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

(fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems

XMLWordPrintable

    • b70
    • os_x

        Test URL: api/java_nio/file/FileStore/index.html\#FileStoreTests
        JDK Version: JDK 7,8,9

        Standalone Code Snippet:

        import java.nio.file.*;
        import java.io.IOException;

        public class NIOTest {
        public static void main(String[] args) throws IOException {
        for (FileStore store: FileSystems.getDefault().getFileStores()) {
                 long total = store.getTotalSpace()/(1024*1024*1024); // Just to convert into Gi
                 long avail = store.getUsableSpace()/(1024*1024*1024);
                 System.out.format("%-20s %12d %12d%n", store, total, avail);
             }
        }
        }

        Comparing the output of shared location on Mac and Linux:


        Code run on mac:

        stt-mac-04:bin gtee$ ./java NIOTest

        /net/stt-13.ru.oracle.com/export (stt-13.ru.oracle.com:/export) 966Gi 1903Gi
        /net/stt-13.ru.oracle.com/export2 (stt-13.ru.oracle.com:/export2) 1147Gi 187Gi

        Code run on Linux:

        /net/stt-13.ru.oracle.com/export (stt-13.ru.oracle.com:/export) 7110Gi 1903Gi
        /net/stt-13.ru.oracle.com/export2 (stt-13.ru.oracle.com:/export2) 7291Gi 187Gi


        Output by df -kh :

        Filesystem Size Used Avail Capacity iused ifree %iused Mounted on

        stt-13.ru.oracle.com:/export2 7.1Ti 6.9Ti 188Gi 98% 58113721 393509647 13% /net/stt-13.ru.oracle.com/export2
        stt-13.ru.oracle.com:/export 6.9Ti 5.1Ti 1.9Ti 74% 261224288 3991590226 6% /net/stt-13.ru.oracle.com/export



        On Mac, JDK provided wrong information of getTotalSpace and it gives a value less than getUsableSpace.


              bpb Brian Burkhalter
              vaibhav Vaibhav Choudhary (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

                Created:
                Updated:
                Resolved: