Contains the format of a Journaled File System (JFS) logical volume.
#include <sys/filsys.h>
The filsys.h file contains the format of a JFS file system. A JFS file system has a common format for vital information and is divided into a number of fixed-sized units, or fragments. Fragments serve as the basic unit of file system disk space allocation and can be smaller than the file system logical block size, which is 4096 bytes. The file system superblock records the logical block size and fragment size, as well as the size of the entire file system.
A unique feature of the JFS is the implementation of file system metadata as unnamed files that reside in that file system. For example, the disk i-nodes for any file system are contained in the blocks fragments allocated to the file described by the INODES_I i-node. The i-node number for the boot file is 0. Each of the following reserved i-nodes corresponds to a file system metadata file:
Item | Description |
---|---|
SUPER_I | Superblock file |
INODES_I | Disk i-nodes |
INDIR_I | Indirect file blocks, double and single |
INOMAP_I | i-node allocation bit map |
ROOTDIR_I | Root directory i-node |
DISKMAP_I | Block Fragment allocation bit map |
INODEX_I | i-node extensions |
INODEXMAP_I | Allocation map for i-node extensions |
The first 4096 bytes of the file system are unused and available to contain a bootstrap program or other information. The second 4096 bytes of the file system are used to hold the file system superblock. The structure of a JFS superblock follows:
/* 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
The path name of this file is /usr/include/jfs/filsys.h. But, if the /usr/include/sys/filsys.h file is included, the /usr/include/jfs/filsys.h file is included by default.
The fields of the superblock structure have the following functions:
Item | Description |
---|---|
s_fname | Specifies the name of the file system. |
s_fpack | Specifies the name of the volume on which the file system resides. |
s_fsize | Specifies the entire file system size in 512-byte units. |
s_bsize | Specifies the file-system logical block size in bytes. |
s_fragsize | Specifies the file system fragment size and is only valid for fsv3p file systems. For fsv3 file systems, the file-system fragment size is logically defined as the file-system logical block size. |
s_agsize | Specifies the number of fragments per file system allocation group. For fsv3 file systems, this field also specifies the number of disk i-nodes per file system allocation group. |
s_iagsize | Specifies the number of disk i-nodes per file system allocation group for fsv3p file systems. The s_iagsize field is only valid for fsv3p file systems. |
s_magic | Specifies the file-system magic number and is used
to validate
file systems. The magic number is encoded as a 4-byte character
string to make it possible to validate the superblock without knowing
the byte order of the remaining fields. To check for a valid fsv3
superblock, use a condition similar to:
For fsv3p file systems, superblock validation is made by checking both the s_magic and s_version fields. |
s_version | Specifies
the file-system version number and is only valid
for fsv3p file systems. To check for a valid fsv3p superblock, use
a condition similar to:
|
s_logdev | Specifies the device ID of the file system log device. |
s_logserial | Records the serial number of the log device at the time the file system was last mounted as modifiable. |
s_fmod | Contains a flag to indicate the cleanliness
of the file system.
Whenever a file system is mounted, this flag is checked and a warning
message is printed if the s_fmod field is equal to nonzero.
A file system whose s_fmod field is equal to 0 is very likely
to be clean, and a file system whose s_fmod field is equal
to 2 is likely to have problems. The s_fmod field is intended
to be a three-state flag with the third state being a sticky state.
The three states are:
If you only mount and unmount the file system, the flag toggles back and forth between states 0 and 1. If you mount the file system while the flag is in state 1, the flag goes to state 2 and stays there until you run the fsck command. The only way to clean up a corrupted file system (change the flag from state 2 back to state 0) is to run the fsck command. |
s_ronly | Contains a flag indicating that the file system is mounted read-only. This flag is maintained in memory only; its value on disk is not valid. |
s_time | Specifies the last time the superblock of the file system was changed (in seconds since 00:00 Jan. 1, 1970 (GMT)). |