Lines Matching refs:fs
58 static unsigned int calc_reserved_gdt_blocks(ext2_filsys fs) in calc_reserved_gdt_blocks() argument
60 struct ext2_super_block *sb = fs->super; in calc_reserved_gdt_blocks()
77 rsv_gdb = ext2fs_div_ceil(rsv_groups, gdpb) - fs->desc_blocks; in calc_reserved_gdt_blocks()
92 ext2_filsys fs; in ext2fs_initialize() local
115 retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs); in ext2fs_initialize()
119 memset(fs, 0, sizeof(struct struct_ext2_filsys)); in ext2fs_initialize()
120 fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS; in ext2fs_initialize()
121 fs->flags = flags | EXT2_FLAG_RW; in ext2fs_initialize()
122 fs->umask = 022; in ext2fs_initialize()
123 fs->default_bitmap_type = EXT2FS_BMAP64_RBTREE; in ext2fs_initialize()
125 fs->flags |= EXT2_FLAG_SWAP_BYTES; in ext2fs_initialize()
130 fs->now = strtoul(time_env, NULL, 0); in ext2fs_initialize()
138 retval = manager->open(name, io_flags, &fs->io); in ext2fs_initialize()
141 fs->image_io = fs->io; in ext2fs_initialize()
142 fs->io->app_data = fs; in ext2fs_initialize()
143 retval = ext2fs_get_mem(strlen(name)+1, &fs->device_name); in ext2fs_initialize()
147 strcpy(fs->device_name, name); in ext2fs_initialize()
151 fs->super = super; in ext2fs_initialize()
214 super->s_mkfs_time = super->s_lastcheck = fs->now ? fs->now : time(NULL); in ext2fs_initialize()
218 fs->fragsize = fs->blocksize = EXT2_BLOCK_SIZE(super); in ext2fs_initialize()
219 fs->cluster_ratio_bits = super->s_log_cluster_size - in ext2fs_initialize()
227 ((param->s_clusters_per_group * EXT2FS_CLUSTER_RATIO(fs)) != in ext2fs_initialize()
237 EXT2FS_CLUSTER_RATIO(fs); in ext2fs_initialize()
239 super->s_clusters_per_group = fs->blocksize * 8; in ext2fs_initialize()
241 super->s_clusters_per_group = (fs->blocksize - 1) * 8; in ext2fs_initialize()
244 bpg = EXT2FS_C2B(fs, in ext2fs_initialize()
252 set_field(s_blocks_per_group, fs->blocksize * 8); in ext2fs_initialize()
259 ~((blk64_t) EXT2FS_CLUSTER_MASK(fs))); in ext2fs_initialize()
273 fs->group_desc_count = 0; in ext2fs_initialize()
274 ext2fs_mark_super_dirty(fs); in ext2fs_initialize()
275 *ret_fs = fs; in ext2fs_initialize()
280 fs->group_desc_count = (dgrp_t) ext2fs_div64_ceil( in ext2fs_initialize()
283 if (fs->group_desc_count == 0) { in ext2fs_initialize()
292 fs->desc_blocks = ext2fs_div_ceil(fs->group_desc_count, in ext2fs_initialize()
295 i = fs->blocksize >= 4096 ? 1 : 4096 / fs->blocksize; in ext2fs_initialize()
316 ipg = ext2fs_div_ceil(super->s_inodes_count, fs->group_desc_count); in ext2fs_initialize()
317 if (ipg > fs->blocksize * 8) { in ext2fs_initialize()
342 fs->inode_blocks_per_group = (((super->s_inodes_per_group * in ext2fs_initialize()
346 super->s_inodes_per_group = ((fs->inode_blocks_per_group * in ext2fs_initialize()
357 fs->inode_blocks_per_group = (((super->s_inodes_per_group * in ext2fs_initialize()
365 if ((__u64)super->s_inodes_per_group * fs->group_desc_count > ~0U) { in ext2fs_initialize()
370 fs->group_desc_count; in ext2fs_initialize()
377 rsv_gdt = calc_reserved_gdt_blocks(fs); in ext2fs_initialize()
386 if (super->s_reserved_gdt_blocks + fs->desc_blocks > in ext2fs_initialize()
388 ext2fs_set_feature_meta_bg(fs->super); in ext2fs_initialize()
389 ext2fs_clear_feature_resize_inode(fs->super); in ext2fs_initialize()
399 overhead = (int) (3 + fs->inode_blocks_per_group + in ext2fs_initialize()
402 if (ext2fs_has_feature_meta_bg(fs->super)) in ext2fs_initialize()
405 overhead += fs->desc_blocks; in ext2fs_initialize()
420 overhead = (int) (2 + fs->inode_blocks_per_group); in ext2fs_initialize()
427 if (fs->group_desc_count == 2) in ext2fs_initialize()
432 has_bg = ext2fs_bg_has_super(fs, fs->group_desc_count - 1); in ext2fs_initialize()
434 overhead += 1 + fs->desc_blocks + super->s_reserved_gdt_blocks; in ext2fs_initialize()
437 if ((fs->group_desc_count == 1) && rem && (rem < overhead)) { in ext2fs_initialize()
464 if (super->s_backup_bgs[0] >= fs->group_desc_count) in ext2fs_initialize()
465 super->s_backup_bgs[0] = fs->group_desc_count - 1; in ext2fs_initialize()
466 if (super->s_backup_bgs[1] >= fs->group_desc_count) in ext2fs_initialize()
467 super->s_backup_bgs[1] = fs->group_desc_count - 1; in ext2fs_initialize()
477 retval = ext2fs_get_mem(strlen(fs->device_name) + 80, &buf); in ext2fs_initialize()
482 strcat(buf, fs->device_name); in ext2fs_initialize()
483 retval = ext2fs_allocate_subcluster_bitmap(fs, buf, &fs->block_map); in ext2fs_initialize()
488 strcat(buf, fs->device_name); in ext2fs_initialize()
489 retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map); in ext2fs_initialize()
495 retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize, in ext2fs_initialize()
496 &fs->group_desc); in ext2fs_initialize()
500 memset(fs->group_desc, 0, (size_t) fs->desc_blocks * fs->blocksize); in ext2fs_initialize()
514 csum_flag = ext2fs_has_group_desc_csum(fs); in ext2fs_initialize()
516 for (i = 0; i < fs->group_desc_count; i++) { in ext2fs_initialize()
522 if (i != fs->group_desc_count - 1) in ext2fs_initialize()
523 ext2fs_bg_flags_set(fs, i, in ext2fs_initialize()
525 ext2fs_bg_flags_set(fs, i, EXT2_BG_INODE_UNINIT); in ext2fs_initialize()
536 ext2fs_bg_itable_unused_set(fs, i, numblocks); in ext2fs_initialize()
538 numblocks = ext2fs_reserve_super_and_bgd(fs, i, fs->block_map); in ext2fs_initialize()
539 if (fs->super->s_log_groups_per_flex) in ext2fs_initialize()
540 numblocks += 2 + fs->inode_blocks_per_group; in ext2fs_initialize()
543 ext2fs_bg_free_blocks_count_set(fs, i, numblocks); in ext2fs_initialize()
544 ext2fs_bg_free_inodes_count_set(fs, i, fs->super->s_inodes_per_group); in ext2fs_initialize()
545 ext2fs_bg_used_dirs_count_set(fs, i, 0); in ext2fs_initialize()
546 ext2fs_group_desc_csum_set(fs, i); in ext2fs_initialize()
548 free_blocks &= ~EXT2FS_CLUSTER_MASK(fs); in ext2fs_initialize()
558 ext2fs_mark_super_dirty(fs); in ext2fs_initialize()
559 ext2fs_mark_bb_dirty(fs); in ext2fs_initialize()
560 ext2fs_mark_ib_dirty(fs); in ext2fs_initialize()
562 io_channel_set_blksize(fs->io, fs->blocksize); in ext2fs_initialize()
564 *ret_fs = fs; in ext2fs_initialize()
568 ext2fs_free(fs); in ext2fs_initialize()