Home | History | Annotate | Download | only in ext2fs

Lines Matching refs:fs

66 static unsigned int calc_reserved_gdt_blocks(ext2_filsys fs)
68 struct ext2_super_block *sb = fs->super;
81 rsv_gdb = ext2fs_div_ceil(rsv_groups, gdpb) - fs->desc_blocks;
96 ext2_filsys fs;
114 retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs);
118 memset(fs, 0, sizeof(struct struct_ext2_filsys));
119 fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS;
120 fs->flags = flags | EXT2_FLAG_RW;
121 fs->umask = 022;
123 fs->flags |= EXT2_FLAG_SWAP_BYTES;
128 retval = manager->open(name, io_flags, &fs->io);
131 fs->image_io = fs->io;
132 fs->io->app_data = fs;
133 retval = ext2fs_get_mem(strlen(name)+1, &fs->device_name);
137 strcpy(fs->device_name, name);
141 fs->super = super;
189 super->s_mkfs_time = super->s_lastcheck = fs->now ? fs->now : time(NULL);
193 fs->blocksize = EXT2_BLOCK_SIZE(super);
194 fs->fragsize = EXT2_FRAG_SIZE(super);
195 frags_per_block = fs->blocksize / fs->fragsize;
197 /* default: (fs->blocksize*8) blocks/group, up to 2^16 (GDT limit) */
198 set_field(s_blocks_per_group, fs->blocksize * 8);
215 fs->group_desc_count = 0;
216 ext2fs_mark_super_dirty(fs);
217 *ret_fs = fs;
222 fs->group_desc_count = ext2fs_div_ceil(super->s_blocks_count -
225 if (fs->group_desc_count == 0) {
229 fs->desc_blocks = ext2fs_div_ceil(fs->group_desc_count,
232 i = fs->blocksize >= 4096 ? 1 : 4096 / fs->blocksize;
248 ipg = ext2fs_div_ceil(super->s_inodes_count, fs->group_desc_count);
249 if (ipg > fs->blocksize * 8) {
274 fs->inode_blocks_per_group = (((super->s_inodes_per_group *
278 super->s_inodes_per_group = ((fs->inode_blocks_per_group *
287 fs->inode_blocks_per_group = (((super->s_inodes_per_group *
295 if ((__u64)super->s_inodes_per_group * fs->group_desc_count > ~0U) {
300 fs->group_desc_count;
307 rsv_gdt = calc_reserved_gdt_blocks(fs);
322 overhead = (int) (3 + fs->inode_blocks_per_group +
323 fs->desc_blocks + super->s_reserved_gdt_blocks);
338 overhead = (int) (2 + fs->inode_blocks_per_group);
339 if (ext2fs_bg_has_super(fs, fs->group_desc_count - 1))
340 overhead += 1 + fs->desc_blocks + super->s_reserved_gdt_blocks;
343 if ((fs->group_desc_count == 1) && rem && (rem < overhead)) {
358 retval = ext2fs_get_mem(strlen(fs->device_name) + 80, &buf);
363 strcat(buf, fs->device_name);
364 retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map);
369 strcat(buf, fs->device_name);
370 retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map);
376 retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize,
377 &fs->group_desc);
381 memset(fs->group_desc, 0, (size_t) fs->desc_blocks * fs->blocksize);
395 csum_flag = EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
397 for (i = 0; i < fs->group_desc_count; i++) {
403 if (i != fs->group_desc_count - 1)
404 fs->group_desc[i].bg_flags |=
406 fs->group_desc[i].bg_flags |= EXT2_BG_INODE_UNINIT;
410 fs->group_desc[i].bg_itable_unused = numblocks;
412 numblocks = ext2fs_reserve_super_and_bgd(fs, i, fs->block_map);
413 if (fs->super->s_log_groups_per_flex)
414 numblocks += 2 + fs->inode_blocks_per_group;
417 fs->group_desc[i].bg_free_blocks_count = numblocks;
418 fs->group_desc[i].bg_free_inodes_count =
419 fs->super->s_inodes_per_group;
420 fs->group_desc[i].bg_used_dirs_count = 0;
421 ext2fs_group_desc_csum_set(fs, i);
431 ext2fs_mark_super_dirty(fs);
432 ext2fs_mark_bb_dirty(fs);
433 ext2fs_mark_ib_dirty(fs);
435 io_channel_set_blksize(fs->io, fs->blocksize);
437 *ret_fs = fs;
441 ext2fs_free(fs);