8179320: File.getUsableSpace() returns a negative number on very large file system
Weijun Wang
weijun.wang at oracle.com
Sat Nov 23 03:37:23 UTC 2019
Just curious.
Why is fs.getSpace() returning negative here? Naively, I would think it is truncating an int128 to int64. If so, if the value exceeds 2^64, will it be positive again?
Thanks,
Max
> On Nov 23, 2019, at 1:40 AM, Brian Burkhalter <brian.burkhalter at oracle.com> wrote:
>
> PING!
>
>> Begin forwarded message:
>>
>> From: Brian Burkhalter <brian.burkhalter at oracle.com>
>> Subject: Re: 8179320: File.getUsableSpace() returns a negative number on very large file system
>> Date: November 15, 2019 at 2:40:06 PM PST
>> To: Alan Bateman <Alan.Bateman at oracle.com>
>> Cc: Core-Libs-Dev <core-libs-dev at openjdk.java.net>
>>
>>
>>> On Nov 15, 2019, at 2:59 AM, Alan Bateman <Alan.Bateman at oracle.com <mailto: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.
>>
>> I’ve updated the patch [1] to address this. The difference versus webrev.00 is [2].
>>
>> Thanks,
>>
>> Brian
>>
>> [1] http://cr.openjdk.java.net/~bpb/8179320/webrev.01/ <http://cr.openjdk.java.net/~bpb/8179320/webrev.01/>[2] diff vs. webrev.00
>>
>> --- a/src/java.base/share/classes/java/io/File.java
>> +++ b/src/java.base/share/classes/java/io/File.java
>> @@ -1804,7 +1804,8 @@
>> * returned.
>> *
>> * @return The size, in bytes, of the partition or {@code 0L} if this
>> - * abstract pathname does not name a partition
>> + * abstract pathname does not name a partition or if the size
>> + * cannot be obtained
>> *
>> * @throws SecurityException
>> * If a security manager has been installed and it denies
>> @@ -1844,9 +1845,10 @@
>> * will succeed.
>> *
>> * @return The number of unallocated bytes on the partition or {@code 0L}
>> - * if the abstract pathname does not name a partition. This
>> - * value will be less than or equal to the total file system size
>> - * returned by {@link #getTotalSpace}.
>> + * if the abstract pathname does not name a partition or if this
>> + * number cannot be obtained. This value will be less than or
>> + * equal to the total file system size returned by
>> + * {@link #getTotalSpace}.
>> *
>> * @throws SecurityException
>> * If a security manager has been installed and it denies
>> @@ -1889,9 +1891,10 @@
>> * to this file system will succeed.
>> *
>> * @return The number of available bytes on the partition or {@code 0L}
>> - * if the abstract pathname does not name a partition. On
>> - * systems where this information is not available, this method
>> - * will be equivalent to a call to {@link #getFreeSpace}.
>> + * if the abstract pathname does not name a partition or if this
>> + * number cannot be obtained. On systems where this information
>> + * is not available, this method will be equivalent to a call to
>> + * {@link #getFreeSpace}.
>> *
>> * @throws SecurityException
>> * If a security manager has been installed and it denies
>
More information about the core-libs-dev
mailing list