Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!cs.utexas.edu!uwm.edu!linac!att!cbfsb!cbnewsc!gregg From: gregg@cbnewsc.att.com (gregg.g.wonderly) Newsgroups: comp.sys.amiga Subject: Re: Backup links on 2.0 Message-ID: <1991Jan14.200405.3205@cbnewsc.att.com> Date: 14 Jan 91 20:04:05 GMT References: <2866@dsacg3.dsac.dla.mil> Organization: AT&T Bell Laboratories Lines: 49 From article <2866@dsacg3.dsac.dla.mil>, by nfs1675@dsacg3.dsac.dla.mil ( Michael S Figg): > In article <7304@jhunix.HCF.JHU.EDU>, barrett@jhunix.HCF.JHU.EDU (Dan Barrett) writes: >> Since links have nothing to do with file protections, this is >> perhaps not a good place for link information. > > I agree that this is inconsistent, but is it anymore so than the first > position of the UNIX permissions, which shows whether the entry is a file, > directory, etc. I don't of anyway you can change this first position with > the 'chmod' command, besides the fact that it probably isn't real kosher to > change files to directorys, or directorys to files. I have little experience > with links in the UNIX environment, and don't have an A3000 or WB2.0 but > would guess that a flag could be used just like the directory is marked in > UNIX. The implementation details are what drives the output of the UN*X ls(1) output. The inode (every file/directory is an inode) contains a value called "mode". Mode has, besides the protections, the other flag type values, specifically, S_IFDIR, S_IFBLK, S_IFCHR etc which are the more special types of inodes. Another field contains the link count, which is one for most files, and two for most directories (hopefully all). The link count refers to the number of directory entries which contain this inode number. That is, doing a 'od -cx .' on a particular directory (under SYSV) yields $ od -xc 0000000 26d0 2e00 0000 0000 0000 0000 0000 0000 & 320 . \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 $ pwd /c/gregg $ od -xc .. # trimed to just the needed output yields 0015320 26d0 6772 6567 6700 0000 0000 0000 0000 & 320 g r e g g \0 \0 \0 \0 \0 \0 \0 \0 \0 The first 16 bits of a SYSV directory entry is the inode number. Inodes are indexed from the filesystem table directly by this number. Thus, the action of ln foo bar is to merely append a directory entry to "." which contains the same inode number as foo, and then to go into the filesystem and increment the link count. Now, it would probably not be a bad idea to say "Link", but you also need to say "Count" somewhere, so rather than say both (those that use links "know" what that number means generally), the link count suffices. -- ----- gregg.g.wonderly@att.com (AT&T bell laboratories)