How to determine file being redirected to in C

Jonathan Bayer jbayer at ispi.UUCP
Thu Mar 2 23:15:20 AEST 1989


In article <1105 at auspex.UUCP> guy at auspex.UUCP (Guy Harris) writes:
}
} }Use the stat() and fstat() functions, then compare the inode numbers 
} }in the structure.  If they are the same then the two files are identical.
}
}Wrong.  If the inode numbers (st_ino) *AND* the file system IDs (st_dev)
}are the same, then the two files are identical.  If just the inode
}numbers are the same, you can't conclude anything about whether the
}files are the same or not.  They could have the same inode number but be
}on two different file systems; inode numbers are *not* unique across
}file systems.

I stand corrected.  Working on one filesystem for a while tends to make
one forget that the inodes can come from multiple filesystems.


JB
-- 
Jonathan Bayer			      Beware: The light at the end of the
Intelligent Software Products, Inc.	      tunnel may be an oncoming dragon
19 Virginia Ave.				...uunet!ispi!jbayer
Rockville Centre, NY 11570  (516) 766-2867    jbayer at ispi.UUCP



More information about the Comp.unix.questions mailing list