tarfs について (3)
きちんと理解した上で読んでいないので、gdgd です。とりあえず
static DECLARE_FSTYPE_DEV(tar_fs_type, "tarfs", tarfs_read_super);
は
static struct file_system_type tar_fs_type = { .owner = THIS_MODULE, .name = "tarfs", .get_sb = tarfs_read_super, .kill_sb = kill_litter_super, };
みたいなカンジで良さげ。kill_litter_super は fs/super.c にて定義されてます。デフォルトはこれね、みたいな理解なんですが良いのだろうか。
で
ファイルシステムが mount される時に上記の tarfs_read_super がナニ。
Linux カーネル 2.4 の設計と実装では
- デバイスのブロックサイズを set_blocksize() で 512 bytes に設定
- 引数で渡された struct super_block オブジェクトの属性の設定
- tarfs 独自データの登録
- tarfs_sops の登録 (s_op 属性)
- ルート i-node に対応する dcache エントリの登録 (s_root 属性)
とある。細かく言えば他にもヤッてはいるのですが、微妙なのが 3 番目の処理。まず、領域を確保しているのが以下なんですが
/* Alloc tarfs dependent data */ TARSB(sb) = kmalloc(sizeof(struct tarfs_sb_info), GFP_KERNEL);
ええと、TARSB というマクロがナニ。これは tarfs.h にて定義されています。
#define TARSB(sb) ((struct tarfs_sb_info*)((sb)->u.generic_sbp))
struct tarfs_sb_info は直上にて定義されてて
/* Additional information for tarfs superblock */ struct tarfs_sb_info { /* 1 if already have archive information */ int parsed; /* Root tarent */ struct tarent *root_tarent; /* Hash table */ struct tarent **ihash; /* Information for statfs */ unsigned long s_files; unsigned long s_blocks; /* Max inode assigned */ unsigned long s_maxino; };
との事。ちなみに struct super_block 構造体の定義には u などというメンバは無い。Linux カーネル 2.4 の設計と実装、によれば
Linux のスーパーブロックは、全ファイルシステムに共通な構造の後ろに、各ファイルシステムの独自データが [union u] として埋めこまれています
とある。むむ。どこを探しても無いんだけどなぁ、そんな属性。
とりあえず
色々掘り返してみたいと思います。何かあればエントリ投入予定とゆー事で。