filsys.h 文件
用途
包含 "日志文件系统" (JFS) 逻辑卷的格式。
语法
#include < sys/filsys.h >
描述
filsys.h 文件包含 JFS 文件系统的格式。 JFS 文件系统具有用于重要信息的公共格式,并且被划分为多个固定大小的单元或片段。 片段用作文件系统磁盘空间分配的基本单元,并且可以小于文件系统逻辑块大小 (即 4096 字节)。 文件系统超块记录了逻辑块大小和片段大小,以及整个文件系统的大小。
JFS 的一个独特功能是将文件系统元数据实现为驻留在该文件系统中的未命名文件。 例如,任何文件系统的磁盘索引节点都包含在分配给 INODES_I 索引节点所描述的文件的块段中。 该引导文件的索引节点号为 0。 以下每个保留的索引节点对应于一个文件系统元数据文件:
| 项 | 描述 |
|---|---|
| SUPER_I | 超块文件 |
| INODES_I | 磁盘索引节点 |
| INDIR_I | 间接文件块,双精度和单精度 |
| INOMAP_I | 索引节点分配位图 |
| ROOTDIR_I | 根目录索引节点 |
| 磁盘映射 _I | 块片段分配位映射 |
| INODEX_I | 索引节点扩展 |
| INODEXMAP_I | 索引节点扩展的分配映射 |
文件系统的前 4096 个字节是未使用的,并且可用于包含引导程序或其他信息。 文件系统的第二个 4096 字节用于保存文件系统超级块。 JFS 超块的结构如下所示:
/* The following disk-blocks are formatted or reserved:
*
* ipl block 0 - not changed by filesystem.
*
* superblocks at 1 x 4096 (primary superblock) and 31 x
* 4096 (secondary superblock). the secondary super-block
* location is likely to be on a different disk-surface than
* the primary super-block. both structures are allocated as
* fragments in ".superblock".
*
* fragments for .inodes according to BSD layout. each
* allocation group contains a fixed number of disk inodes.
* for fsv3 file systems, each allocation group contains one
* inode per 4096 byte fragment of the allocation group,
* with the number of fragments within each group described
* by the s_agsize field of the superblock. for fsv3p file
* systems, the number of inodes per group is described by
* the s_iagsize field of the superblock and may be less
* than or greater than the number of fragments per group.
* for these file systems, s_agsize describes the number of
* s_fragsize fragments contained within each allocation
* group.
*
* the first allocation group inodes starts at 32 x
* 4096 bytes and consumes consecutive fragments sufficient
* to hold the group's inodes. the inode fragments for all
* other allocation groups start in the first fragments of
* the allocation group and continue in consecutive
* fragments sufficient to hold the group's inodes.
*
* other fragments are allocated for .indirect, .diskmap,
* .inodemap, and their indirect blocks starting in the
* first allocation-group.
*
* The special fs inodes formatted and their usage is as follows:
*
* inode 0 - never allocated - reserved by setting
* n_link = 1
* inode 1 - inode for .superblock
* inode 2 - inode for root directory
* inode 3 - inode for .inodes
* inode 4 - inode for .indirect
* inode 5 - inode for .inodemap - allocation map for
* .inodes
* inode 6 - inode for .diskmap - disk allocation map
* inode 7 - inode for .inodex - inode extensions
* inode 8 - inode for .inodexmap - allocation map for
* .inodex
* inode 9 - 16 - reserved for future extensions
*
* except for the root directory, the special inodes are not in
* any directory.
*
*/ #define
IPL_B 0
#define SUPER_B 1
#define SUPER_B1 31
#define INODES_B 32
#define NON_B 0
#define SUPER_I 1
#define ROOTDIR_I 2
#define INODES_I 3
#define INDIR_I 4
#define INOMAP_I 5
#define DISKMAP_I 6
#define INODEX_I 7
#define INDOESMAP_I 8 /*
* super block format. primary superblock is located in the
* second 4096 bytes of the file system.
* the secondary super-block is not used except for disaster
* recovery.
*/
struct superblock
{
char s_magic[4]; /* magic number */
char s_flag[4]; /* flag word (see below) */
int s_agsize; /* fragments per allocation group */
int s_logserial; /* serial number of log when fs mounted */
daddr_t s_fsize; /* size (in 512 bytes) of entire fs */
short s_bsize; /* block size (in bytes) for this
system */
short s_spare; /* unused. */
char s_fname[6]; /* name of this file system */
char s_fpack[6]; /* name of this volume */
dev_t s_logdev; /* device address of log */
/* current file system state information, values change over
time */
char s_fmod; /* flag: set when file system is mounted */
char s_ronly; /*flag: file system is read only */
time_t s_time; /* time of last superblock update */
/* more persistent
information &
nbsp; &
nbsp;*/
int s_version; /* version
number
*/
int s_fragsize; /* fragment size in bytes (fsv3p only) */
int s_iagsize; /* disk inodes per alloc grp (fsv3p only) */
int s_compress; /* > 0 if data compression */
};
/* Version 4 fs magic number */
#define fsv4magic "\102\041\207\145"
/* Version 4p fs magic number */
#define fsv4pmagic "\145\207\041\102"
/* Version 4p version number */
#define fsv4pvers 1此文件的路径名为 /usr/include/jfs/filsys.h。 但是,如果包含 /usr/include/sys/filsys.h 文件,那么缺省情况下将包含 /usr/include/jfs/filsys.h 文件。
上一个块结构的字段具有以下功能:
| 项 | 描述 |
|---|---|
| s_fname | 指定该文件系统的名称。 |
| s_fpack | 指定文件系统驻留所在的卷的名称。 |
| s_fsize | 以 512 字节为单位指定整个文件系统大小。 |
| s_bsize | 指定文件系统逻辑块大小 (以字节为单位)。 |
| s_fragsize | 指定文件系统片段大小,并且仅对 fsv3p 文件系统有效。 对于 fsv3 文件系统,文件系统片段大小在逻辑上被定义为文件系统逻辑块大小。 |
| s_agsize | 指定每个文件系统分配组的片段数。 对于 fsv3 文件系统,此字段还指定每个文件系统分配组的磁盘索引节点数。 |
| s_iagsize | 指定 fsv3p 文件系统的每个文件系统分配组的磁盘索引节点数。 该s_iagsize字段仅对 fsv3p 文件系统有效。 |
| s_magic | 指定文件系统幻数,并用来验证文件系统。 幻数 编码为 4 个字节的字符串,以便在不知道剩余字段的字节顺序的情况下对超块进行验证。 要检查有效的 fsv3 超块,请使用类似于以下内容的条件:对于 fsv3p 文件系统,超级块验证是通过同时检查s_magic和s_version字段。 |
| s_version | 指定文件系统版本号,并仅对 fsv3p 文件系统有效。 要检查有效的 fsv3p 超块,请使用类似于以下内容的条件: |
| s_logdev | 指定文件系统作业记录设备的设备标识。 |
| s_logserial | 将上次安装文件系统时日志设备的序列号记录为可修改的。 |
| s_fmod | 包含用于指示文件系统的清洁度的标志。 只要安装了文件系统,就会检查此标志并显示警告消息,如果s_fmod字段为非零值。 具有以下内容的文件系统:s_fmod0 等于 0 ,很可能是干净的,并且文件系统s_fmod字段等于 2 很可能存在问题。 该s_fmod字段被设计为三状态标志,第三状态为粘滞状态。 这三种状态是:
如果您仅安装和卸装文件系统,那么该标志将 0 1 到 1 之间来回切换。 如果您在 1 处于状态 1 时安装文件系统,那么该标志将 2 状态 2 并停留在该状态,直到您运行 Fsck 命令为止。 清除已损坏的文件系统 (将 2 从状态 2 更改回状态 0) 0 唯一方法是运行 Fsck 命令。 |
| s_ronly | 包含一个标志,该标志指示文件系统已安装为只读。 此标志仅在内存中维护; 它在磁盘上的值无效。 |
| s_time | 指定上次更改文件系统的超级块的时间 (自 1970 年 1 月 1 日 00:00 (GMT) 以来的秒数)。 |