How to determine file being redirected to in C

Guy Harris guy at auspex.UUCP
Thu Mar 2 06:11:24 AEST 1989


>The device/inode numbers are obtained from the fstat() system call.
>These days, the system ID should also be compared.

The *what*?  "stat" returns no system ID.  RFS is, as far as I know,
smart enough to ensure that the "st_dev" on a "stat" is unique on the
local machine (there appears to be code that looks as if its intent is
to do so); NFS does the same thing.  Thus, even if file A is on a file
system with major/minor 3/1 on machine A, and file B is on a file system
with major/minor 3/1 on machine B, and files A and B have the same
i-number, "stat" or "fstat" will reveal that they have different
"st_dev"s and are thus different files.

This had better be the case; otherwise, your system won't be
POSIX-conformant ("File serial number (st_ino) and device ID (st_dev)
taken together uniquely identify the file within the system.")

This means that "st_dev"s aren't network-unique, and that "stat"ting the
same file on machines A and B will give different "st_dev"s, but that's
life. 



More information about the Comp.unix.questions mailing list