[Mono-list] Unable to get block device size in UnixStream
Robert Jordan
robertj at gmx.net
Thu Jan 31 13:41:45 UTC 2013
On 31.01.2013 12:45, Christian Schmid wrote:
> Hi Jon
>
> Unfortunately, it did not work. Although /dev/sda2 is a 500 gb device, statfvs("dev/sda2", out stat) and fstatvfs(fd, out stat) returned the following:
>
> bavail=2560
> bfree=2560
> blocks=2560
> bsize=4096
> files=8262645
> frsize=4096
Maybe the device must be mounted to be able to get meaningful values...
If you don't care about POSIX and only want to handle Linux,
reading the ProcFS files
/sys/block/<device>/size
and
/sys/block/<device>/<partition>/size
should return the size of the device in 512-byte blocks.
It works for me with an unmounted device.
Robert
More information about the Mono-list
mailing list