7 static void * tfs_read_inode_bitmap(struct tfs_sb_info
*sbi
)
9 char *buf
= malloc(sbi
->s_block_size
);
11 tfs_bread(sbi
, sbi
->s_inode_bitmap
, buf
);
17 * free an inode, return -1 if failed, or return 9
19 int tfs_free_inode(struct tfs_sb_info
*sbi
, int inr
)
21 char *bitmap
= tfs_read_inode_bitmap(sbi
);
23 /* inode number count from 1 */
24 if (clear_bit(bitmap
, inr
- 1) == 0) {
25 printk("ERROR: trying to free an unallocated inode!\n");
30 tfs_bwrite(sbi
, sbi
->s_inode_bitmap
, bitmap
);
35 int tfs_alloc_inode(struct tfs_sb_info
*sbi
, int inr
)
40 printk("ERROR: trying to alloc a negtive inode!\n");
44 bitmap
= tfs_read_inode_bitmap(sbi
);
45 /* try the target first */
46 if (test_bit(bitmap
, inr
- 1) != 0)
47 inr
= find_first_zero(bitmap
, bitmap
+ sbi
->s_block_size
) + 1;
49 set_bit(bitmap
, inr
- 1);
50 tfs_bwrite(sbi
, sbi
->s_inode_bitmap
, bitmap
);