Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Sep 2016 05:57:11 +0700
From:      Eugene Grosbein <eugen@grosbein.net>
To:        Matthias Andree <mandree@FreeBSD.org>, freebsd-hackers@freebsd.org
Subject:   Re: User-space API to inquire block alignment requirements for open file descriptor?
Message-ID:  <57D5E147.1030802@grosbein.net>
In-Reply-To: <c9063edd-a3c1-fce4-483c-a192addc6b86@FreeBSD.org>
References:  <c9063edd-a3c1-fce4-483c-a192addc6b86@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
12.09.2016 5:34, Matthias Andree пишет:
> 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?

Take a look at system cat(1) sources. It uses several system interfaces
and some logic to optimize its read buffer size: fstat(2)/sbuf.st_blksize for file descriptor,
sysconf(_SC_PHYS_PAGES) for system having plenty of RAM,
BUFSIZE_SMALL and BUFSIZE_MAX constanst for lower/upper limits.





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?57D5E147.1030802>