Home | History | Annotate | Download | only in misc

Lines Matching refs:fs

154 static void remove_journal_device(ext2_filsys fs)
168 uuid_unparse(fs->super->s_journal_uuid, buf);
173 ext2fs_find_block_device(fs->super->s_journal_dev);
187 fs->blocksize, io_ptr, &jfs);
216 if (memcmp(fs->super->s_uuid,
245 fs->super->s_journal_dev = 0;
246 uuid_clear(fs->super->s_journal_uuid);
247 ext2fs_mark_super_dirty(fs);
253 static int release_blocks_proc(ext2_filsys fs, blk_t *blocknr,
261 ext2fs_unmark_block_bitmap(fs->block_map, block);
262 group = ext2fs_group_of_blk(fs, block);
263 fs->group_desc[group].bg_free_blocks_count++;
264 ext2fs_group_desc_csum_set(fs, group);
265 fs->super->s_free_blocks_count++;
272 static void remove_journal_inode(ext2_filsys fs)
276 ino_t ino = fs->super->s_journal_inum;
278 retval = ext2fs_read_inode(fs, ino, &inode);
285 retval = ext2fs_read_bitmaps(fs);
291 retval = ext2fs_block_iterate(fs, ino,
300 ext2fs_mark_bb_dirty(fs);
301 fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
304 retval = ext2fs_write_inode(fs, ino, &inode);
310 fs->super->s_journal_inum = 0;
311 ext2fs_mark_super_dirty(fs);
317 static void update_mntopts(ext2_filsys fs, char *mntopts)
319 struct ext2_super_block *sb = fs->super;
326 ext2fs_mark_super_dirty(fs);
332 static void update_feature_set(ext2_filsys fs, char *features)
334 struct ext2_super_block *sb = fs->super;
387 remove_journal_inode(fs);
390 remove_journal_device(fs);
413 if (ext2fs_check_desc(fs)) {
436 ext2fs_update_dynamic_rev(fs);
459 ext2fs_mark_super_dirty(fs);
465 static void add_journal(ext2_filsys fs)
472 if (fs->super->s_feature_compat &
489 fs->blocksize, io_ptr, &jfs);
500 retval = ext2fs_add_journal_device(fs, jfs);
512 journal_blocks = figure_journal_size(journal_size, fs);
514 retval = ext2fs_add_journal_inode(fs, journal_blocks,
528 fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
530 print_check_message(fs);
862 static void parse_extended_opts(ext2_filsys fs, const char *opts)
889 fs->super->s_flags |= EXT2_FLAGS_TEST_FILESYS;
891 ext2fs_mark_super_dirty(fs);
893 fs->super->s_flags &= ~EXT2_FLAGS_TEST_FILESYS;
895 ext2fs_mark_super_dirty(fs);
939 fs->super->s_def_hash_version = hash_alg;
943 ext2fs_mark_super_dirty(fs);
968 static int get_move_bitmaps(ext2_filsys fs, int new_ino_blks_per_grp,
977 retval = ext2fs_read_bb_inode(fs, &bb_list);
981 for (i = 0; i < fs->group_desc_count; i++) {
982 start_blk = fs->group_desc[i].bg_inode_table +
983 fs->inode_blocks_per_group;
985 end_blk = fs->group_desc[i].bg_inode_table +
989 if (ext2fs_test_block_bitmap(fs->block_map, j)) {
1004 ext2fs_mark_block_bitmap(fs->block_map, j);
1011 if (needed_blocks > fs->super->s_free_blocks_count)
1017 static int ext2fs_is_meta_block(ext2_filsys fs, blk_t blk)
1020 group = ext2fs_group_of_blk(fs, blk);
1021 if (fs->group_desc[group].bg_block_bitmap == blk)
1023 if (fs->group_desc[group].bg_inode_bitmap == blk)
1028 static int ext2fs_is_block_in_group(ext2_filsys fs, dgrp_t group, blk_t blk)
1031 start_blk = fs->super->s_first_data_block +
1032 EXT2_BLOCKS_PER_GROUP(fs->super) * group;
1037 end_blk = start_blk + EXT2_BLOCKS_PER_GROUP(fs->super);
1043 static int move_block(ext2_filsys fs, ext2fs_block_bitmap bmap)
1053 retval = ext2fs_get_mem(fs->blocksize, &buf);
1057 for (new_blk = blk = fs->super->s_first_data_block;
1058 blk < fs->super->s_blocks_count; blk++) {
1062 if (ext2fs_is_meta_block(fs, blk)) {
1064 * If the block is mapping a fs meta data block
1067 * the respective fs metadata pointers. Otherwise
1070 group = ext2fs_group_of_blk(fs, blk);
1071 goal = ext2fs_group_first_block(fs, group);
1077 retval = ext2fs_new_block(fs, goal, NULL, &new_blk);
1081 /* new fs meta data block should be in the same group */
1082 if (meta_data && !ext2fs_is_block_in_group(fs, group, new_blk)) {
1088 ext2fs_mark_block_bitmap(fs->block_map, new_blk);
1100 retval = io_channel_read_blk(fs->io, blk, 1, buf);
1104 retval = io_channel_write_blk(fs->io, new_blk, 1, buf);
1128 static int process_block(ext2_filsys fs EXT2FS_ATTR((unused)),
1153 static int inode_scan_and_fix(ext2_filsys fs, ext2fs_block_bitmap bmap)
1162 retval = ext2fs_get_mem(fs->blocksize * 3, &block_buf);
1166 retval = ext2fs_open_inode_scan(fs, 0, &scan);
1200 retval = ext2fs_write_inode(fs, ino, &inode);
1208 retval = ext2fs_block_iterate2(fs, ino, 0, block_buf,
1226 static int group_desc_scan_and_fix(ext2_filsys fs, ext2fs_block_bitmap bmap)
1231 for (i = 0; i < fs->group_desc_count; i++) {
1232 blk = fs->group_desc[i].bg_block_bitmap;
1237 fs->group_desc[i].bg_block_bitmap = new_blk;
1240 blk = fs->group_desc[i].bg_inode_bitmap;
1245 fs->group_desc[i].bg_inode_bitmap = new_blk;
1251 static int expand_inode_table(ext2_filsys fs, unsigned long new_ino_size)
1263 old_itable_size = fs->inode_blocks_per_group * fs->blocksize;
1264 old_ino_size = EXT2_INODE_SIZE(fs->super);
1267 EXT2_INODES_PER_GROUP(fs->super) *
1269 fs->blocksize);
1271 new_itable_size = new_ino_blks_per_grp * fs->blocksize;
1284 for (i = 0; i < fs->group_desc_count; i++) {
1285 blk = fs->group_desc[i].bg_inode_table;
1286 retval = io_channel_read_blk(fs->io, blk,
1287 fs->inode_blocks_per_group, old_itable);
1291 for (j = 0; j < EXT2_INODES_PER_GROUP(fs->super); j++) {
1305 retval = io_channel_write_blk(fs->io, blk,
1312 fs->inode_blocks_per_group = new_ino_blks_per_grp;
1313 fs->super->s_inode_size = new_ino_size;
1325 static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
1337 for (blk = fs->super->s_first_data_block;
1338 blk < fs->super->s_blocks_count; blk++) {
1339 if (!ext2fs_fast_test_block_bitmap(fs->block_map, blk)) {
1344 if ((count == fs->super->s_blocks_per_group) ||
1345 (blk == fs->super->s_blocks_count-1)) {
1346 fs->group_desc[group++].bg_free_blocks_count =
1352 fs->super->s_free_blocks_count = total_free;
1363 for (ino = 1; ino <= fs->super->s_inodes_count && ino > 0; ino++) {
1364 if (!ext2fs_fast_test_inode_bitmap(fs->inode_map, ino)) {
1369 if ((count == fs->super->s_inodes_per_group) ||
1370 (ino == fs->super->s_inodes_count)) {
1371 fs->group_desc[group++].bg_free_inodes_count =
1377 fs->super->s_free_inodes_count = total_free;
1378 ext2fs_mark_super_dirty(fs);
1399 static int resize_inode(ext2_filsys fs, unsigned long new_size)
1405 ext2fs_read_inode_bitmap(fs);
1406 ext2fs_read_block_bitmap(fs);
1411 EXT2_INODES_PER_GROUP(fs->super)*
1413 fs->blocksize);
1419 fs->super->s_state &= ~EXT2_VALID_FS;
1421 retval = ext2fs_allocate_block_bitmap(fs, _("blocks to be moved"),
1428 retval = get_move_bitmaps(fs, new_ino_blks_per_grp, bmap);
1433 retval = move_block(fs, bmap);
1439 retval = inode_scan_and_fix(fs, bmap);
1443 retval = group_desc_scan_and_fix(fs, bmap);
1447 retval = expand_inode_table(fs, new_size);
1451 ext2fs_calculate_summary_stats(fs);
1453 fs->super->s_state |= EXT2_VALID_FS;
1455 ext2fs_mark_super_dirty(fs);
1456 ext2fs_mark_bb_dirty(fs);
1537 ext2_filsys fs;
1570 0, 0, io_ptr, &fs);
1586 if (new_inode_size == EXT2_INODE_SIZE(fs->super)) {
1591 if (new_inode_size < EXT2_INODE_SIZE(fs->super)) {
1606 ext2fs_close(fs);
1611 sb = fs->super;
1612 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
1630 fs->flags |= EXT2_FLAG_SUPER_ONLY;
1634 ext2fs_mark_super_dirty(fs);
1640 ext2fs_mark_super_dirty(fs);
1645 ext2fs_mark_super_dirty(fs);
1650 ext2fs_mark_super_dirty(fs);
1655 ext2fs_mark_super_dirty(fs);
1662 ext2fs_mark_super_dirty(fs);
1675 ext2fs_mark_super_dirty(fs);
1688 ext2fs_mark_super_dirty(fs);
1700 ext2fs_mark_super_dirty(fs);
1706 ext2fs_mark_super_dirty(fs);
1716 ext2fs_mark_super_dirty(fs);
1722 ext2fs_mark_super_dirty(fs);
1725 update_mntopts(fs, mntopts_cmd);
1727 update_feature_set(fs, features_cmd);
1729 parse_extended_opts(fs, extended_cmd);
1731 add_journal(fs);
1744 for (i = 0; i < fs->group_desc_count; i++)
1745 if (!ext2fs_group_desc_csum_verify(fs, i))
1747 if (i >= fs->group_desc_count)
1762 for (i = 0; i < fs->group_desc_count; i++)
1763 ext2fs_group_desc_csum_set(fs, i);
1764 fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
1766 ext2fs_mark_super_dirty(fs);
1775 if (fs->super->s_feature_incompat &
1787 fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
1788 if (resize_inode(fs, new_inode_size) == 0) {
1798 ext2fs_mark_super_dirty(fs);
1803 ext2fs_mark_super_dirty(fs);
1808 return (ext2fs_close(fs) ? 1 : 0);