stat() / lstat() and incorrect field values
- From: Jules <jules.richardsonnews@xxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 08 Apr 2009 18:14:09 -0500
Hi all,
stat() and lstat() calls seem to be consistently giving me correct
st_dev and st_gid values, but incorrect values for st_ino, st_mode,
st_size, st_nlink, and st_uid (I've not analysed the other fileds yet).
I'm not doing anything special, just:
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
...
struct stat st;
stat(filename, &st);
/* printing values here gives unexpected results */
(I'm checking the result of the stat() call before querying values,
obviously :-)
For any file, st_mode seems to always end up being 0, st_ino is a random
integer value (consistent across runs against the same file), st_nlink
ends up being very close to what I st_ino *should* be (checking against
the 'stat' system binary).
It's almost as though memory gets copied somewhere behind the scenes and
something's getting misaligned; but if so, why might that be - and how
come it's not limited to a single kernel release? Makes me think it's user
error, but I'm not sure what I'm doing wrong :-)
cheers
Jules
.
- Follow-Ups:
- Re: stat() / lstat() and incorrect field values
- From: Lew Pitcher
- Re: stat() / lstat() and incorrect field values
- Prev by Date: Re: Why are the syslogd facility names hardlisted?
- Next by Date: Re: stat() / lstat() and incorrect field values
- Previous by thread: Why are the syslogd facility names hardlisted?
- Next by thread: Re: stat() / lstat() and incorrect field values
- Index(es):
Relevant Pages
|