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



(This should really be on tech-kern…)

> On Feb 21, 2024, at 1:20 PM, Taylor R Campbell <campbell+netbsd-tech-userlevel%mumble.net@localhost> wrote:
> 
>> Date: Wed, 21 Feb 2024 10:52:55 +0000
>> From: Sad Clouds <cryintothebluesky%gmail.com@localhost>
>> 
>> Hello, for most operating systems determining the size of a block
>> device can be done with:
>> 
>> lseek(fd, 0, SEEK_END);
>> 
>> However, on NetBSD this does not seem to work.
> 
> Internally, this is happens for more or less the same reason that
> stat(2) doesn't return the size of a block device in st_size.
> 
> Each file system on which device nodes can reside implements its own
> VOP_GETATTR (used by both lseek(2) and stat(2)), and most of them use
> the _inode_ size (more or less) rather than querying the block device
> that the device node represents for its physical size.

Add a d_stat devsw entry point and implement spec_getattr()?  Except you don’t want ALL of the results from spec_getattr(), just some of them - rather, specfs can’t possibly provide all of the info, just some of it.  So the file system that owns the vnode (UFS, in this case) would need to call spec_getattr() to get the stuff that specfs can provide, then do its own stuff to overlay the usual UFS stuff over it.

-- thorpej



Home | Main Index | Thread Index | Old Index