Subject: Re: Using stat() to obtain a block device size on 1.6.2_STABLE
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-kern
Date: 08/12/2004 23:02:15
In article <20040812191349.GA5177@skywalker.sceen>,
Richard Braun <syn@sceen.net> wrote:
>-=-=-=-=-=-
>
>Hi,
>
>I'm using stat() to get the size of a file. When it's a block device,
>the returned size (st_size field) is 0. But sometimes it correctly
>reports the size. It seems the kernel doesn't look for the size until
>an I/O operation is performed on the device. Is it a bug or another
>stupid standard compliance ? I tested it only on 1.6.2, but it'd be
>good to check on 2.0 and current if it hasn't been corrected yet.

I don't think that you can depend on stat to get the size of a block device.
How is it supposed to be done for removable media anyway?

christos