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
On Thu, Feb 22, 2024 at 05:47:55AM +0000, Sad Clouds wrote:
> On Wed, 21 Feb 2024 12:48:34 -0800
> Jason Thorpe <thorpej%me.com@localhost> wrote:
>
> >
> > > On Feb 21, 2024, at 2:52???AM, Sad Clouds <cryintothebluesky%gmail.com@localhost> wrote:
> > >
> > > Hello, for most operating systems determining the size of a block
> > > device can be done with:
> > >
> > > lseek(fd, 0, SEEK_END);
> >
> > On what operating systems does this do what you claim?
> >
> > > However, on NetBSD this does not seem to work.
> >
> > It doesn???t work on macOS, either:
> >
> > thorpej-mbp:thorpej 541$ sudo ./lseek /dev/disk4
> > Password:
> > lseek(fd, 4096, SEEK_SET) = 4096 bytes
> > lseek(fd, 0, SEEK_END) = 0 bytes
> > thorpej-mbp:thorpej 542$
> >
> > -- thorpej
> >
>
> Hello, it works on Linux, FreeBSD, Solaris and it also works on NetBSD
I don't think that's correct for all devices on Linux - generally, on
Linux systems I have to use the BLKGETSIZE64 ioctl to reliable determine
the size of a block device.
Home |
Main Index |
Thread Index |
Old Index