Any way to access fstat.st_blocks from Java (UnixFileAttributesView)
Uwe Schindler
uschindler at apache.org
Wed Jul 3 14:51:05 UTC 2019
Hi,
sorry for the late response. To actually fix my problem I had to go and use a native solution by using the JNR-POSIX package by Charles Nutter (@headius) from Maven (see <https://github.com/jnr/jnr-posix> https://github.com/jnr/jnr-posix). I don’t like the complexity of that setup (you need like 8 additional jar files), but at least it works for now. JNA would have been another solution, but I did not want to create the st_stat structs and all syscalls needed to get from a NIO Path to that value.
The question is how to propose a change request like this, because getting the size a file *occupies* on disk is a useful information. Adding this should bring no backwards breaks or any need to change public APIs, as the “unix” view is not exposed as a public API, its just accessible using the lookup by string key. So adding two other key-value pairs should be easy. What do you think?
Maybe I can create a patch to add this, but what’s the way to go? This may be a first try to submit something as a “new contributor”, because I have signed the CLA already.
This change is not Lucene related (was a problem in my daily work), but we have some other ideas for more complex patches in Lucene, so this could be a start.
Uwe
-----
Uwe Schindler
uschindler at apache.org
ASF Member, Apache Lucene PMC / Committer
Bremen, Germany
https://lucene.apache.org/
From: Brian Burkhalter <brian.burkhalter at oracle.com>
Sent: Friday, June 28, 2019 5:45 PM
To: Alan Bateman <Alan.Bateman at oracle.com>
Cc: Uwe Schindler <uschindler at apache.org>; nio-dev <nio-dev at openjdk.java.net>
Subject: Re: Any way to access fstat.st_blocks from Java (UnixFileAttributesView)
On Jun 28, 2019, at 7:18 AM, Alan Bateman <Alan.Bateman at oracle.com <mailto:Alan.Bateman at oracle.com> > wrote:
Any hints to get the file size on disk from Java that uses the st_blocks and st_blksize behind the scenes?
There isn't anything at this time. You are right that the "unix" view could expose a "blocks" attribute. The block size is already exposed by FileStore::getBlockSize - the motivation for that was sizing and aligning buffers for use with direct I/O.
Maybe an enhancement should be filed?
Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190703/26511a96/attachment-0001.html>
More information about the nio-dev
mailing list