User-space API to inquire block alignment requirements for open file descriptor?
Alan Somers
asomers at freebsd.org
Sun Sep 11 22:55:58 UTC 2016
On Sun, Sep 11, 2016 at 4:34 PM, Matthias Andree <mandree at freebsd.org> wrote:
> Greetings,
>
> given an open file descriptor, do we have a system interface to inquire
> about the block size of the underlying devices? In the past, we used to
> deal with 512-byte blocks, but how about drives using 4096-byte blocks?
>
> Thanks,
> Matthias
Does DIOCGSECTORSIZE do what you want? From the command line, you can
see the result of this ioctl using "diskinfo -v <filename>".
int fd;
unsigned sectorsize;
int error = ioctl(fd, DIOCGSECTORSIZE, §orsize);
-Alan
More information about the freebsd-hackers
mailing list