Home | History | Annotate | Download | only in ext2fs

Lines Matching refs:fs

35 int ext2fs_bg_has_super(ext2_filsys fs, int group_block)
37 if (!(fs->super->s_feature_ro_compat &
48 int ext2fs_super_and_bgd_loc(ext2_filsys fs,
60 group_block = fs->super->s_first_data_block +
61 (group * fs->super->s_blocks_per_group);
63 if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
64 old_desc_blocks = fs->super->s_first_meta_bg;
67 fs->desc_blocks + fs->super->s_reserved_gdt_blocks;
69 if (group == fs->group_desc_count-1) {
70 numblocks = (fs->super->s_blocks_count -
71 fs->super->s_first_data_block) %
72 fs->super->s_blocks_per_group;
74 numblocks = fs->super->s_blocks_per_group;
76 numblocks = fs->super->s_blocks_per_group;
78 has_super = ext2fs_bg_has_super(fs, group);
84 meta_bg_size = (fs->blocksize / sizeof (struct ext2_group_desc));
87 if (!(fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) ||
88 (meta_bg < fs->super->s_first_meta_bg)) {
104 numblocks -= 2 + fs->inode_blocks_per_group;
128 static errcode_t write_primary_superblock(ext2_filsys fs,
135 if (!fs->io->manager->write_byte || !fs->orig_super) {
136 io_channel_set_blksize(fs->io, SUPERBLOCK_OFFSET);
137 retval = io_channel_write_blk(fs->io, 1, -SUPERBLOCK_SIZE,
139 io_channel_set_blksize(fs->io, fs->blocksize);
143 old_super = (__u16 *) fs->orig_super;
158 retval = io_channel_write_byte(fs->io,
164 memcpy(fs->orig_super, super, SUPERBLOCK_SIZE);
172 void ext2fs_update_dynamic_rev(ext2_filsys fs)
174 struct ext2_super_block *sb = fs->super;
186 static errcode_t write_backup_super(ext2_filsys fs, dgrp_t group,
195 if (fs->flags & EXT2_FLAG_SWAP_BYTES)
199 fs->super->s_block_group_nr = sgrp;
201 return io_channel_write_blk(fs->io, group_block, -SUPERBLOCK_SIZE,
206 errcode_t ext2fs_flush(ext2_filsys fs)
218 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
220 fs_state = fs->super->s_state;
221 feature_incompat = fs->super->s_feature_incompat;
223 fs->super->s_wtime = fs->now ? fs->now : time(NULL);
224 fs->super->s_block_group_nr = 0;
226 if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
231 retval = ext2fs_get_array(fs->blocksize, fs->desc_blocks,
235 memset(group_shadow, 0, (size_t) fs->blocksize *
236 fs->desc_blocks);
239 for (j=0, s=fs->group_desc, t=group_shadow;
240 j < fs->group_desc_count; j++, t++, s++) {
245 super_shadow = fs->super;
246 group_shadow = fs->group_desc;
249 super_shadow = fs->super;
250 group_shadow = fs->group_desc;
254 * Set the state of the FS to be non-valid. (The state has
258 fs->super->s_state &= ~EXT2_VALID_FS;
259 fs->super->s_feature_incompat &= ~EXT3_FEATURE_INCOMPAT_RECOVER;
261 if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
262 *super_shadow = *fs->super;
271 if (fs->super->s_feature_incompat &
280 if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
281 old_desc_blocks = fs->super->s_first_meta_bg;
283 old_desc_blocks = fs->desc_blocks;
285 for (i = 0; i < fs->group_desc_count; i++) {
289 ext2fs_super_and_bgd_loc(fs, i, &super_blk, &old_desc_blk,
292 if (!(fs->flags & EXT2_FLAG_MASTER_SB_ONLY) &&i && super_blk) {
293 retval = write_backup_super(fs, i, super_blk,
298 if (fs->flags & EXT2_FLAG_SUPER_ONLY)
301 (!(fs->flags & EXT2_FLAG_MASTER_SB_ONLY) || (i == 0))) {
302 retval = io_channel_write_blk(fs->io,
308 retval = io_channel_write_blk(fs->io, new_desc_blk,
309 1, group_ptr + (meta_bg*fs->blocksize));
321 if (fs->write_bitmaps) {
322 retval = fs->write_bitmaps(fs);
336 fs->super->s_block_group_nr = 0;
337 fs->super->s_state = fs_state;
338 fs->super->s_feature_incompat = feature_incompat;
340 if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
341 *super_shadow = *fs->super;
346 retval = io_channel_flush(fs->io);
347 retval = write_primary_superblock(fs, super_shadow);
351 fs->flags &= ~EXT2_FLAG_DIRTY;
353 retval = io_channel_flush(fs->io);
355 fs->super->s_state = fs_state;
356 if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
365 errcode_t ext2fs_close(ext2_filsys fs)
369 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
371 if (fs->flags & EXT2_FLAG_DIRTY) {
372 retval = ext2fs_flush(fs);
376 if (fs->write_bitmaps) {
377 retval = fs->write_bitmaps(fs);
381 ext2fs_free(fs);