Lines Matching refs:fs
154 static void remove_journal_device(ext2_filsys fs) in remove_journal_device() argument
168 uuid_unparse(fs->super->s_journal_uuid, buf); in remove_journal_device()
173 ext2fs_find_block_device(fs->super->s_journal_dev); in remove_journal_device()
187 fs->blocksize, io_ptr, &jfs); in remove_journal_device()
216 if (memcmp(fs->super->s_uuid, in remove_journal_device()
245 fs->super->s_journal_dev = 0; in remove_journal_device()
246 uuid_clear(fs->super->s_journal_uuid); in remove_journal_device()
247 ext2fs_mark_super_dirty(fs); in remove_journal_device()
253 static int release_blocks_proc(ext2_filsys fs, blk_t *blocknr, in release_blocks_proc() argument
261 ext2fs_unmark_block_bitmap(fs->block_map, block); in release_blocks_proc()
262 group = ext2fs_group_of_blk(fs, block); in release_blocks_proc()
263 fs->group_desc[group].bg_free_blocks_count++; in release_blocks_proc()
264 ext2fs_group_desc_csum_set(fs, group); in release_blocks_proc()
265 fs->super->s_free_blocks_count++; in release_blocks_proc()
272 static void remove_journal_inode(ext2_filsys fs) in remove_journal_inode() argument
276 ino_t ino = fs->super->s_journal_inum; in remove_journal_inode()
278 retval = ext2fs_read_inode(fs, ino, &inode); in remove_journal_inode()
285 retval = ext2fs_read_bitmaps(fs); in remove_journal_inode()
291 retval = ext2fs_block_iterate(fs, ino, in remove_journal_inode()
300 ext2fs_mark_bb_dirty(fs); in remove_journal_inode()
301 fs->flags &= ~EXT2_FLAG_SUPER_ONLY; in remove_journal_inode()
304 retval = ext2fs_write_inode(fs, ino, &inode); in remove_journal_inode()
310 fs->super->s_journal_inum = 0; in remove_journal_inode()
311 ext2fs_mark_super_dirty(fs); in remove_journal_inode()
317 static void update_mntopts(ext2_filsys fs, char *mntopts) in update_mntopts() argument
319 struct ext2_super_block *sb = fs->super; in update_mntopts()
326 ext2fs_mark_super_dirty(fs); in update_mntopts()
329 static void request_fsck_afterwards(ext2_filsys fs) in request_fsck_afterwards() argument
335 fs->super->s_state &= ~EXT2_VALID_FS; in request_fsck_afterwards()
344 static void update_feature_set(ext2_filsys fs, char *features) in update_feature_set() argument
346 struct ext2_super_block *sb = fs->super; in update_feature_set()
401 remove_journal_inode(fs); in update_feature_set()
404 remove_journal_device(fs); in update_feature_set()
427 if (ext2fs_check_desc(fs)) { in update_feature_set()
449 gd = fs->group_desc; in update_feature_set()
450 for (i = 0; i < fs->group_desc_count; i++, gd++) { in update_feature_set()
453 ext2fs_group_desc_csum_set(fs, i); in update_feature_set()
455 fs->flags &= ~EXT2_FLAG_SUPER_ONLY; in update_feature_set()
460 gd = fs->group_desc; in update_feature_set()
461 for (i = 0; i < fs->group_desc_count; i++, gd++) { in update_feature_set()
467 request_fsck_afterwards(fs); in update_feature_set()
474 fs->flags &= ~EXT2_FLAG_SUPER_ONLY; in update_feature_set()
480 ext2fs_update_dynamic_rev(fs); in update_feature_set()
492 request_fsck_afterwards(fs); in update_feature_set()
497 ext2fs_mark_super_dirty(fs); in update_feature_set()
503 static void add_journal(ext2_filsys fs) in add_journal() argument
510 if (fs->super->s_feature_compat & in add_journal()
527 fs->blocksize, io_ptr, &jfs); in add_journal()
538 retval = ext2fs_add_journal_device(fs, jfs); in add_journal()
550 journal_blocks = figure_journal_size(journal_size, fs); in add_journal()
552 retval = ext2fs_add_journal_inode(fs, journal_blocks, in add_journal()
566 fs->flags &= ~EXT2_FLAG_SUPER_ONLY; in add_journal()
568 print_check_message(fs); in add_journal()
900 static void parse_extended_opts(ext2_filsys fs, const char *opts) in parse_extended_opts() argument
927 fs->super->s_flags |= EXT2_FLAGS_TEST_FILESYS; in parse_extended_opts()
929 ext2fs_mark_super_dirty(fs); in parse_extended_opts()
931 fs->super->s_flags &= ~EXT2_FLAGS_TEST_FILESYS; in parse_extended_opts()
933 ext2fs_mark_super_dirty(fs); in parse_extended_opts()
977 fs->super->s_def_hash_version = hash_alg; in parse_extended_opts()
981 ext2fs_mark_super_dirty(fs); in parse_extended_opts()
987 if (strlen(arg) >= sizeof(fs->super->s_mount_opts)) { in parse_extended_opts()
992 strcpy(fs->super->s_mount_opts, arg); in parse_extended_opts()
993 ext2fs_mark_super_dirty(fs); in parse_extended_opts()
1018 static int get_move_bitmaps(ext2_filsys fs, int new_ino_blks_per_grp, in get_move_bitmaps() argument
1027 retval = ext2fs_read_bb_inode(fs, &bb_list); in get_move_bitmaps()
1031 for (i = 0; i < fs->group_desc_count; i++) { in get_move_bitmaps()
1032 start_blk = fs->group_desc[i].bg_inode_table + in get_move_bitmaps()
1033 fs->inode_blocks_per_group; in get_move_bitmaps()
1035 end_blk = fs->group_desc[i].bg_inode_table + in get_move_bitmaps()
1039 if (ext2fs_test_block_bitmap(fs->block_map, j)) { in get_move_bitmaps()
1054 ext2fs_mark_block_bitmap(fs->block_map, j); in get_move_bitmaps()
1061 if (needed_blocks > fs->super->s_free_blocks_count) in get_move_bitmaps()
1067 static int ext2fs_is_meta_block(ext2_filsys fs, blk_t blk) in ext2fs_is_meta_block() argument
1070 group = ext2fs_group_of_blk(fs, blk); in ext2fs_is_meta_block()
1071 if (fs->group_desc[group].bg_block_bitmap == blk) in ext2fs_is_meta_block()
1073 if (fs->group_desc[group].bg_inode_bitmap == blk) in ext2fs_is_meta_block()
1078 static int ext2fs_is_block_in_group(ext2_filsys fs, dgrp_t group, blk_t blk) in ext2fs_is_block_in_group() argument
1081 start_blk = fs->super->s_first_data_block + in ext2fs_is_block_in_group()
1082 EXT2_BLOCKS_PER_GROUP(fs->super) * group; in ext2fs_is_block_in_group()
1087 end_blk = start_blk + EXT2_BLOCKS_PER_GROUP(fs->super); in ext2fs_is_block_in_group()
1093 static int move_block(ext2_filsys fs, ext2fs_block_bitmap bmap) in move_block() argument
1103 retval = ext2fs_get_mem(fs->blocksize, &buf); in move_block()
1107 for (new_blk = blk = fs->super->s_first_data_block; in move_block()
1108 blk < fs->super->s_blocks_count; blk++) { in move_block()
1112 if (ext2fs_is_meta_block(fs, blk)) { in move_block()
1120 group = ext2fs_group_of_blk(fs, blk); in move_block()
1121 goal = ext2fs_group_first_block(fs, group); in move_block()
1127 retval = ext2fs_new_block(fs, goal, NULL, &new_blk); in move_block()
1132 if (meta_data && !ext2fs_is_block_in_group(fs, group, new_blk)) { in move_block()
1138 ext2fs_mark_block_bitmap(fs->block_map, new_blk); in move_block()
1150 retval = io_channel_read_blk(fs->io, blk, 1, buf); in move_block()
1154 retval = io_channel_write_blk(fs->io, new_blk, 1, buf); in move_block()
1178 static int process_block(ext2_filsys fs EXT2FS_ATTR((unused)), in process_block()
1203 static int inode_scan_and_fix(ext2_filsys fs, ext2fs_block_bitmap bmap) in inode_scan_and_fix() argument
1212 retval = ext2fs_get_mem(fs->blocksize * 3, &block_buf); in inode_scan_and_fix()
1216 retval = ext2fs_open_inode_scan(fs, 0, &scan); in inode_scan_and_fix()
1250 retval = ext2fs_write_inode(fs, ino, &inode); in inode_scan_and_fix()
1258 retval = ext2fs_block_iterate2(fs, ino, 0, block_buf, in inode_scan_and_fix()
1276 static int group_desc_scan_and_fix(ext2_filsys fs, ext2fs_block_bitmap bmap) in group_desc_scan_and_fix() argument
1281 for (i = 0; i < fs->group_desc_count; i++) { in group_desc_scan_and_fix()
1282 blk = fs->group_desc[i].bg_block_bitmap; in group_desc_scan_and_fix()
1287 fs->group_desc[i].bg_block_bitmap = new_blk; in group_desc_scan_and_fix()
1290 blk = fs->group_desc[i].bg_inode_bitmap; in group_desc_scan_and_fix()
1295 fs->group_desc[i].bg_inode_bitmap = new_blk; in group_desc_scan_and_fix()
1301 static int expand_inode_table(ext2_filsys fs, unsigned long new_ino_size) in expand_inode_table() argument
1313 old_itable_size = fs->inode_blocks_per_group * fs->blocksize; in expand_inode_table()
1314 old_ino_size = EXT2_INODE_SIZE(fs->super); in expand_inode_table()
1317 EXT2_INODES_PER_GROUP(fs->super) * in expand_inode_table()
1319 fs->blocksize); in expand_inode_table()
1321 new_itable_size = new_ino_blks_per_grp * fs->blocksize; in expand_inode_table()
1334 for (i = 0; i < fs->group_desc_count; i++) { in expand_inode_table()
1335 blk = fs->group_desc[i].bg_inode_table; in expand_inode_table()
1336 retval = io_channel_read_blk(fs->io, blk, in expand_inode_table()
1337 fs->inode_blocks_per_group, old_itable); in expand_inode_table()
1341 for (j = 0; j < EXT2_INODES_PER_GROUP(fs->super); j++) { in expand_inode_table()
1355 retval = io_channel_write_blk(fs->io, blk, in expand_inode_table()
1362 fs->inode_blocks_per_group = new_ino_blks_per_grp; in expand_inode_table()
1363 fs->super->s_inode_size = new_ino_size; in expand_inode_table()
1375 static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs) in ext2fs_calculate_summary_stats() argument
1387 for (blk = fs->super->s_first_data_block; in ext2fs_calculate_summary_stats()
1388 blk < fs->super->s_blocks_count; blk++) { in ext2fs_calculate_summary_stats()
1389 if (!ext2fs_fast_test_block_bitmap(fs->block_map, blk)) { in ext2fs_calculate_summary_stats()
1394 if ((count == fs->super->s_blocks_per_group) || in ext2fs_calculate_summary_stats()
1395 (blk == fs->super->s_blocks_count-1)) { in ext2fs_calculate_summary_stats()
1396 fs->group_desc[group++].bg_free_blocks_count = in ext2fs_calculate_summary_stats()
1402 fs->super->s_free_blocks_count = total_free; in ext2fs_calculate_summary_stats()
1413 for (ino = 1; ino <= fs->super->s_inodes_count && ino > 0; ino++) { in ext2fs_calculate_summary_stats()
1414 if (!ext2fs_fast_test_inode_bitmap(fs->inode_map, ino)) { in ext2fs_calculate_summary_stats()
1419 if ((count == fs->super->s_inodes_per_group) || in ext2fs_calculate_summary_stats()
1420 (ino == fs->super->s_inodes_count)) { in ext2fs_calculate_summary_stats()
1421 fs->group_desc[group++].bg_free_inodes_count = in ext2fs_calculate_summary_stats()
1427 fs->super->s_free_inodes_count = total_free; in ext2fs_calculate_summary_stats()
1428 ext2fs_mark_super_dirty(fs); in ext2fs_calculate_summary_stats()
1449 static int resize_inode(ext2_filsys fs, unsigned long new_size) in resize_inode() argument
1455 ext2fs_read_inode_bitmap(fs); in resize_inode()
1456 ext2fs_read_block_bitmap(fs); in resize_inode()
1461 EXT2_INODES_PER_GROUP(fs->super)* in resize_inode()
1463 fs->blocksize); in resize_inode()
1469 fs->super->s_state &= ~EXT2_VALID_FS; in resize_inode()
1471 retval = ext2fs_allocate_block_bitmap(fs, _("blocks to be moved"), in resize_inode()
1478 retval = get_move_bitmaps(fs, new_ino_blks_per_grp, bmap); in resize_inode()
1483 retval = move_block(fs, bmap); in resize_inode()
1489 retval = inode_scan_and_fix(fs, bmap); in resize_inode()
1493 retval = group_desc_scan_and_fix(fs, bmap); in resize_inode()
1497 retval = expand_inode_table(fs, new_size); in resize_inode()
1501 ext2fs_calculate_summary_stats(fs); in resize_inode()
1503 fs->super->s_state |= EXT2_VALID_FS; in resize_inode()
1505 ext2fs_mark_super_dirty(fs); in resize_inode()
1506 ext2fs_mark_bb_dirty(fs); in resize_inode()
1587 ext2_filsys fs; in main() local
1620 0, 0, io_ptr, &fs); in main()
1636 if (new_inode_size == EXT2_INODE_SIZE(fs->super)) { in main()
1641 if (new_inode_size < EXT2_INODE_SIZE(fs->super)) { in main()
1656 ext2fs_close(fs); in main()
1661 sb = fs->super; in main()
1662 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; in main()
1680 fs->flags |= EXT2_FLAG_SUPER_ONLY; in main()
1684 ext2fs_mark_super_dirty(fs); in main()
1690 ext2fs_mark_super_dirty(fs); in main()
1695 ext2fs_mark_super_dirty(fs); in main()
1700 ext2fs_mark_super_dirty(fs); in main()
1705 ext2fs_mark_super_dirty(fs); in main()
1712 ext2fs_mark_super_dirty(fs); in main()
1725 ext2fs_mark_super_dirty(fs); in main()
1738 ext2fs_mark_super_dirty(fs); in main()
1750 ext2fs_mark_super_dirty(fs); in main()
1756 ext2fs_mark_super_dirty(fs); in main()
1766 ext2fs_mark_super_dirty(fs); in main()
1772 ext2fs_mark_super_dirty(fs); in main()
1775 update_mntopts(fs, mntopts_cmd); in main()
1777 update_feature_set(fs, features_cmd); in main()
1779 parse_extended_opts(fs, extended_cmd); in main()
1781 add_journal(fs); in main()
1794 for (i = 0; i < fs->group_desc_count; i++) in main()
1795 if (!ext2fs_group_desc_csum_verify(fs, i)) in main()
1797 if (i >= fs->group_desc_count) in main()
1812 for (i = 0; i < fs->group_desc_count; i++) in main()
1813 ext2fs_group_desc_csum_set(fs, i); in main()
1814 fs->flags &= ~EXT2_FLAG_SUPER_ONLY; in main()
1816 ext2fs_mark_super_dirty(fs); in main()
1825 if (fs->super->s_feature_incompat & in main()
1837 fs->flags &= ~EXT2_FLAG_SUPER_ONLY; in main()
1838 if (resize_inode(fs, new_inode_size) == 0) { in main()
1848 ext2fs_mark_super_dirty(fs); in main()
1853 ext2fs_mark_super_dirty(fs); in main()
1858 return (ext2fs_close(fs) ? 1 : 0); in main()