Best web site - 3. Links or even no name. In

3. Links or even no name. In UNIX, a file name is just an entry in a directory inode. Such an entry is called a link. Let us look at links in more detail. 3. Links The best way to understand what links are is to look at an example. Let’s create a (regular) file: $ pwd /home/queen/example $ ls $ touch a $ ls -il a 32555 -rw-r–r–1 queen queen 0 Aug 6 19:26 a The -i option of the ls command prints the inode number, which is the first field on the output. As you can see, before we created file a, there were no files in the directory. The other field of interest is the third one, which is the number of file links (well, inode links, in fact). The touch a command can be separated into two distinct actions: creation of an inode, to which the operating system has given the number 32555, and whose type is the one of a regular file; creation of a link to this inode, named a, in the current directory (/home/queen/example). Therefore the /home/queen/example/a file is a link to the inode numbered 32555, and it’s currently the only one: the link counter shows 1. But now, if we type: $ ln a b $ ls -il a b 32555 -rw-r–r–2 queen queen 0 Aug 6 19:26 a 32555 -rw-r–r–2 queen queen 0 Aug 6 19:26 b $ We create another link to the same inode. As you can see, we didn’t create a file named b. Instead, we just added another link to the inode numbered 32555 in the same directory, and attributed the name b to this new link. You can see on the ls -l output that the link counter for the inode is now 2 rather than 1. systems, in-memory inodes have a unique number right across the system. One solution to obtain uniqueness, for example, is to hash the on-disk inode number against the block device identifier.

Leave a Reply