Path: utzoo!attcan!uunet!auspex!guy From: guy@auspex.UUCP (Guy Harris) Newsgroups: comp.unix.questions Subject: Re: How to determine file being redirected to in C Keywords: redirection Message-ID: <1103@auspex.UUCP> Date: 1 Mar 89 20:11:24 GMT References: <10@sherpa.UUCP> <9745@smoke.BRL.MIL> Reply-To: guy@auspex.UUCP (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 19 >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.