Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6395581

File.listFiles() is unable to read nfs-mounted directory (MacOS X)

XMLWordPrintable

    • b79
    • sparc
    • solaris_8, solaris_10

        java.io.File.listFiles() is unable to read nfs-mounted directory from MacOS X.

        1. Testcase
        -----------
        Here is a short testprogram:
        % more Main.java
        import java.io.File;

        public class Main {

                public static void main(String[] args){
                        if(args.length != 1){
                                System.out.println("USAGE: ");
                                System.out.println(" java Main <directory_on_nfs_mount>");
                                System.out.println();
                                System.exit(1);
                        }

                        String filename = args[0];
                        File file = new File(filename);

                        if(! file.exists() ){
                                System.out.println("file "+filename+" does not exist.");
                        }
                        else if ( file.isFile() ){
                                System.out.println("f "+filename);
                        }
                        else if ( file.isDirectory() ){
                                System.out.println("listing contents of directory "+filename);
                                File[] subfiles = file.listFiles();
                                for( int i=0 ; i<subfiles.length ; i++ ){
                                        System.out.print( subfiles[i].isFile() ? "f " : "d " );
                                        System.out.println( subfiles[i].getName() );
                                }
                                System.out.println();
                                System.out.println( subfiles.length + " files total");
                        }
                }
        }

        2. nfs-directory
        ----------------
        I used an nfs directory mounted via automounter shared from MacOS 10.4.5 (Darwin 8.5.0):

        3. Compile
        ----------
        % /j2sdk1.4.2_11/bin/java -version
        java version "1.4.2_11"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_11-b02)
        Java HotSpot(TM) Client VM (build 1.4.2_11-b02, mixed mode)
        % /j2sdk1.4.2_11/bin/javac Main.java
        %

        4. Run
        ------
         I blanked the ip_adress using "<ip_addr>" in the output below.

        % /j2sdk1.4.2_11/bin/java -version
        java version "1.4.2_11"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_11-b02)
        Java HotSpot(TM) Client VM (build 1.4.2_11-b02, mixed mode)
        % /j2sdk1.4.2_11/bin/java Main /net/<ip_addr>
        listing contents of directory /net/<ip_addr>
        d Users

        1 files total
        %
         That's fine...

        % /j2sdk1.4.2_11/bin/java Main /net/<ip_addr>/Users
        listing contents of directory /net/<ip_addr>/Users
        d thomas

        1 files total
        %
         That's fine...

        % /j2sdk1.4.2_11/bin/java Main /net/<ip_addr>/Users/thomas
        listing contents of directory /net/<ip_addr>/Users/thomas
        d Public

        1 files total
        %
         That's fine...

        % /j2sdk1.4.2_11/bin/java Main /net/<ip_addr>/Users/thomas/Public
        listing contents of directory /net/<ip_addr>/Users/thomas/Public

        0 files total
        %
         That's wrong ....

        % ls -l /net/<ip_addr>/Users/thomas/Public
        total 16
        drwx-wx-wx 3 thomas 990 102 Nov 30 13:18 Drop Box
        -rwxrwxrwx 1 thomas 990 18 Mar 8 13:35 Hallo_Thomas.txt
        %


        % df -k /net/<ip_addr>/
        Filesystem kbytes used avail capacity Mounted on
        -hosts 0 0 0 0% /net
        % df -k /net/<ip_addr>/Users/
        Filesystem kbytes used avail capacity Mounted on
        -hosts 0 0 0 0% /net/<ip_addr>/Users
        % df -k /net/<ip_addr>/Users/thomas/
        Filesystem kbytes used avail capacity Mounted on
        -hosts 0 0 0 0% /net/<ip_addr>/Users/thomas
        % df -k /net/<ip_addr>/Users/thomas/Public
        Filesystem kbytes used avail capacity Mounted on
        <ip_addr>:/Users/thomas/Public
                             58474008 31462436 26755572 55% /net/<ip_addr>/Users/thomas/Public
        %

              chegar Chris Hegarty
              thlenz Thomas Lenz (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: