-
Bug
-
Resolution: Fixed
-
P4
-
9
-
Mac OS X
-
b70
-
os_x
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8098756 | emb-9 | Brian Burkhalter | P4 | Resolved | Fixed | team |
The printed output of this class may return incorrect values for large file systems:
public class FileGetSpace {
public static void main(String[] args) throws Throwable {
String pathname = "/mnt";
File file = new File(pathname);
long total = file.getTotalSpace();
long free = file.getFreeSpace();
long usable = file.getUsableSpace();
System.out.printf("total: %d free: %d usable: %d\n",
total, free, usable);
}
}
For example, the output of the command 'df -k' for mounted file system "node.domain.com:/export" was
$ df -k /mnt
Filesystem 1024-blocks Used Available Capacity iused ifree %iused Mounted on
node.domain.com:/export 7456395490 5480807360 1975588130 74% 262591304 3951176261 6% /mnt
and the output of the above test class was
total: 1038279215616 free: 2023002245632 usable: 2023002245632
Whereas the free space 2023002245632/1024 = 1975588130 is correct, the total space 1038279215616/1024 = 1013944546 most certainly is not.
A fix similar to that forJDK-8081843 appears to be in order.
public class FileGetSpace {
public static void main(String[] args) throws Throwable {
String pathname = "/mnt";
File file = new File(pathname);
long total = file.getTotalSpace();
long free = file.getFreeSpace();
long usable = file.getUsableSpace();
System.out.printf("total: %d free: %d usable: %d\n",
total, free, usable);
}
}
For example, the output of the command 'df -k' for mounted file system "node.domain.com:/export" was
$ df -k /mnt
Filesystem 1024-blocks Used Available Capacity iused ifree %iused Mounted on
node.domain.com:/export 7456395490 5480807360 1975588130 74% 262591304 3951176261 6% /mnt
and the output of the above test class was
total: 1038279215616 free: 2023002245632 usable: 2023002245632
Whereas the free space 2023002245632/1024 = 1975588130 is correct, the total space 1038279215616/1024 = 1013944546 most certainly is not.
A fix similar to that for
- backported by
-
JDK-8098756 File.get{Free,Total,Usable}Space may return unexpected results with >2TB file systems
-
- Resolved
-
- relates to
-
JDK-8081843 (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
-
- Closed
-