tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Issues with lseek(2) on a block device



> Date: Sat, 24 Feb 2024 16:21:42 -0500
> From: Thor Lancelot Simon <tls%panix.com@localhost>
> 
> On Wed, Feb 21, 2024 at 09:20:55PM +0000, Taylor R Campbell wrote:
> > I think this is a bug, and it would be great if stat(2) just returned
> > the physical medium's size in st_size -- currently doing this reliably
> > takes at least three different ioctls to handle all storage media, if
> > I counted correctly in sbin/fsck/partutil.c's getdiskinfo.
> 
> I am not sure this can be done for all block devices.  Tapes have block
> devices, and open-reel tape drives do not really know the length of the
> loaded media, while on any other tape drive supporting compression, there
> may really be no such size.

Sure, it's fine if it doesn't give an answer (or, returns st_size=0)
for devices where there's no reasonable answer.

But for a medium which does have a definite size that is known up
front, it should just be returned by stat(2) in st_size instead of
requiring a dance of multiple different NetBSD-specific ioctls to
guess at which one will work.


Home | Main Index | Thread Index | Old Index