tailieunhanh - unix filesystems evolution design and implementation phần 7

Lĩnh vực này quy định các loại tập tin mà gnode thuộc, chẳng hạn như một tập tin thường xuyên, thư mục, và như vậy. g_seg. ID phân khúc này được sử dụng để tham khảo các phân đoạn tập tin có chứa các trang lưu trữ cho tập tin đó. g_vnode. Điều này các tài liệu tham khảo lĩnh vực vnode cho tập tin này. g_filocks. | 256 UNIX Filesystems Evolution Design and Implementation The following example shows the linkage between two device special files and the common specfs vnode that represents both. This is also shown in Figure . First of all consider the following simple program which simply opens a file and pauses awaiting a signal include main int argc char argv int fd fd open argv 1 O_RDONLY pause As shown below a new special file is created with the same major and minor number as dev null ls -l dev null crw-r--r-- 1 root other 13 2 May 30 09 17 mynull mknod mynull c 13 2 ls -l mynull crw-r--r-- 1 root other 13 2 May 30 09 17 mynull and the program is run as follows . dopen dev null 1 3715 . dopen mynull 2 3719 Using crash it is possible to trace through the list of file related structures starting out at the file descriptor for each process to see which underlying vnodes they actually reference. First the process table slots are located where the two processes reside crash dumpfile dev mem namelist dev ksyms outfile stdout p grep dopen 336 s 3719 3713 3719 3713 0 46 dopen load 363 s 3715 3713 3715 3713 0 46 dopen load Starting with the process that is accessing the mynull special file the user area is displayed to locate the open files user 336 . OPEN FILES POFILE FLAGS AND THREAD REFCNT 0 F 300106fc690 0 0 1 F 300106fc690 0 0 2 F 300106fc690 0 0 3 F 300106fca10 0 0 Pseudo Filesystems 257 struct snode Figure Accessing devices from different device special files. The file structure and its corresponding vnode are then displayed as shown file 300106fca10 ADDRESS RCNT TYPE ADDR OFFSET FLAGS 300106fca10 1 SPEC 300180a1bd0 0 read vnode 300180a1bd0 VCNT VFSMNTED VFSP STREAMP VTYPE RDEV VDATA VFILOCKS VFLAG 1 0 300222d8578 0 c 13 2 300180a1bc8 0 - snode 300180a1bc8 SNODE TABLE SIZE 256 HASH-SLOT MAJ MIN REALVP COMMONVP NEXTR SIZE COUNT FLAGS - 13 2 3001bdcdf50 30001b5d5b0 0 0 0 The REALVP field references the vnode for the special file within the filesystem that .