Hard Link Symbolic Link

A special device file is used to describe the attached IO device. UNIX accesses devices via their special files. In UNIX, device drivers themselves software interfaces that control the devices are part of the kernel, and can be accessed by using certain system calls UNIX internals. A special device file is a kind of pointer to the corresponding device driver within the kernel; it is a very simple file that contains two pointers: major and minor numbers. The major number points to the device class, while the minor number points to the individual device within the class. All special device files reside in the directory dev and its subdirectories on System V. There are two groups of special device files: block device files and character device files.

2.2.4.3.1 Block Device File

IO operations are provided through a group of buffers; the system maintains a buffer pool for all block devices. The block device is accessed in fixed−size blocks. Physically, the high−speed data transfer is realized using a DMA mechanism direct memory access data transfer. The letter b in the long listing of a directory identifies the block device files. The following disk−related block device files are examples of block device files: devdisk0a or devdskc1d1s5.

2.2.4.3.2 Character Device File

Nonbuffered IO operations are provided via a character or raw device. Physically, the data transfer is performed through a registered data exchange between the device and its controller. Character devices include all devices that do not fit the block IO transfer. The letter c in the long listing of a directory identifies the character device files. The following disk related raw device files are examples of character special files: devrdisk0a or devrdskc1d1s5.

2.2.4.4 Link

A link is a mechanism that allows multiple filenames to refer to a single file on a disk, i.e., a single inode. There are two kinds of links: hard links and symbolic links.

2.2.4.4.1 Hard Link

A hard link associates two or more filenames with an inode; each inode keeps a record of a number of linked filenames. Only when all filenames are deleted will the file itself also be deleted, and the corresponding inode released and returned as free for new file assignments. Strictly speaking, a hard link is not a separate file type; each hard link represents an already existing file with an additional filename. The only way to identify mutually hard−linked filenames is to list a directory or directories by using the ls −i command and check for identical inode numbers. The −i option displays, beside the filename, the inode number for each displayed file in the listed directory. Hard links always remain within the same filesystem; simply, inodes cannot be shared between filesystems, and two hard links are always associated with the same inode. A hard link never creates a new file; it only attaches a new filename to the existing file. This means that a hard link only presents a new entry in a directory, a new record about a filename−inode pair. To create a hard link use the ln command: ln myfile hardlink 46

2.2.4.4.2 Symbolic Link

A symbolic link is a pointer file to another file elsewhere in the overall hierarchical directory tree. By creating a symbolic link, a new small file is also created; this new file contains the full−path filename of the linked file. There is no restriction on the use of symbolic links; they span filesystem boundaries independently of the origin of the linked file. Symbolic links are very common this cannot be said for hard links; they are easy to create, easy to maintain and easy to see. The letter l in the long listing of a directory identifies them; a linked file is also displayed in a visually comprehensive way see previous example for file types. To create a symbolic link use also the ln command with the option −s: ln −s myfile symlink This command creates another file named symlink in the current directory with a separate inode since this is a completely new file that points to the file myfile. Both types of links are presented in Figure 2.1. Let me explain it in more detail. Figure 2.1: Hard and symbolic links. For an existing file named myname, which is determined by the inode index node N1, both links are created. The hard link hardlink is another name for the file myfile, and it corresponds to the same inode N1. The symbolic link symlink represents another file determined by the inode N2; its contents point to the file myfile. 47 What will happen if another file named myfile is created in the same directory? This is a brand new file, determined by the new index node N3 and unrelated to the existing file hardlink, which continues to exist as a different file. However, the file symlink is now linked with the new file myname, and it continues to point to the newly created file myfile.

2.2.4.5 Socket