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 > On Jan 29, 2013, at 3:46 AM, Dragony <[email protected]> wrote: >> I want to get the device size of /dev/sda. I have an open fd and a UnixStream > Don't use UnixStream.Length here; UnixStream.Length uses the stat(2) system > call, which states: > > http://linux.die.net/man/2/stat >> The st_size field gives the size of the file (if it is a regular file or a >> symbolic link) in bytes. The size of a symbolic link is the length of the >> pathname it contains, without a terminating null byte. > > You should instead use Syscall.fstatvfs() and Statvfs: > > > http://docs.go-mono.com/index.aspx?link=M%3aMono.Unix.Native.Syscall.fstatvfs(System.Int32%2cMono.Unix.Native.Statvfs%40) > http://docs.go-mono.com/index.aspx?link=T%3aMono.Unix.Native.Statvfs%2f* > > For example: > > Statvfs stat; > int r = Syscall.fstatvfs (fd, out stat); > int filesystem_size = stat.f_blocks*stat.f_frsize; > > - Jon > >
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mono-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-list
