• Home
  • Raw
  • Download

Lines Matching refs:fs

35 blk64_t ext2fs_descriptor_block_loc2(ext2_filsys fs, blk64_t group_block,  in ext2fs_descriptor_block_loc2()  argument
46 if (i == 0 && fs->blocksize == 1024 && EXT2FS_CLUSTER_RATIO(fs) > 1) in ext2fs_descriptor_block_loc2()
49 if (!ext2fs_has_feature_meta_bg(fs->super) || in ext2fs_descriptor_block_loc2()
50 (i < fs->super->s_first_meta_bg)) in ext2fs_descriptor_block_loc2()
53 bg = EXT2_DESC_PER_BLOCK(fs->super) * i; in ext2fs_descriptor_block_loc2()
54 if (ext2fs_bg_has_super(fs, bg)) in ext2fs_descriptor_block_loc2()
56 ret_blk = ext2fs_group_first_block2(fs, bg); in ext2fs_descriptor_block_loc2()
65 if (group_block != fs->super->s_first_data_block && in ext2fs_descriptor_block_loc2()
66 ((ret_blk + has_super + fs->super->s_blocks_per_group) < in ext2fs_descriptor_block_loc2()
67 ext2fs_blocks_count(fs->super))) { in ext2fs_descriptor_block_loc2()
68 ret_blk += fs->super->s_blocks_per_group; in ext2fs_descriptor_block_loc2()
75 if (ext2fs_bg_has_super(fs, bg + 1)) in ext2fs_descriptor_block_loc2()
83 blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, dgrp_t i) in ext2fs_descriptor_block_loc() argument
85 return ext2fs_descriptor_block_loc2(fs, group_block, i); in ext2fs_descriptor_block_loc()
121 ext2_filsys fs; in ext2fs_open2() local
140 retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs); in ext2fs_open2()
144 memset(fs, 0, sizeof(struct struct_ext2_filsys)); in ext2fs_open2()
145 fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS; in ext2fs_open2()
146 fs->flags = flags; in ext2fs_open2()
148 fs->flags |= EXT2_FLAG_MASTER_SB_ONLY; in ext2fs_open2()
149 fs->umask = 022; in ext2fs_open2()
153 fs->now = strtoul(time_env, NULL, 0); in ext2fs_open2()
155 retval = ext2fs_get_mem(strlen(name)+1, &fs->device_name); in ext2fs_open2()
158 strcpy(fs->device_name, name); in ext2fs_open2()
159 cp = strchr(fs->device_name, '?'); in ext2fs_open2()
172 retval = manager->open(fs->device_name, io_flags, &fs->io); in ext2fs_open2()
176 (retval = io_channel_set_options(fs->io, io_options))) in ext2fs_open2()
178 fs->image_io = fs->io; in ext2fs_open2()
179 fs->io->app_data = fs; in ext2fs_open2()
180 retval = io_channel_alloc_buf(fs->io, -SUPERBLOCK_SIZE, &fs->super); in ext2fs_open2()
185 &fs->image_header); in ext2fs_open2()
188 retval = io_channel_read_blk(fs->io, 0, in ext2fs_open2()
190 fs->image_header); in ext2fs_open2()
193 if (ext2fs_le32_to_cpu(fs->image_header->magic_number) != EXT2_ET_MAGIC_E2IMAGE) in ext2fs_open2()
196 block_size = ext2fs_le32_to_cpu(fs->image_header->fs_blocksize); in ext2fs_open2()
213 io_channel_set_blksize(fs->io, block_size); in ext2fs_open2()
215 fs->orig_super = 0; in ext2fs_open2()
217 io_channel_set_blksize(fs->io, SUPERBLOCK_OFFSET); in ext2fs_open2()
220 retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &fs->orig_super); in ext2fs_open2()
224 retval = io_channel_read_blk(fs->io, superblock, -SUPERBLOCK_SIZE, in ext2fs_open2()
225 fs->super); in ext2fs_open2()
228 if (fs->orig_super) in ext2fs_open2()
229 memcpy(fs->orig_super, fs->super, SUPERBLOCK_SIZE); in ext2fs_open2()
231 if (!(fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS)) { in ext2fs_open2()
233 if (!ext2fs_verify_csum_type(fs, fs->super)) in ext2fs_open2()
235 if (!ext2fs_superblock_csum_verify(fs, fs->super)) in ext2fs_open2()
240 fs->flags |= EXT2_FLAG_SWAP_BYTES; in ext2fs_open2()
241 ext2fs_swap_super(fs->super); in ext2fs_open2()
243 if (fs->flags & EXT2_FLAG_SWAP_BYTES) { in ext2fs_open2()
249 if (fs->super->s_magic != EXT2_SUPER_MAGIC) in ext2fs_open2()
254 if (fs->super->s_rev_level > EXT2_LIB_CURRENT_REV) { in ext2fs_open2()
263 features = fs->super->s_feature_incompat; in ext2fs_open2()
273 features = fs->super->s_feature_ro_compat; in ext2fs_open2()
285 ext2fs_has_feature_journal_dev(fs->super)) { in ext2fs_open2()
291 if (fs->super->s_log_block_size > in ext2fs_open2()
301 if (ext2fs_has_feature_bigalloc(fs->super) && in ext2fs_open2()
307 if (!ext2fs_has_feature_bigalloc(fs->super) && in ext2fs_open2()
308 (fs->super->s_log_block_size != fs->super->s_log_cluster_size)) { in ext2fs_open2()
312 fs->fragsize = fs->blocksize = EXT2_BLOCK_SIZE(fs->super); in ext2fs_open2()
313 inode_size = EXT2_INODE_SIZE(fs->super); in ext2fs_open2()
315 (inode_size > fs->blocksize) || in ext2fs_open2()
322 if (ext2fs_has_feature_64bit(fs->super)) { in ext2fs_open2()
323 if (fs->super->s_desc_size < EXT2_MIN_DESC_SIZE_64BIT) { in ext2fs_open2()
329 fs->cluster_ratio_bits = fs->super->s_log_cluster_size - in ext2fs_open2()
330 fs->super->s_log_block_size; in ext2fs_open2()
331 if (EXT2_BLOCKS_PER_GROUP(fs->super) != in ext2fs_open2()
332 EXT2_CLUSTERS_PER_GROUP(fs->super) << fs->cluster_ratio_bits) { in ext2fs_open2()
336 fs->inode_blocks_per_group = ((EXT2_INODES_PER_GROUP(fs->super) * in ext2fs_open2()
337 EXT2_INODE_SIZE(fs->super) + in ext2fs_open2()
338 EXT2_BLOCK_SIZE(fs->super) - 1) / in ext2fs_open2()
339 EXT2_BLOCK_SIZE(fs->super)); in ext2fs_open2()
341 if (block_size != fs->blocksize) { in ext2fs_open2()
349 io_channel_set_blksize(fs->io, fs->blocksize); in ext2fs_open2()
355 if (ext2fs_has_feature_journal_dev(fs->super)) { in ext2fs_open2()
356 fs->group_desc_count = 0; in ext2fs_open2()
357 *ret_fs = fs; in ext2fs_open2()
361 if (EXT2_INODES_PER_GROUP(fs->super) == 0) { in ext2fs_open2()
366 ext2fs_init_csum_seed(fs); in ext2fs_open2()
371 blocks_per_group = EXT2_BLOCKS_PER_GROUP(fs->super); in ext2fs_open2()
373 blocks_per_group > EXT2_MAX_BLOCKS_PER_GROUP(fs->super) || in ext2fs_open2()
374 fs->inode_blocks_per_group > EXT2_MAX_INODES_PER_GROUP(fs->super) || in ext2fs_open2()
375 EXT2_DESC_PER_BLOCK(fs->super) == 0 || in ext2fs_open2()
376 fs->super->s_first_data_block >= ext2fs_blocks_count(fs->super)) { in ext2fs_open2()
380 groups_cnt = ext2fs_div64_ceil(ext2fs_blocks_count(fs->super) - in ext2fs_open2()
381 fs->super->s_first_data_block, in ext2fs_open2()
387 fs->group_desc_count = groups_cnt; in ext2fs_open2()
389 (__u64)fs->group_desc_count * EXT2_INODES_PER_GROUP(fs->super) != in ext2fs_open2()
390 fs->super->s_inodes_count) { in ext2fs_open2()
394 fs->desc_blocks = ext2fs_div_ceil(fs->group_desc_count, in ext2fs_open2()
395 EXT2_DESC_PER_BLOCK(fs->super)); in ext2fs_open2()
396 retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize, in ext2fs_open2()
397 &fs->group_desc); in ext2fs_open2()
401 group_block = fs->super->s_first_data_block; in ext2fs_open2()
413 if (group_block == 0 && fs->blocksize == 1024) in ext2fs_open2()
415 dest = (char *) fs->group_desc; in ext2fs_open2()
417 groups_per_block = EXT2_DESC_PER_BLOCK(fs->super); in ext2fs_open2()
419 if (ext2fs_has_feature_meta_bg(fs->super) && in ext2fs_open2()
421 first_meta_bg = fs->super->s_first_meta_bg; in ext2fs_open2()
422 if (first_meta_bg > fs->desc_blocks) in ext2fs_open2()
423 first_meta_bg = fs->desc_blocks; in ext2fs_open2()
425 first_meta_bg = fs->desc_blocks; in ext2fs_open2()
427 retval = io_channel_read_blk(fs->io, group_block + in ext2fs_open2()
435 gdp = ext2fs_group_desc(fs, fs->group_desc, j); in ext2fs_open2()
436 ext2fs_swap_group_desc2(fs, gdp); in ext2fs_open2()
439 dest += fs->blocksize*first_meta_bg; in ext2fs_open2()
442 for (i = first_meta_bg ; i < fs->desc_blocks; i++) { in ext2fs_open2()
443 blk = ext2fs_descriptor_block_loc2(fs, group_block, i); in ext2fs_open2()
444 io_channel_cache_readahead(fs->io, blk, 1); in ext2fs_open2()
447 for (i=first_meta_bg ; i < fs->desc_blocks; i++) { in ext2fs_open2()
448 blk = ext2fs_descriptor_block_loc2(fs, group_block, i); in ext2fs_open2()
449 retval = io_channel_read_blk64(fs->io, blk, 1, dest); in ext2fs_open2()
454 gdp = ext2fs_group_desc(fs, fs->group_desc, in ext2fs_open2()
456 ext2fs_swap_group_desc2(fs, gdp); in ext2fs_open2()
459 dest += fs->blocksize; in ext2fs_open2()
462 fs->stride = fs->super->s_raid_stride; in ext2fs_open2()
468 if (superblock > 1 && ext2fs_has_group_desc_csum(fs)) { in ext2fs_open2()
471 for (group = 0; group < fs->group_desc_count; group++) { in ext2fs_open2()
472 ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT); in ext2fs_open2()
473 ext2fs_bg_flags_clear(fs, group, EXT2_BG_INODE_UNINIT); in ext2fs_open2()
474 ext2fs_bg_itable_unused_set(fs, group, 0); in ext2fs_open2()
477 ext2fs_group_desc_csum_set(fs, group); in ext2fs_open2()
479 if (fs->flags & EXT2_FLAG_RW) in ext2fs_open2()
480 ext2fs_mark_super_dirty(fs); in ext2fs_open2()
483 if (ext2fs_has_feature_mmp(fs->super) && in ext2fs_open2()
486 retval = ext2fs_mmp_start(fs); in ext2fs_open2()
488 fs->flags |= EXT2_FLAG_SKIP_MMP; /* just do cleanup */ in ext2fs_open2()
489 ext2fs_mmp_stop(fs); in ext2fs_open2()
494 if (fs->flags & EXT2_FLAG_SHARE_DUP) { in ext2fs_open2()
495 fs->block_sha_map = ext2fs_hashmap_create(ext2fs_djb2_hash, in ext2fs_open2()
497 if (!fs->block_sha_map) { in ext2fs_open2()
501 ext2fs_set_feature_shared_blocks(fs->super); in ext2fs_open2()
504 if (ext2fs_has_feature_casefold(fs->super)) in ext2fs_open2()
505 fs->encoding = ext2fs_load_nls_table(fs->super->s_encoding); in ext2fs_open2()
507 fs->flags &= ~EXT2_FLAG_NOFREE_ON_ERROR; in ext2fs_open2()
508 *ret_fs = fs; in ext2fs_open2()
513 ext2fs_free(fs); in ext2fs_open2()
514 fs = NULL; in ext2fs_open2()
516 *ret_fs = fs; in ext2fs_open2()
525 errcode_t ext2fs_get_data_io(ext2_filsys fs, io_channel *old_io) in ext2fs_get_data_io() argument
527 if ((fs->flags & EXT2_FLAG_IMAGE_FILE) == 0) in ext2fs_get_data_io()
530 *old_io = (fs->image_io == fs->io) ? 0 : fs->io; in ext2fs_get_data_io()
535 errcode_t ext2fs_set_data_io(ext2_filsys fs, io_channel new_io) in ext2fs_set_data_io() argument
537 if ((fs->flags & EXT2_FLAG_IMAGE_FILE) == 0) in ext2fs_set_data_io()
539 fs->io = new_io ? new_io : fs->image_io; in ext2fs_set_data_io()
543 errcode_t ext2fs_rewrite_to_io(ext2_filsys fs, io_channel new_io) in ext2fs_rewrite_to_io() argument
547 if ((fs->flags & EXT2_FLAG_IMAGE_FILE) == 0) in ext2fs_rewrite_to_io()
549 err = io_channel_set_blksize(new_io, fs->blocksize); in ext2fs_rewrite_to_io()
552 if ((new_io == fs->image_io) || (new_io == fs->io)) in ext2fs_rewrite_to_io()
554 if ((fs->image_io != fs->io) && in ext2fs_rewrite_to_io()
555 fs->image_io) in ext2fs_rewrite_to_io()
556 io_channel_close(fs->image_io); in ext2fs_rewrite_to_io()
557 if (fs->io) in ext2fs_rewrite_to_io()
558 io_channel_close(fs->io); in ext2fs_rewrite_to_io()
559 fs->io = fs->image_io = new_io; in ext2fs_rewrite_to_io()
560 fs->flags |= EXT2_FLAG_DIRTY | EXT2_FLAG_RW | in ext2fs_rewrite_to_io()
562 fs->flags &= ~EXT2_FLAG_IMAGE_FILE; in ext2fs_rewrite_to_io()