(This should really be on tech-kern…) > On Feb 21, 2024, at 1:20 PM, Taylor R Campbell > <campbell+netbsd-tech-userle...@mumble.net> wrote: > >> Date: Wed, 21 Feb 2024 10:52:55 +0000 >> From: Sad Clouds <cryintotheblue...@gmail.com> >> >> 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