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

Re: stat().st_size and lseek() should return block device size.



On Tue, May 07, 2024 at 07:22:57PM +0200, Lars Rohwedder wrote:
> I'd prefer when both stat().st_size and lseek() just return the "number
> of bytes" (that you can read out until you get EOF) of that block
> device.

That would be nice in an ideal world, but it does not match what the
Linux kernel currently does (0 for st_size, capacity for lseek) or the
BSD heritage (0 for both st_size and lseek), which differs still from
Solaris (capacity for st_size and lseek).

> Anything else is just awkward and does not make any sense to me
> (from the programmer's point of view), even though POSIX might not
> require it for block devices.

And that's why we're having this conversation in the first place.

> 
> And for NBD this size is always known to the nbd-server: Either size of
> served file, sum of the sizes of all chunks ("multifile") or configured
> size (for "treefiles").

Maybe what it boils down to is whether nbd-server is intended to serve
block devices.  Right now, it does what you want with regular files,
but gets the size of block devices wrong.

> 
> So why not just give that information to the clients easily?
> 
> Just my 2 ct,
> 
> 	Lars R.
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization:  qemu.org | libguestfs.org


Reply to: