Coding question: finding the size of a block device

Andrew andrew.chace at gmail.com
Thu Jun 22 21:15:56 UTC 2006


Hello,

First off, is this the appropriate list for coding questions? I read
questions@, but I do not often see discussions about code there, so I
thought I might ask here instead. If not, please correct me.

I need to know the size of a block device in some code that I'm writing.
I checked the man pages, and I was thinking that I could use fstat(),
but after I call it on the device, stat->st_size is still 0. I tested
fstat()'s return value, and it's correct; there are no errors. So, I'm
thinking that this is not the correct way to do this. 

So I guess my question is: is there a POSIX compatible function that
will allow me to check the size of a given block device?

Thanks,
-Andrew



More information about the freebsd-hackers mailing list