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