"Linux c programming guide" Learning Notes 4

7.1 File System Introduction

7.1.1 file

File types: regular files, directories, files, links, files, device file, pipe file

File permissions: rwx

Access: file owner, file owner group of users with other users

7.1.2 inode

7.1.3 File System

  Tree hierarchy of the system, ultimately comes down to the root file directory / on


7.2 based on file descriptor IO operations

7.2.1 Create a file, open and close

Create create 1 file

2 file open open

(File operations are not guarantee of success, so the file the operation should be carried out to detect if the error to terminate the program)

Close close 3 files

7.2.2 file read and write operations write read

Positioning lseek 7.2.3 file


Other operations 7.3 files

7.3.1 modify file attributes

1 modify file permissions

Change file owner chown fchown

  (When the file operation, call chown use the path to the file name, file descriptor when the file is opened when calling fchown)
  only the root user can use

Access chmod fchmod change file

2 other properties to modify the file

Rename rename

Modify the file length truncate ftruncate

Other operations 7.3.2 files

1 dup and dup2 copy the file descriptor

2 stat、fstat、lstat 

  stat: by pathname to access files, fstat access files through the file descriptor

  When accessing a stat symbolic link file to track the end of the connection. lstat function returns only information the link itself

3 fsync all data will be stored in the buffer to be written to the file descriptor fd refresh file to be written

4 flock lock or unlock

5 fcntl view or set of files some information

6 select effective means of dealing with a plurality of file descriptors


Operation 7.4 Special files

7.4.1 Operation catalog file

Creating a directory file deletion mkdir rmdir

2 file opening and closing opendir closedir

Read readdir 3 directory file system calls to read a file directory

 

7.4.2 Operation of linked files

1 hard link operation

  Create a link link (only root can create a link to the new file directory file)

  Remove link unlink (inode link the counter is decremented)

2 symbolic links

  Create symlink

  Open and read the name: readlink

 

Operation 7.4.3 Pipeline file

  pipe usually used in conjunction with fork \ dup2 \ execve and other functions used in conjunction with other programs to create a pipeline to be redirected IO's

 

7.4.4 Device File

  /dev

 

 

Reproduced in: https: //my.oschina.net/u/204616/blog/544983

Guess you like

Origin blog.csdn.net/weixin_34301132/article/details/91989266