Selaa lähdekoodia

HADOOP-3161. Fix FIleUtil.HardLink.getLinkCount on Mac OS. Contributed by
Nigel.


git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@644600 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 17 vuotta sitten
vanhempi
commit
910e6f72fe
2 muutettua tiedostoa jossa 11 lisäystä ja 1 poistoa
  1. 3 0
      CHANGES.txt
  2. 8 1
      src/java/org/apache/hadoop/fs/FileUtil.java

+ 3 - 0
CHANGES.txt

@@ -452,6 +452,9 @@ Trunk (unreleased changes)
     HADOOP-3010. Fix ConcurrentModificationException in ipc.Server.Responder.
     (rangadi)
 
+    HADOOP-3161. Fix FIleUtil.HardLink.getLinkCount on Mac OS. (nigel
+    via omalley)
+
 Release 0.16.2 - 2008-04-02
 
   BUG FIXES

+ 8 - 1
src/java/org/apache/hadoop/fs/FileUtil.java

@@ -463,7 +463,8 @@ public class FileUtil {
     enum OSType {
       OS_TYPE_UNIX, 
       OS_TYPE_WINXP,
-      OS_TYPE_SOLARIS; 
+      OS_TYPE_SOLARIS,
+      OS_TYPE_MAC; 
     }
   
     private static String[] hardLinkCommand;
@@ -480,6 +481,10 @@ public class FileUtil {
         hardLinkCommand = new String[] {"ln", null, null};
         getLinkCountCommand = new String[] {"ls","-l"};
         break;
+      case OS_TYPE_MAC:
+        hardLinkCommand = new String[] {"ln", null, null};
+        getLinkCountCommand = new String[] {"stat","-f%l"};
+        break;
       case OS_TYPE_UNIX:
       default:
         hardLinkCommand = new String[] {"ln", null, null};
@@ -493,6 +498,8 @@ public class FileUtil {
         return OSType.OS_TYPE_WINXP;
       else if (osName.indexOf("SunOS") >= 0)
          return OSType.OS_TYPE_SOLARIS;
+      else if (osName.indexOf("Mac") >= 0)
+         return OSType.OS_TYPE_MAC;
       else
         return OSType.OS_TYPE_UNIX;
     }