Development Diary -20,190,902 keyword study notes "Unix-level programming environment (Second Edition)" DAY 7

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_31433709/article/details/100368680

Reading directory

Single user has permission to access a directory can read the directory, but only the kernel to the directory (prevent file system panics). Bits and write permissions to perform a directory permission bits determines in that directory You are able to create new files and delete files, does not mean they can write the directory itself.

The actual format of the directory of the UNIX implementation-dependent early systems, V7, for example, have a relatively simple structure: 16 bytes of each directory entry, wherein the file name is 14 bytes, two bytes are the i node number number. for 4.2BSD, since it allows for quite a long file name, so the length of each directory entry is variable, which means read the directory of program and system-related. in order to simplify this situation , UNIX now includes a directory with read-related routines, they are part of POSIX.1.

We will write a program using these directory file hierarchy traversal, which object is to obtain the number of types of files as shown in Table 4-2. 4-7 programs only one parameter, which illustrates the starting point of the path name, from the point start descending traverse the file hierarchy. V system provides a practical traverse this hierarchy function ftw (3), for each file he calls a user-defined function.

Die, last night, slept more than four hours, nothing is worth life to achieve the catch! Today first dismissed!

Guess you like

Origin blog.csdn.net/qq_31433709/article/details/100368680