RFR [8054029] (fc) FileChannel.size() returns 0 for block devices

Ivan Gerasimov ivan.gerasimov at oracle.com
Fri Sep 12 14:04:07 UTC 2014


Hello!

There was an edge case found, where FileChannel.size() reports wrong 
size: This is for block device on Linux.
That's due to limitation of stat on Linux, which reports the size of 
block special devices to be zero.

The proposed solution is to explicitly check, if we deal with a block 
device, and use the ioctl() call with the special flag.

BUGURL: https://bugs.openjdk.java.net/browse/JDK-8054029
WEBREV: http://cr.openjdk.java.net/~igerasim/8054029/0/webrev/

The solution isn't perfect, in particular, because we still are getting 
zero from j.nio.Files.size().

A test is provided with the fix, though I marked it as ignored.
This is because the access to the special devices normally needs the 
root permissions.

Sincerely yours,
Ivan


More information about the nio-dev mailing list