Directories

As well as its contents, a file has a name and some properties, or “administrative information”; that is, the file’s creation/modification date and its permissions. The properties are stored in the file’s inode, a special block of data in the file system that also contains the length of the file and where on the disk it’s stored. The system uses the number of the file’s inode; the directory structure just names the file for our benefit.

 

A directory is a file that holds the inode numbers and names of other files. Each directory entry is a link to a file’s inode; remove the filename and you remove the link. (You can see the inode number for a file by using ls –i.) Using the ln command, you can make links to the same file in different directories.

目录也是一个文件,它保存着其它文件的inode数目和名字;删除文件名将删除这个链接。

 

When you delete a file all that happens is that the directory entry for the file is removed and the number of links to the file goes down by one. The data for the file is possibly still available through other links to the same file. When the number of links to a file (the number after the permissions in ls -l) reaches zero, the inode and the data blocks it references are then no longer in use and are marked as free.

 

Files are arranged in directories, which may also contain subdirectories. These form the familiar file system hierarchy. A user, say neil, usually has his files stored in a “home” directory, perhaps /home/neil, with subdirectories for e-mail, business letters, utility programs, and so on. Note that many command shells for UNIX and Linux have an excellent notation for getting straight to your home directory: the tilde (~). For another user, type ~user. As you know, home directories for each user are usually subdirectories of a higher-level directory created specifically for this purpose, in this case /home.

 

System Calls

These and other system calls are usually documented in section 2 of the manual pages. Prototypes providing the parameter lists and function return types for system calls, and associated #defines of constants, are provided in include files. The particular ones required for each system call will be included with the descriptions of individual calls.

 

Library Functions 

Library functions are usually documented in section 3 of the manual pages and often have a standard include file associated with them, such as stdio.h for the standard I/O library. 

 

posted on 2010-08-31 09:42  Lonely Programming Blog  阅读(213)  评论(0编辑  收藏  举报