Skip to main content

No way to retrieve file system block sizes?

2 replies [Last post]
faquino
Offline
Joined: 2009-07-07
Points: 0

I think there's currently no way to retrieve the underlying native file system block size for a given file, at least not without resorting to jni or Runtime.exec()

For a most convenient solution it could be implemented as a method (eg. getFSBlockSize()) in java.io.File, although I understand it may not be a frequently used property and it could carry some innecesary overhead. Other alternatives could be java.nio.file.FileSystem, java.nio.file.FileStore or even as a property in java.nio.file.attribute.FileStoreSpaceAttributeView.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alanb
Offline
Joined: 2005-08-08
Points: 0

This could be exposed by FileStore#getAttribute if really needed. I'm curious how you might use, as the use-cases to date have been mostly in the context of direct I/O which is a niche area and require a lot more support (like careful alignment of buffers, etc.).

faquino
Offline
Joined: 2009-07-07
Points: 0

Well, my use case is direct I/O. I have to copy very high data volumes (dozens of TB) between filesystems on a regular basis. Currently, if you want to read exactly a block from disk, you must hard code the block size for the filesystem. If there are multiple filesystems, there's quite a chance their block sizes are different...
... at least for me, this feature would be very useful.