filsys.h ファイル

目的

ジャーナル・ファイルシステム (JFS) 論理ボリュームのフォーマットが入っています。

構文

#include <sys/filsys.h>

説明

filsys.h ファイルには、JFS ファイルシステムのフォーマットが含まれています。 JFS ファイルシステムは、重要な情報のための共通のフォーマットを持ち、いくつかの固定サイズの単位、すなわちフラグメントに分割されます。 フラグメントは、ファイルシステムのディスク・スペース割り振りの基本単位として機能し、ファイルシステムの論理ブロック・サイズ (4096 バイト) より小さくすることができます。 ファイルシステム・スーパーブロックは、論理ブロック・サイズとフラグメント・サイズ、およびファイルシステム全体のサイズを記録します。

JFS の固有の機能は、ファイル・システム・メタデータを、そのファイル・システムに常駐する名前なしファイルとして実装することです。 例えば、ファイルシステムのディスク i ノードは、 INODES_I (ノード) i ノードによって記述されるファイルに割り振られるブロック・フラグメントに含まれます。 ブート・ファイルの i ノード番号は 0 です。 以下の予約済み i ノードは、それぞれファイル・システム・メタデータ・ファイルに対応しています。

項目 説明
SUPER_I (スーパー 1) スーパーブロック・ファイル
INODES_I (ノード) ディスク i ノード
INDIR_I (I の場合) 間接ファイル・ブロック、二重および単一
イOMAP_I (I) i ノード割り振りビットマップ
ルート・ディレクトリー ルート・ディレクトリー i ノード
ディスク・マAP_I ブロック・フラグメント割り当てビットマップ
INODEX_I (I) i ノード拡張
INODEXMAP_I (ノード名) i ノード拡張の割り振りマップ

ファイル・システムの最初の 4096 バイトは使用されず、ブートストラップ・プログラムまたはその他の情報を入れることができます。 ファイル・システムの 2 番目の 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 ファイル・システムの場合、このフィールドは、ファイル・システム割り振りグループごとのディスク i ノードの数も指定します。
s_iagsize fsv3p ファイルシステムのファイルシステム割り当てグループごとのディスク i ノードの数を指定します。 このs_iagsizeフィールドが有効なのは、 fsv3p ファイル・システムの場合のみです。
s_magic ファイル・システムのマジック・ナンバーを指定し、ファイル・システムの妥当性検査に使用されます。 マジックナンバー は、4 バイトの文字ストリングとしてエンコードされます。これにより、残りのフィールドのバイト・オーダーを知らなくても、スーパーブロックを検証することができます。 有効な fsv3 スーパーブロックを検査するには、次のような条件を使用します。
if (strncmp(sp->s_magic,fsv3magic,4) == 0)

fsv3p ファイル・システムの場合、スーパーブロック妥当性検査は、以下の両方を検査することによって行われます。s_magicおよびs_versionフィールド

s_version ファイル・システムのバージョン番号を指定します。これは、 fsv3p ファイル・システムの場合にのみ有効です。 有効な fsv3p スーパーブロックを検査するには、次のような条件を使用します。
if (strncmp(sp->s_magic,fsv3pmagic,4) == 0 &&
    sp->s_version == fsv3pvers)
s_logdev ファイルシステム・ログ・デバイスのデバイス ID を指定します。
s_logserial ファイル・システムが最後にマウントされたときのログ装置のシリアル番号を変更可能として記録します。
s_fmod ファイルシステムの清浄度を示すフラグが入っています。 ファイルシステムがマウントされるたびに、このフラグが検査され、以下の場合は警告メッセージが出力されます。s_fmodフィールドがゼロ以外です。 ファイル・システムs_fmodフィールドが 0 であるということは、クリーンである可能性が高いと考えられます。s_fmod2 に等しいフィールドに問題がある可能性があります。 このs_fmodフィールドは、3 番目の状態がスティッキー状態である 3 つの状態フラグになるように意図されています。 3 つの状態は次のとおりです。
  • 0 = ファイル・システムはクリーンで、アンマウントされています。
  • 1 = ファイル・システムはクリーンでマウントされています。
  • 2 = ファイル・システムはダーティーにマウントされました。

ファイル・システムをマウントおよびアンマウントするだけの場合、フラグは状態 0 と 1 の間を切り替えます。 フラグが状態 1 のときにファイルシステムをマウントすると、フラグは状態 2 になり、 FSCK コマンドを実行するまでそこにとどまります。 破損したファイルシステムをクリーンアップする (フラグを状態 2 から状態 0 に戻す) 唯一の方法は、 FSCK コマンドを実行することです。

s_ronly ファイルシステムが読み取り専用でマウントされていることを示すフラグが入っています。 このフラグはメモリー内でのみ維持されます。ディスク上の値は無効です。
s_time ファイル・システムのスーパーブロックが最後に変更された時刻 (1970 年 1 月 1 日 00:00 (GMT) 以降の秒数) を指定します。