8179320: File.getUsableSpace() returns a negative number on very large file system

Brian Burkhalter brian.burkhalter at oracle.com
Fri Nov 15 15:57:55 UTC 2019


> On Nov 15, 2019, at 2:59 AM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> 
> On 02/11/2019 00:13, Brian Burkhalter wrote:
>> For this issue [1], please review this patch [2] and the corresponding CSR [3].
>> 
>> 
> One thing that isn't clear is how these methods behave when the space info can't be obtained. It is specified to return 0L when the path is not "a partition" but I think it also returns 0L when the information cannot be obtained.

It checks whether it has read permission, as documented, and also whether the path string is invalid. In the latter case 0L is returned. Zero is also returned if statfs(2) fails (returns -1). This is different behavior from FileStore.getXSpace() which throws an IOException if statfs fails.

For the File.getXSpace() case, then perhaps something like this would be better documentation of return:

"The size, in bytes, of the partition or 0L if this abstract pathname is not a valid path or the information cannot be obtained."

Brian


More information about the core-libs-dev mailing list