VFS-目录项对象(dentry)
dentry 结构代表的是逻辑意义上的文件,描述的是文件逻辑上的属性,目录项对象在磁盘上并没有对应的映像
inode 结构代表的是物理意义上的文件,记录的是物理上的属性 对于一个具体的文件,系统 其 inode 结构在磁盘上就有对应的映像
VFS-文件对象(file)
By convention, UNIX System shells associate file descriptor 0 with the standard
input of a process, file descriptor 1 with the standard output, and file descriptor 2 with
the standard error. This convention is used by the shells and many applications; it is
not a feature of the UNIX kernel. Nevertheless, many applications would break if these
associations weren’t followed.
Although their values are standardized by POSIX.1, the magic numbers 0, 1, and 2
should be replaced in POSIX-compliant applications with the symbolic constants
STDIN_FILENO, STDOUT_FILENO, and STDERR_FILENO to improve readability.
These constants are defined in the <unistd.h> header.
File descriptors range from 0 through OPEN_MAX−1. (Recall Figure 2.11.) Early
historical implementations of the UNIX System had an upper limit of 19, allowing a
maximum of 20 open files per process, but many systems subsequently increased this
limit to 63.
超级块是对一个文件系统的描述
查看超级块的命令:DUMPE2FS (dumpe2fs - dump ext2/ext3/ext4 filesystem information)
DUMPE2FS(8) System Manager‘s Manual DUMPE2FS(8) NAME dumpe2fs - dump ext2/ext3/ext4 filesystem information SYNOPSIS dumpe2fs [ -bfghixV ] [ -o superblock=superblock ] [ -o blocksize=blocksize ] device DESCRIPTION dumpe2fs prints the super block and blocks group information for the filesystem present on device. Note: When used with a mounted filesystem, the printed information may be old or inconsis‐ tent. OPTIONS -b print the blocks which are reserved as bad in the filesystem. -o superblock=superblock use the block superblock when examining the filesystem. This option is not usually needed except by a filesystem wizard who is examining the remains of a very badly corrupted filesystem. -o blocksize=blocksize use blocks of blocksize bytes when examining the filesystem. This option is not usu‐ ally needed except by a filesystem wizard who is examining the remains of a very badly corrupted filesystem. ##################################################################################################
至于DUMPE2FS(8), 8是什么意思呢?
The table below shows the section numbers of the manual followed by the types of pages they contain. 1 Executable programs or shell commands 2 System calls (functions provided by the kernel) 3 Library calls (functions within program libraries) 4 Special files (usually found in /dev) 5 File formats and conventions eg /etc/passwd 6 Games 7 Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7) 8 System administration commands (usually only for root)(系统管理命令) 9 Kernel routines [Non standard]
~$ df -Th # 只可以查看已经挂载的分区和文件系统类型。 Filesystem Type Size Used Avail Use% Mounted on udev devtmpfs 888M 0 888M 0% /dev tmpfs tmpfs 184M 6.0M 178M 4% /run /dev/vda1 ext4 50G 4.5G 43G 10% / tmpfs tmpfs 917M 24K 917M 1% /dev/shm tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs tmpfs 917M 0 917M 0% /sys/fs/cgroup tmpfs tmpfs 184M 0 184M 0% /run/user/500
#dumpe2fs /dev/loop0 【-h不打印Group信息】 dumpe2fs 1.42.9 (网上示例仅供参照) Filesystem volume name: <none> Last mounted on: <not available> 最后挂载目录 Filesystem UUID: cef5f647-058f-49bd-88c6-baf3ce2338a0 Filesystem magic number: 0xEF53 ext4文件系统标志 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize Filesystem flags: signed_directory_hash Default mount options: user_xattr acl Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 25688 文件系统inode号总数,由系统决定但可以指定比例 Block count: 102400 文件系统block总数,==容量/默认的1KB Reserved block count: 5120 保留的block总数,默认比例为5% Free blocks: 93504 空闲的block总数, Free inodes: 25677 空闲的inode总数 First block: 1 第一个block号 Block size: 1024 block大小 Fragment size: 1024 Group descriptor size: 64 块组描述大小 Reserved GDT blocks: 256 预留块组描述block数量 Blocks per group: 8192 块组中block数量 Fragments per group: 8192 Inodes per group: 1976 块组中inode数量==25688/13 Inode blocks per group: 247 块组中inode占用block总数 Flex block group size: 16 inode表大小? Filesystem created: Tue Nov 27 13:26:27 2018 Last mount time: Tue Nov 27 13:28:39 2018 Last write time: Tue Nov 27 13:28:39 2018 Mount count: 1 挂载次数 Maximum mount count: -1 Last checked: Tue Nov 27 13:26:27 2018 Check interval: 0 (<none>) Lifetime writes: 4447 kB Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) First inode: 11 文件系统的第一个inode号 Inode size: 128 inode大小 Journal inode: 8 日志文件inode号 Default directory hash: half_md4 Directory Hash Seed: 45d2f9d4-714a-4ccf-9c9d-308d12552317 Journal backup: inode blocks Journal features: journal_64bit 日志大小: 4096k Journal length: 4096 Journal sequence: 0x00000002 Journal start: 1 Group 0: (Blocks 1-8192) [ITABLE_ZEROED] Checksum 0x0229, unused inodes 1965 主 superblock at 1, Group descriptors at 2-2 保留的GDT块位于 3-258 Block bitmap at 259 (+258), Inode bitmap at 275 (+274) Inode表位于 291-537 (+290) 4683 free blocks, 1965 free inodes, 2 directories, 1965个未使用的inodes 可用块数: 3510-8192 可用inode数: 12-1976
索引节点(Inode)查看命令: stat <file>
一个进程所处的位置是由 fs_struct 来描述的,而一个进程 或用户 打开的文件是由
files_struct 来描述的,而整个系统所打开的文件是由 file 结构来描述
文件系统的注册和注销
文件系统的安装
自己( 一般是超级用户 )安装文件系统时 需要指定三种信息:文件系统的名称 、 包含
文件系统的物理块设备 、 文件系统在已有文件系统中的安装点 。
mount -t iso9660 /dev/hdc /mnt/cdrom 其中 iso9660 是光驱文件系统的名称,
/dev/hdc 是包含文件系统的物理块设备 ,/mnt/cdrom 就是将要安装到的目录,即安装点 。
在用户程序中要安装一个文件系统则可以调用 mount 系统调用 。 安装过程主要工作
是创建安装点对象,将其挂接到根文件系统的指定安装点下,然后初始化超级块对象,从而
获得文件系统基本信息和相关的操作 。
文件系统的安装
否则,查看对应的 VFS 超级块,如果该文件系统的 VFS 超级块标志为 脏,则必须
将超级块信息写回磁盘
之后,对应的 VFS 超级块被释放,vfsmount 数据结构将从 vfsmntlist 链表中断开并
被释放
原文:https://www.cnblogs.com/51try-again/p/11028871.html