7 struct tfs_sb_info
* tfs_mount(void)
9 struct tfs_sb_info
*sbi
;
10 struct tfs_super_block sb
;
13 if (read_sector(1, &sb
, 1) == -1) {
14 printf("Read the tfs super block error!\n");
17 if (sb
.s_magic
!= TFS_MAGIC
) {
18 printf("Trying to mount not tfs file system!\n");
22 sbi
= malloc(sizeof(*sbi
));
24 printf("Malloc from tfs sbi object failed!\n");
28 sbi
->s_block_shift
= sb
.s_block_shift
;
29 sbi
->s_block_size
= 1 << sbi
->s_block_shift
;
30 sbi
->s_blocks_count
= sb
.s_blocks_count
;
31 sbi
->s_inodes_count
= sb
.s_inodes_count
;
32 sbi
->s_free_blocks_count
= sb
.s_free_blocks_count
;
33 sbi
->s_free_inodes_count
= sb
.s_free_inodes_count
;
36 sbi
->s_inode_bitmap
= sb
.s_inode_bitmap
;
37 sbi
->s_block_bitmap
= sb
.s_block_bitmap
;
38 sbi
->s_inode_table
= sb
.s_inode_table
;
39 sbi
->s_data_area
= sb
.s_data_area
;
41 sbi
->s_inode_bitmap_count
= sb
.s_block_bitmap
- sb
.s_inode_bitmap
;
42 sbi
->s_block_bitmap_count
= sb
.s_inode_table
- sb
.s_block_bitmap
;
43 sbi
->s_inode_table_count
= sb
.s_data_area
- sb
.s_inode_table
;
46 sbi
->s_offset
= sb
.s_offset
;
48 sbi
->s_inodes_per_block
= sbi
->s_block_size
/ sizeof(struct tfs_inode
);
58 struct tfs_sb_info
* tfs_mount_by_fsname(const char *fs
)