My C program mounts a raw device, then lseeks to its end to find the length. This works well in Linux and Windows, but fails in AIX - apparently you can seek to any location, even past the end. Any idea on how to do it correctly in C?
+1
A:
I've never used AIX, but have you tried using read
. It may fail either at or past the end, so you could do binary search for the end using seek
and read
, maybe.
nategoose
2010-09-30 19:42:20
A:
Nategoose, There must be a better way. Running "df" shows the size immediately. I don't understand why stat or fstat don't work. I even tried taking the _cnt field from the opaque FILE structure (a big no no, I know, but I'm getting desperate). It's 0.
David Meiri
2010-10-19 15:24:46