Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!tut.cis.ohio-state.edu!ucbvax!ziploc!eps From: eps@toaster.SFSU.EDU (Eric P. Scott) Newsgroups: news.newusers.questions Subject: Re: ln question Summary: No data copying occurs Message-ID: <311@toaster.SFSU.EDU> Date: 11 Feb 90 21:51:40 GMT References: <7419@tank.uchicago.edu> <1990Feb3.081741.23991@ux1.cso.uiuc.edu> <13085@fs2.NISC.SRI.COM> Reply-To: eps@cs.SFSU.EDU (Eric P. Scott) Organization: San Francisco State University Lines: 41 In article <13085@fs2.NISC.SRI.COM> cwilson@NISC.SRI.COM (Chan Wilson) writes: >question: Does 'ln'ing a file make multiple copies? Assuming you're running UNIX (and not some "imitation" UNIX), the answer is no, there are no multiple copies. Each UNIX file is held by an inode (pronounced eye-node). The inode points to actual storage locations for disk files, and contains nearly all the other interesting properties--size, dates, ownership, permissions, etc. Inodes do *not* contain file names--file names only exist in directories. A directory is a collection of name:inode-number pairs. Making a "hard" link involves creating an additional directory entry pointing to the same inode. The inode contains a "link count" which is the number of directory entries that point to it. A file with no links and no references goes away (that's why UNIX has no file "delete"--only "unlink"). An inode doesn't know which directories point to it, only how many. Hard links are indistinguishable from each other (you can't tell which came first)--they point to the same inode, and hence the same file. ls -l will normally show you the link count; the -i option will show inode numbers as well. Two directory entries on the same filesystem with the same inode number reference the same file. (Exercise for the reader: why do most files have one link, but newly created directories two?) Some UNIX implementations implement "symbolic" or "soft" links; each consumes its own inode to hold a file name, but no "data" as we normally think of it. Again, no copy is made of the linked-to file (if it even exists!). The usual "backup" utilities attempt to keep track of multiple links. If entire filesystems are backed up, there shouldn't be any problems. If backups are piecemeal, a file that spans savesets could potentially be restored as separate files, and in that case a copy would be created and the links broken. "There's nothing wrong with your system, just your administrator." -=EPS=-