这篇教程C++ EXT2_INODES_PER_GROUP函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中EXT2_INODES_PER_GROUP函数的典型用法代码示例。如果您正苦于以下问题:C++ EXT2_INODES_PER_GROUP函数的具体用法?C++ EXT2_INODES_PER_GROUP怎么用?C++ EXT2_INODES_PER_GROUP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了EXT2_INODES_PER_GROUP函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ext2_setup_superstatic int ext2_setup_super (struct super_block * sb, struct ext2_super_block * es, int read_only){ int res = 0; struct ext2_sb_info *sbi = EXT2_SB(sb); if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) { printk ("EXT2-fs warning: revision level too high, " "forcing read-only mode/n"); res = MS_RDONLY; } if (read_only) return res; if (!(sbi->s_mount_state & EXT2_VALID_FS)) printk ("EXT2-fs warning: mounting unchecked fs, " "running e2fsck is recommended/n"); else if ((sbi->s_mount_state & EXT2_ERROR_FS)) printk ("EXT2-fs warning: mounting fs with errors, " "running e2fsck is recommended/n"); else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && le16_to_cpu(es->s_mnt_count) >= (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) printk ("EXT2-fs warning: maximal mount count reached, " "running e2fsck is recommended/n"); else if (le32_to_cpu(es->s_checkinterval) && (le32_to_cpu(es->s_lastcheck) + le32_to_cpu(es->s_checkinterval) <= get_seconds())) printk ("EXT2-fs warning: checktime reached, " "running e2fsck is recommended/n"); if (!le16_to_cpu(es->s_max_mnt_count)) es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT); le16_add_cpu(&es->s_mnt_count, 1); ext2_write_super(sb); if (test_opt (sb, DEBUG)) printk ("[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, " "bpg=%lu, ipg=%lu, mo=%04lx]/n", EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize, sbi->s_frag_size, sbi->s_groups_count, EXT2_BLOCKS_PER_GROUP(sb), EXT2_INODES_PER_GROUP(sb), sbi->s_mount_opt); return res;}
开发者ID:sushengloong,项目名称:comp3301-s4239799,代码行数:44,
示例2: check_inode_endstatic void check_inode_end(e2fsck_t ctx){ ext2_filsys fs = ctx->fs; ext2_ino_t end, save_inodes_count, i; struct problem_context pctx; clear_problem_context(&pctx); end = EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count; pctx.errcode = ext2fs_fudge_inode_bitmap_end(fs->inode_map, end, &save_inodes_count); if (pctx.errcode) { pctx.num = 1; fix_problem(ctx, PR_5_FUDGE_BITMAP_ERROR, &pctx); ctx->flags |= E2F_FLAG_ABORT; /* fatal */ return; } if (save_inodes_count == end) return; /* protect loop from wrap-around if end is maxed */ for (i = save_inodes_count + 1; i <= end && i > save_inodes_count; i++) { if (!ext2fs_test_inode_bitmap(fs->inode_map, i)) { if (fix_problem(ctx, PR_5_INODE_BMAP_PADDING, &pctx)) { for (; i <= end; i++) ext2fs_mark_inode_bitmap(fs->inode_map, i); ext2fs_mark_ib_dirty(fs); } else ext2fs_unmark_valid(fs); break; } } pctx.errcode = ext2fs_fudge_inode_bitmap_end(fs->inode_map, save_inodes_count, 0); if (pctx.errcode) { pctx.num = 2; fix_problem(ctx, PR_5_FUDGE_BITMAP_ERROR, &pctx); ctx->flags |= E2F_FLAG_ABORT; /* fatal */ return; }}
开发者ID:RaphaelFrajuca,项目名称:platform_kyleveub,代码行数:43,
示例3: ext2fs_write_inode_bitmaperrcode_t ext2fs_write_inode_bitmap(ext2_filsys fs){ dgrp_t i; size_t nbytes; errcode_t retval; char * inode_bitmap = fs->inode_map->bitmap; char * bitmap_block = NULL; blk_t blk; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); if (!(fs->flags & EXT2_FLAG_RW)) return EXT2_ET_RO_FILSYS; if (!inode_bitmap) return 0; nbytes = (size_t) ((EXT2_INODES_PER_GROUP(fs->super)+7) / 8); retval = ext2fs_get_mem(fs->blocksize, &bitmap_block); if (retval) return retval; memset(bitmap_block, 0xff, fs->blocksize); for (i = 0; i < fs->group_desc_count; i++) { memcpy(bitmap_block, inode_bitmap, nbytes); blk = fs->group_desc[i].bg_inode_bitmap; if (blk) {#ifdef EXT2_BIG_ENDIAN_BITMAPS if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) || (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE))) ext2fs_swap_bitmap(fs, bitmap_block, nbytes);#endif retval = io_channel_write_blk(fs->io, blk, 1, bitmap_block); if (retval) return EXT2_ET_INODE_BITMAP_WRITE; } inode_bitmap += nbytes; } fs->flags &= ~EXT2_FLAG_IB_DIRTY; ext2fs_free_mem(&bitmap_block); return 0;}
开发者ID:alhazred,项目名称:busybox-solaris,代码行数:41,
示例4: ext2_setup_superstatic void ext2_setup_super (struct super_block * sb, struct ext2_super_block * es){ if (!(sb->s_flags & MS_RDONLY)) { if (!(sb->u.ext2_sb.s_mount_state & EXT2_VALID_FS)) printk ("EXT2-fs warning: mounting unchecked fs, " "running e2fsck is recommended/n"); else if ((sb->u.ext2_sb.s_mount_state & EXT2_ERROR_FS)) printk ("EXT2-fs warning: mounting fs with errors, " "running e2fsck is recommended/n"); else if (es->s_max_mnt_count >= 0 && es->s_mnt_count >= (unsigned short) es->s_max_mnt_count) printk ("EXT2-fs warning: maximal mount count reached, " "running e2fsck is recommended/n"); else if (es->s_checkinterval && (es->s_lastcheck + es->s_checkinterval <= CURRENT_TIME)) printk ("EXT2-fs warning: checktime reached, " "running e2fsck is recommended/n"); es->s_state &= ~EXT2_VALID_FS; if (!es->s_max_mnt_count) es->s_max_mnt_count = EXT2_DFL_MAX_MNT_COUNT; es->s_mnt_count++; es->s_mtime = CURRENT_TIME; sb->u.ext2_sb.s_sbh->b_dirt = 1; sb->s_dirt = 1; if (test_opt (sb, DEBUG)) printk ("[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, " "bpg=%lu, ipg=%lu, mo=%04lx]/n", EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize, sb->u.ext2_sb.s_frag_size, sb->u.ext2_sb.s_groups_count, EXT2_BLOCKS_PER_GROUP(sb), EXT2_INODES_PER_GROUP(sb), sb->u.ext2_sb.s_mount_opt); if (test_opt (sb, CHECK)) { ext2_check_blocks_bitmap (sb); ext2_check_inodes_bitmap (sb); } }}
开发者ID:DreamLiMu,项目名称:Linux-Kernel-Study,代码行数:40,
示例5: ext2_count_free_inodesunsigned long ext2_count_free_inodes (struct super_block * sb){#ifdef EXT2FS_DEBUG struct ext2_super_block * es; unsigned long desc_count, bitmap_count, x; int bitmap_nr; struct ext2_group_desc * gdp; int i, bs; lock_super (sb); es = sb->u.ext2_sb.s_es; bs = BYTE_SWAP(sb->u.ext2_sb.s_byte_swapped); desc_count = 0; bitmap_count = 0; gdp = NULL; for (i = 0; i < sb->u.ext2_sb.s_groups_count; i++) { gdp = get_group_desc (sb, i, NULL); desc_count += e_swab (bs, gdp->bg_free_inodes_count); bitmap_nr = load_inode_bitmap (sb, i); if (bitmap_nr < 0) continue; x = ext2_count_free (sb->u.ext2_sb.s_inode_bitmap[bitmap_nr], EXT2_INODES_PER_GROUP(sb) / 8); printk ("group %d: stored = %d, counted = %lu/n", i, e_swab (bs, gdp->bg_free_inodes_count), x); bitmap_count += x; } printk("ext2_count_free_inodes: stored = %lu, computed = %lu, %lu/n", e_swab (bs, es->s_free_inodes_count), desc_count, bitmap_count); unlock_super (sb); return desc_count;#else return e_swab (BYTE_SWAP(sb->u.ext2_sb.s_byte_swapped), sb->u.ext2_sb.s_es->s_free_inodes_count);#endif}
开发者ID:shattered,项目名称:linux-m68k,代码行数:37,
示例6: write_bitmapsstatic errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block){ dgrp_t i; unsigned int j; int block_nbytes, inode_nbytes; unsigned int nbits; errcode_t retval; char *block_bitmap, *inode_bitmap; char *block_buf, *inode_buf; int lazy_flag = 0; blk_t blk; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); if (!(fs->flags & EXT2_FLAG_RW)) return EXT2_ET_RO_FILSYS; if (EXT2_HAS_COMPAT_FEATURE(fs->super, EXT2_FEATURE_COMPAT_LAZY_BG)) lazy_flag = 1; inode_nbytes = block_nbytes = 0; block_bitmap = inode_bitmap = 0; if (do_block) { block_bitmap = fs->block_map->bitmap; block_nbytes = EXT2_BLOCKS_PER_GROUP(fs->super) / 8; retval = ext2fs_get_mem(fs->blocksize, &block_buf); if (retval) return retval; memset(block_buf, 0xff, fs->blocksize); } if (do_inode) { inode_bitmap = fs->inode_map->bitmap; inode_nbytes = (size_t) ((EXT2_INODES_PER_GROUP(fs->super)+7) / 8); retval = ext2fs_get_mem(fs->blocksize, &inode_buf); if (retval) return retval; memset(inode_buf, 0xff, fs->blocksize); } for (i = 0; i < fs->group_desc_count; i++) { if (!block_bitmap || !do_block) goto skip_block_bitmap; if (lazy_flag && fs->group_desc[i].bg_flags & EXT2_BG_BLOCK_UNINIT) goto skip_this_block_bitmap; memcpy(block_buf, block_bitmap, block_nbytes); if (i == fs->group_desc_count - 1) { /* Force bitmap padding for the last group */ nbits = ((fs->super->s_blocks_count - fs->super->s_first_data_block) % EXT2_BLOCKS_PER_GROUP(fs->super)); if (nbits) for (j = nbits; j < fs->blocksize * 8; j++) ext2fs_set_bit(j, block_buf); } blk = fs->group_desc[i].bg_block_bitmap; if (blk) {#ifdef EXT2_BIG_ENDIAN_BITMAPS if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) || (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE))) ext2fs_swap_bitmap(fs, block_buf, block_nbytes);#endif retval = io_channel_write_blk(fs->io, blk, 1, block_buf); if (retval) return EXT2_ET_BLOCK_BITMAP_WRITE; } skip_this_block_bitmap: block_bitmap += block_nbytes; skip_block_bitmap: if (!inode_bitmap || !do_inode) continue; if (lazy_flag && fs->group_desc[i].bg_flags & EXT2_BG_INODE_UNINIT) goto skip_this_inode_bitmap; memcpy(inode_buf, inode_bitmap, inode_nbytes); blk = fs->group_desc[i].bg_inode_bitmap; if (blk) {#ifdef EXT2_BIG_ENDIAN_BITMAPS if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) || (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE))) ext2fs_swap_bitmap(fs, inode_buf, inode_nbytes);#endif retval = io_channel_write_blk(fs->io, blk, 1, inode_buf); if (retval) return EXT2_ET_INODE_BITMAP_WRITE; } skip_this_inode_bitmap: inode_bitmap += inode_nbytes; } if (do_block) {//.........这里部分代码省略.........
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:101,
示例7: ext2fs_open2//.........这里部分代码省略......... if (!ext2fs_has_feature_bigalloc(fs->super) && (fs->super->s_log_block_size != fs->super->s_log_cluster_size)) { retval = EXT2_ET_CORRUPT_SUPERBLOCK; goto cleanup; } fs->fragsize = fs->blocksize = EXT2_BLOCK_SIZE(fs->super); if (EXT2_INODE_SIZE(fs->super) < EXT2_GOOD_OLD_INODE_SIZE) { retval = EXT2_ET_CORRUPT_SUPERBLOCK; goto cleanup; } /* Enforce the block group descriptor size */ if (ext2fs_has_feature_64bit(fs->super)) { if (fs->super->s_desc_size < EXT2_MIN_DESC_SIZE_64BIT) { retval = EXT2_ET_BAD_DESC_SIZE; goto cleanup; } } else { if (fs->super->s_desc_size && fs->super->s_desc_size != EXT2_MIN_DESC_SIZE) { retval = EXT2_ET_BAD_DESC_SIZE; goto cleanup; } } fs->cluster_ratio_bits = fs->super->s_log_cluster_size - fs->super->s_log_block_size; if (EXT2_BLOCKS_PER_GROUP(fs->super) != EXT2_CLUSTERS_PER_GROUP(fs->super) << fs->cluster_ratio_bits) { retval = EXT2_ET_CORRUPT_SUPERBLOCK; goto cleanup; } fs->inode_blocks_per_group = ((EXT2_INODES_PER_GROUP(fs->super) * EXT2_INODE_SIZE(fs->super) + EXT2_BLOCK_SIZE(fs->super) - 1) / EXT2_BLOCK_SIZE(fs->super)); if (block_size) { if (block_size != fs->blocksize) { retval = EXT2_ET_UNEXPECTED_BLOCK_SIZE; goto cleanup; } } /* * Set the blocksize to the filesystem's blocksize. */ io_channel_set_blksize(fs->io, fs->blocksize); /* * If this is an external journal device, don't try to read * the group descriptors, because they're not there. */ if (ext2fs_has_feature_journal_dev(fs->super)) { fs->group_desc_count = 0; *ret_fs = fs; return 0; } if (EXT2_INODES_PER_GROUP(fs->super) == 0) { retval = EXT2_ET_CORRUPT_SUPERBLOCK; goto cleanup; } /* Precompute the FS UUID to seed other checksums */ ext2fs_init_csum_seed(fs); /*
开发者ID:MIPS,项目名称:external-e2fsprogs,代码行数:67,
示例8: ext2_new_inode//.........这里部分代码省略......... i = j; gdp = tmp; } } } } } else { /* * Try to place the inode in its parent directory */ i = dir->i_block_group; tmp = get_group_desc (ITOV(dir)->v_mount, i, &bh2); if (tmp->bg_free_inodes_count) gdp = tmp; else { /* * Use a quadratic hash to find a group with a * free inode */ for (j = 1; j < sb->s_groups_count; j <<= 1) { i += j; if (i >= sb->s_groups_count) i -= sb->s_groups_count; tmp = get_group_desc(ITOV(dir)->v_mount,i,&bh2); if (tmp->bg_free_inodes_count) { gdp = tmp; break; } } } if (!gdp) { /* * That failed: try linear search for a free inode */ i = dir->i_block_group + 1; for (j = 2; j < sb->s_groups_count; j++) { if (++i >= sb->s_groups_count) i = 0; tmp = get_group_desc(ITOV(dir)->v_mount,i,&bh2); if (tmp->bg_free_inodes_count) { gdp = tmp; break; } } } } if (!gdp) { unlock_super (DEVVP(dir)); return 0; } bitmap_nr = load_inode_bitmap (ITOV(dir)->v_mount, i); bh = sb->s_inode_bitmap[bitmap_nr]; if ((j = find_first_zero_bit ((unsigned long *) bh->b_data, EXT2_INODES_PER_GROUP(sb))) < EXT2_INODES_PER_GROUP(sb)) { if (set_bit (j, bh->b_data)) { kprintf ( "ext2_new_inode:" "bit already set for inode %d", j); goto repeat; }/* Linux now does the following: mark_buffer_dirty(bh); if (sb->s_flags & MS_SYNCHRONOUS) { ll_rw_block (WRITE, 1, &bh); wait_on_buffer (bh); }*/ mark_buffer_dirty(bh); } else { if (gdp->bg_free_inodes_count != 0) { kprintf ( "ext2_new_inode:" "Free inodes count corrupted in group %d", i); unlock_super (DEVVP(dir)); return 0; } goto repeat; } j += i * EXT2_INODES_PER_GROUP(sb) + 1; if (j < EXT2_FIRST_INO(sb) || j > es->s_inodes_count) { kprintf ( "ext2_new_inode:" "reserved inode or inode > inodes count - " "block_group = %d,inode=%d", i, j); unlock_super (DEVVP(dir)); return 0; } gdp->bg_free_inodes_count--; if (S_ISDIR(mode)) gdp->bg_used_dirs_count++; mark_buffer_dirty(bh2); es->s_free_inodes_count--; /* mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1); */ sb->s_dirt = 1; unlock_super (DEVVP(dir)); return j;}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:101,
示例9: read_bitmapsstatic errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block){ dgrp_t i; char *block_bitmap = 0, *inode_bitmap = 0; char *buf; errcode_t retval; int block_nbytes = (int) EXT2_BLOCKS_PER_GROUP(fs->super) / 8; int inode_nbytes = (int) EXT2_INODES_PER_GROUP(fs->super) / 8; int lazy_flag = 0; blk_t blk; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); fs->write_bitmaps = ext2fs_write_bitmaps; if (EXT2_HAS_COMPAT_FEATURE(fs->super, EXT2_FEATURE_COMPAT_LAZY_BG)) lazy_flag = 1; retval = ext2fs_get_mem(strlen(fs->device_name) + 80, &buf); if (retval) return retval; if (do_block) { if (fs->block_map) ext2fs_free_block_bitmap(fs->block_map); sprintf(buf, "block bitmap for %s", fs->device_name); retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map); if (retval) goto cleanup; block_bitmap = fs->block_map->bitmap; } if (do_inode) { if (fs->inode_map) ext2fs_free_inode_bitmap(fs->inode_map); sprintf(buf, "inode bitmap for %s", fs->device_name); retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map); if (retval) goto cleanup; inode_bitmap = fs->inode_map->bitmap; } ext2fs_free_mem(&buf); if (fs->flags & EXT2_FLAG_IMAGE_FILE) { if (inode_bitmap) { blk = (fs->image_header->offset_inodemap / fs->blocksize); retval = io_channel_read_blk(fs->image_io, blk, -(inode_nbytes * fs->group_desc_count), inode_bitmap); if (retval) goto cleanup; } if (block_bitmap) { blk = (fs->image_header->offset_blockmap / fs->blocksize); retval = io_channel_read_blk(fs->image_io, blk, -(block_nbytes * fs->group_desc_count), block_bitmap); if (retval) goto cleanup; } return 0; } for (i = 0; i < fs->group_desc_count; i++) { if (block_bitmap) { blk = fs->group_desc[i].bg_block_bitmap; if (lazy_flag && fs->group_desc[i].bg_flags & EXT2_BG_BLOCK_UNINIT) blk = 0; if (blk) { retval = io_channel_read_blk(fs->io, blk, -block_nbytes, block_bitmap); if (retval) { retval = EXT2_ET_BLOCK_BITMAP_READ; goto cleanup; }#ifdef EXT2_BIG_ENDIAN_BITMAPS if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) || (fs->flags & EXT2_FLAG_SWAP_BYTES_READ))) ext2fs_swap_bitmap(fs, block_bitmap, block_nbytes);#endif } else memset(block_bitmap, 0xff, block_nbytes); block_bitmap += block_nbytes; } if (inode_bitmap) { blk = fs->group_desc[i].bg_inode_bitmap; if (lazy_flag && fs->group_desc[i].bg_flags & EXT2_BG_INODE_UNINIT) blk = 0; if (blk) { retval = io_channel_read_blk(fs->io, blk, -inode_nbytes, inode_bitmap); if (retval) { retval = EXT2_ET_INODE_BITMAP_READ; goto cleanup; }#ifdef EXT2_BIG_ENDIAN_BITMAPS if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) ||//.........这里部分代码省略.........
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:101,
示例10: ext2_setup_superstatic void ext2_setup_super (struct super_block * sb, struct ext2_super_block * es){#ifdef OS2 if (Errors_Panic) { clear_opt(sb->u.ext2_sb.s_mount_opt, ERRORS_CONT); clear_opt(sb->u.ext2_sb.s_mount_opt, ERRORS_RO); set_opt(sb->u.ext2_sb.s_mount_opt, ERRORS_PANIC); } else { clear_opt(sb->u.ext2_sb.s_mount_opt, ERRORS_PANIC); clear_opt(sb->u.ext2_sb.s_mount_opt, ERRORS_RO); set_opt(sb->u.ext2_sb.s_mount_opt, ERRORS_CONT); }#endif if (es->s_rev_level > EXT2_CURRENT_REV) { printk ("EXT2-fs warning: revision level too high, " "forcing read/only mode/n"); sb->s_flags |= MS_RDONLY; } if (!(sb->s_flags & MS_RDONLY)) { if (!(sb->u.ext2_sb.s_mount_state & EXT2_VALID_FS)) printk ("EXT2-fs warning: mounting unchecked fs, " "running e2fsck is recommended/n"); else if ((sb->u.ext2_sb.s_mount_state & EXT2_ERROR_FS)) printk ("EXT2-fs warning: mounting fs with errors, " "running e2fsck is recommended/n"); else if (es->s_max_mnt_count >= 0 && es->s_mnt_count >= (unsigned short) es->s_max_mnt_count) printk ("EXT2-fs warning: maximal mount count reached, " "running e2fsck is recommended/n"); else if (es->s_checkinterval && (es->s_lastcheck + es->s_checkinterval <= CURRENT_TIME)) printk ("EXT2-fs warning: checktime reached, " "running e2fsck is recommended/n"); es->s_state &= ~EXT2_VALID_FS; if (!es->s_max_mnt_count) es->s_max_mnt_count = EXT2_DFL_MAX_MNT_COUNT;#ifndef OS2 es->s_mnt_count++;#else // // This is to force Linux to autocheck the ext2fs partition "touched" by OS/2 // this autocheck is enabled unless -no_auto_fsck is specified on the IFS cmd // line // if (auto_fsck) { kernel_printf("e2fsck will be forced next time Linux will mount this partition"); es->s_mnt_count = EXT2_DFL_MAX_MNT_COUNT; } else { es->s_mnt_count++; }#endif es->s_mtime = CURRENT_TIME; mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1); sb->s_dirt = 1;#ifndef OS2 // For the moment ..... if (test_opt (sb, DEBUG))#endif printk ("[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, " "bpg=%lu, ipg=%lu, mo=%04lx]/n", EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize, sb->u.ext2_sb.s_frag_size, sb->u.ext2_sb.s_groups_count, EXT2_BLOCKS_PER_GROUP(sb), EXT2_INODES_PER_GROUP(sb), sb->u.ext2_sb.s_mount_opt);#ifndef OS2 // For the moment ..... if (test_opt (sb, CHECK)) {#endif ext2_check_blocks_bitmap (sb); ext2_check_inodes_bitmap (sb);#ifndef OS2 // For the moment ..... }#endif }}
开发者ID:OS2World,项目名称:DRV-ext2,代码行数:77,
示例11: write_bitmapsstatic errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block){ dgrp_t i; unsigned int j; int block_nbytes, inode_nbytes; unsigned int nbits; errcode_t retval; char *block_buf = NULL, *inode_buf = NULL; int csum_flag = 0; blk64_t blk; blk64_t blk_itr = EXT2FS_B2C(fs, fs->super->s_first_data_block); ext2_ino_t ino_itr = 1; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); if (!(fs->flags & EXT2_FLAG_RW)) return EXT2_ET_RO_FILSYS; if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super, EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) csum_flag = 1; inode_nbytes = block_nbytes = 0; if (do_block) { block_nbytes = EXT2_CLUSTERS_PER_GROUP(fs->super) / 8; retval = io_channel_alloc_buf(fs->io, 0, &block_buf); if (retval) goto errout; memset(block_buf, 0xff, fs->blocksize); } if (do_inode) { inode_nbytes = (size_t) ((EXT2_INODES_PER_GROUP(fs->super)+7) / 8); retval = io_channel_alloc_buf(fs->io, 0, &inode_buf); if (retval) goto errout; memset(inode_buf, 0xff, fs->blocksize); } for (i = 0; i < fs->group_desc_count; i++) { if (!do_block) goto skip_block_bitmap; if (csum_flag && ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT) ) goto skip_this_block_bitmap; retval = ext2fs_get_block_bitmap_range2(fs->block_map, blk_itr, block_nbytes << 3, block_buf); if (retval) goto errout; if (i == fs->group_desc_count - 1) { /* Force bitmap padding for the last group */ nbits = EXT2FS_NUM_B2C(fs, ((ext2fs_blocks_count(fs->super) - (__u64) fs->super->s_first_data_block) % (__u64) EXT2_BLOCKS_PER_GROUP(fs->super))); if (nbits) for (j = nbits; j < fs->blocksize * 8; j++) ext2fs_set_bit(j, block_buf); } blk = ext2fs_block_bitmap_loc(fs, i); if (blk) { retval = io_channel_write_blk64(fs->io, blk, 1, block_buf); if (retval) { retval = EXT2_ET_BLOCK_BITMAP_WRITE; goto errout; } } skip_this_block_bitmap: blk_itr += block_nbytes << 3; skip_block_bitmap: if (!do_inode) continue; if (csum_flag && ext2fs_bg_flags_test(fs, i, EXT2_BG_INODE_UNINIT) ) goto skip_this_inode_bitmap; retval = ext2fs_get_inode_bitmap_range2(fs->inode_map, ino_itr, inode_nbytes << 3, inode_buf); if (retval) goto errout; blk = ext2fs_inode_bitmap_loc(fs, i); if (blk) { retval = io_channel_write_blk64(fs->io, blk, 1, inode_buf); if (retval) { retval = EXT2_ET_INODE_BITMAP_WRITE; goto errout; } } skip_this_inode_bitmap: ino_itr += inode_nbytes << 3; }//.........这里部分代码省略.........
开发者ID:csmartin,项目名称:hddtest,代码行数:101,
示例12: ext2fs_read_inode_full/* * Functions to read and write a single inode. */errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode * inode, int bufsize){ blk64_t block_nr; unsigned long group, block, offset; char *ptr; errcode_t retval; unsigned i; int clen, inodes_per_block; io_channel io; int length = EXT2_INODE_SIZE(fs->super); struct ext2_inode_large *iptr; int cache_slot, fail_csum; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); /* Check to see if user has an override function */ if (fs->read_inode && ((bufsize == sizeof(struct ext2_inode)) || (EXT2_INODE_SIZE(fs->super) == sizeof(struct ext2_inode)))) { retval = (fs->read_inode)(fs, ino, inode); if (retval != EXT2_ET_CALLBACK_NOTHANDLED) return retval; } if ((ino == 0) || (ino > fs->super->s_inodes_count)) return EXT2_ET_BAD_INODE_NUM; /* Create inode cache if not present */ if (!fs->icache) { retval = ext2fs_create_inode_cache(fs, 4); if (retval) return retval; } /* Check to see if it's in the inode cache */ for (i = 0; i < fs->icache->cache_size; i++) { if (fs->icache->cache[i].ino == ino) { memcpy(inode, fs->icache->cache[i].inode, (bufsize > length) ? length : bufsize); return 0; } } if (fs->flags & EXT2_FLAG_IMAGE_FILE) { inodes_per_block = fs->blocksize / EXT2_INODE_SIZE(fs->super); block_nr = fs->image_header->offset_inode / fs->blocksize; block_nr += (ino - 1) / inodes_per_block; offset = ((ino - 1) % inodes_per_block) * EXT2_INODE_SIZE(fs->super); io = fs->image_io; } else { group = (ino - 1) / EXT2_INODES_PER_GROUP(fs->super); if (group > fs->group_desc_count) return EXT2_ET_BAD_INODE_NUM; offset = ((ino - 1) % EXT2_INODES_PER_GROUP(fs->super)) * EXT2_INODE_SIZE(fs->super); block = offset >> EXT2_BLOCK_SIZE_BITS(fs->super); if (!ext2fs_inode_table_loc(fs, (unsigned) group)) return EXT2_ET_MISSING_INODE_TABLE; block_nr = ext2fs_inode_table_loc(fs, group) + block; io = fs->io; } offset &= (EXT2_BLOCK_SIZE(fs->super) - 1); cache_slot = (fs->icache->cache_last + 1) % fs->icache->cache_size; iptr = (struct ext2_inode_large *)fs->icache->cache[cache_slot].inode; ptr = (char *) iptr; while (length) { clen = length; if ((offset + length) > fs->blocksize) clen = fs->blocksize - offset; if (block_nr != fs->icache->buffer_blk) { retval = io_channel_read_blk64(io, block_nr, 1, fs->icache->buffer); if (retval) return retval; fs->icache->buffer_blk = block_nr; } memcpy(ptr, ((char *) fs->icache->buffer) + (unsigned) offset, clen); offset = 0; length -= clen; ptr += clen; block_nr++; } length = EXT2_INODE_SIZE(fs->super); /* Verify the inode checksum. */ fail_csum = !ext2fs_inode_csum_verify(fs, ino, iptr);#ifdef WORDS_BIGENDIAN ext2fs_swap_inode_full(fs, (struct ext2_inode_large *) iptr, (struct ext2_inode_large *) iptr, 0, length);#endif//.........这里部分代码省略.........
开发者ID:MIPS,项目名称:external-e2fsprogs,代码行数:101,
示例13: ext2fs_open_inode_scanerrcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks, ext2_inode_scan *ret_scan){ ext2_inode_scan scan; errcode_t retval; errcode_t (*save_get_blocks)(ext2_filsys f, ext2_ino_t ino, blk_t *blocks); EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); /* * If fs->badblocks isn't set, then set it --- since the inode * scanning functions require it. */ if (fs->badblocks == 0) { /* * Temporarly save fs->get_blocks and set it to zero, * for compatibility with old e2fsck's. */ save_get_blocks = fs->get_blocks; fs->get_blocks = 0; retval = ext2fs_read_bb_inode(fs, &fs->badblocks); if (retval && fs->badblocks) { ext2fs_badblocks_list_free(fs->badblocks); fs->badblocks = 0; } fs->get_blocks = save_get_blocks; } retval = ext2fs_get_mem(sizeof(struct ext2_struct_inode_scan), &scan); if (retval) return retval; memset(scan, 0, sizeof(struct ext2_struct_inode_scan)); scan->magic = EXT2_ET_MAGIC_INODE_SCAN; scan->fs = fs; scan->inode_size = EXT2_INODE_SIZE(fs->super); scan->bytes_left = 0; scan->current_group = 0; scan->groups_left = fs->group_desc_count - 1; scan->inode_buffer_blocks = buffer_blocks ? buffer_blocks : EXT2_INODE_SCAN_DEFAULT_BUFFER_BLOCKS; scan->current_block = ext2fs_inode_table_loc(scan->fs, scan->current_group); scan->inodes_left = EXT2_INODES_PER_GROUP(scan->fs->super); scan->blocks_left = scan->fs->inode_blocks_per_group; if (ext2fs_has_group_desc_csum(fs)) { __u32 unused = ext2fs_bg_itable_unused(fs, scan->current_group); if (scan->inodes_left > unused) scan->inodes_left -= unused; else scan->inodes_left = 0; scan->blocks_left = (scan->inodes_left + (fs->blocksize / scan->inode_size - 1)) * scan->inode_size / fs->blocksize; } retval = io_channel_alloc_buf(fs->io, scan->inode_buffer_blocks, &scan->inode_buffer); scan->done_group = 0; scan->done_group_data = 0; scan->bad_block_ptr = 0; if (retval) { ext2fs_free_mem(&scan); return retval; } retval = ext2fs_get_mem(scan->inode_size + scan->inode_buffer_blocks, &scan->temp_buffer); if (retval) { ext2fs_free_mem(&scan->inode_buffer); ext2fs_free_mem(&scan); return retval; } memset(SCAN_BLOCK_STATUS(scan), 0, scan->inode_buffer_blocks); if (scan->fs->badblocks && scan->fs->badblocks->num) scan->scan_flags |= EXT2_SF_CHK_BADBLOCKS; if (ext2fs_has_group_desc_csum(fs)) scan->scan_flags |= EXT2_SF_DO_LAZY; *ret_scan = scan; return 0;}
开发者ID:MIPS,项目名称:external-e2fsprogs,代码行数:80,
示例14: ext2fs_open_inode_scanerrcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks, ext2_inode_scan *ret_scan){ ext2_inode_scan scan; errcode_t retval; errcode_t (*save_get_blocks)(ext2_filsys f, ext2_ino_t ino, blk_t *blocks); EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); /* * If fs->badblocks isn't set, then set it --- since the inode * scanning functions require it. */ if (fs->badblocks == 0) { /* * Temporarly save fs->get_blocks and set it to zero, * for compatibility with old e2fsck's. */ save_get_blocks = fs->get_blocks; fs->get_blocks = 0; retval = ext2fs_read_bb_inode(fs, &fs->badblocks); if (retval && fs->badblocks) { ext2fs_badblocks_list_free(fs->badblocks); fs->badblocks = 0; } fs->get_blocks = save_get_blocks; } retval = ext2fs_get_mem(sizeof(struct ext2_struct_inode_scan), &scan); if (retval) return retval; memset(scan, 0, sizeof(struct ext2_struct_inode_scan)); scan->magic = EXT2_ET_MAGIC_INODE_SCAN; scan->fs = fs; scan->inode_size = EXT2_INODE_SIZE(fs->super); scan->bytes_left = 0; scan->current_group = 0; scan->groups_left = fs->group_desc_count - 1; scan->inode_buffer_blocks = buffer_blocks ? buffer_blocks : 8; scan->current_block = scan->fs-> group_desc[scan->current_group].bg_inode_table; scan->inodes_left = EXT2_INODES_PER_GROUP(scan->fs->super); scan->blocks_left = scan->fs->inode_blocks_per_group; if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super, EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) { scan->inodes_left -= fs->group_desc[scan->current_group].bg_itable_unused; scan->blocks_left = (scan->inodes_left + (fs->blocksize / scan->inode_size - 1)) * scan->inode_size / fs->blocksize; } retval = ext2fs_get_memalign(scan->inode_buffer_blocks * fs->blocksize, fs->blocksize, &scan->inode_buffer); scan->done_group = 0; scan->done_group_data = 0; scan->bad_block_ptr = 0; if (retval) { ext2fs_free_mem(&scan); return retval; } retval = ext2fs_get_mem(scan->inode_size, &scan->temp_buffer); if (retval) { ext2fs_free_mem(&scan->inode_buffer); ext2fs_free_mem(&scan); return retval; } if (scan->fs->badblocks && scan->fs->badblocks->num) scan->scan_flags |= EXT2_SF_CHK_BADBLOCKS; if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super, EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) scan->scan_flags |= EXT2_SF_DO_LAZY; *ret_scan = scan; return 0;}
开发者ID:119,项目名称:aircam-openwrt,代码行数:76,
示例15: ext2_setup_superstatic int ext2_setup_super (struct super_block * sb, struct ext2_super_block * es, int read_only){ int res = 0; struct ext2_sb_info *sbi = EXT2_SB(sb); if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) { printk ("EXT2-fs warning: revision level too high, " "forcing read-only mode/n"); res = MS_RDONLY; } if (read_only) return res; /* PR 28089 - Allow user to turn off a forced fsck in order * to let user to mount a dirty FS RW * Thus if FS is dirty and nocheck is the mount option, then * FS is mounted RW. */ if (!(sbi->s_mount_state & EXT2_VALID_FS)) { if (!test_opt (sb, CHECK)) printk ("EXT2-fs warning: mounting unclean fs with " "errors in RW mode./nRunning e2fsck is strongly urged " "and recommended./n"); else { printk ("EXT2-fs warning: mounting unchecked fs read-only. " "Running e2fsck is recommended before re-mounting read-write./n"); sb->s_flags |= MS_RDONLY; return MS_RDONLY; } } /* PR 28089 - Allow user to turn off a forced fsck in order * to let user to mount a dirty FS RW. * Thus if FS is dirty and nocheck is the mount option, then * FS is mounted RW. */ else if ((sbi->s_mount_state & EXT2_ERROR_FS)) { if (!test_opt (sb, CHECK)) printk ("EXT2-fs warning: mounting unclean fs with " "errors in RW mode./nRunning e2fsck is strongly urged " "and recommended./n"); else { printk ("EXT2-fs warning: mounting unchecked fs read-only. " "Running e2fsck is recommended before re-mounting read-write./n"); sb->s_flags |= MS_RDONLY; return MS_RDONLY; } } else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && le16_to_cpu(es->s_mnt_count) >= (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) { printk ("EXT2-fs warning: maximal mount count reached. Mounting read-only. " "Running e2fsck is recommended before re-mounting read-write./n"); sb->s_flags |= MS_RDONLY; return MS_RDONLY; } else if (le32_to_cpu(es->s_checkinterval) && (le32_to_cpu(es->s_lastcheck) + le32_to_cpu(es->s_checkinterval) <= get_seconds())) { printk ("EXT2-fs warning: checktime reached. Mounting read-only. " "Running e2fsck is recommended before re-mounting read-write./n"); sb->s_flags |= MS_RDONLY; return MS_RDONLY; } if (!le16_to_cpu(es->s_max_mnt_count)) es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT); es->s_mnt_count=cpu_to_le16(le16_to_cpu(es->s_mnt_count) + 1); ext2_write_super(sb); if (test_opt (sb, DEBUG)) printk ("[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, " "bpg=%lu, ipg=%lu, mo=%04lx]/n", EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize, sbi->s_frag_size, sbi->s_groups_count, EXT2_BLOCKS_PER_GROUP(sb), EXT2_INODES_PER_GROUP(sb), sbi->s_mount_opt);#ifdef CONFIG_EXT2_CHECK if (test_opt (sb, CHECK)) { ext2_check_blocks_bitmap (sb); ext2_check_inodes_bitmap (sb); }#endif return res;}
开发者ID:foxsat-hdr,项目名称:linux-kernel,代码行数:84,
示例16: ext2fs_get_next_inode_fullerrcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino, struct ext2_inode *inode, int bufsize){ errcode_t retval; int extra_bytes = 0; int length; struct ext2_inode_large *iptr = (struct ext2_inode_large *)inode; char *iblock_status; unsigned int iblk; EXT2_CHECK_MAGIC(scan, EXT2_ET_MAGIC_INODE_SCAN); length = EXT2_INODE_SIZE(scan->fs->super); iblock_status = SCAN_BLOCK_STATUS(scan); /* * Do we need to start reading a new block group? */ if (scan->inodes_left <= 0) { force_new_group: if (scan->done_group) { retval = (scan->done_group) (scan->fs, scan, scan->current_group, scan->done_group_data); if (retval) return retval; } if (scan->groups_left <= 0) { *ino = 0; return 0; } retval = get_next_blockgroup(scan); if (retval) return retval; } /* * These checks are done outside the above if statement so * they can be done for block group #0. */ if ((scan->scan_flags & EXT2_SF_DO_LAZY) && (ext2fs_bg_flags_test(scan->fs, scan->current_group, EXT2_BG_INODE_UNINIT) )) goto force_new_group; if (scan->inodes_left == 0) goto force_new_group; if (scan->current_block == 0) { if (scan->scan_flags & EXT2_SF_SKIP_MISSING_ITABLE) { goto force_new_group; } else return EXT2_ET_MISSING_INODE_TABLE; } /* * Have we run out of space in the inode buffer? If so, we * need to read in more blocks. */ if (scan->bytes_left < scan->inode_size) { memcpy(scan->temp_buffer, scan->ptr, scan->bytes_left); extra_bytes = scan->bytes_left; retval = get_next_blocks(scan); if (retval) return retval;#if 0 /* * XXX test Need check for used inode somehow. * (Note: this is hard.) */ if (is_empty_scan(scan)) goto force_new_group;#endif } if (bufsize < length) { retval = ext2fs_get_mem(length, &iptr); if (retval) return retval; } retval = 0; iblk = scan->current_inode % EXT2_INODES_PER_GROUP(scan->fs->super) / EXT2_INODES_PER_BLOCK(scan->fs->super) % scan->inode_buffer_blocks; if (extra_bytes) { memcpy(scan->temp_buffer+extra_bytes, scan->ptr, scan->inode_size - extra_bytes); scan->ptr += scan->inode_size - extra_bytes; scan->bytes_left -= scan->inode_size - extra_bytes; /* Verify the inode checksum. */ if (!(iblock_status[iblk] & IBLOCK_STATUS_CSUMS_OK) && !(scan->fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) && !ext2fs_inode_csum_verify(scan->fs, scan->current_inode + 1, (struct ext2_inode_large *)scan->temp_buffer)) retval = EXT2_ET_INODE_CSUM_INVALID;#ifdef WORDS_BIGENDIAN memset(iptr, 0, length); ext2fs_swap_inode_full(scan->fs, (struct ext2_inode_large *) iptr,//.........这里部分代码省略.........
开发者ID:MIPS,项目名称:external-e2fsprogs,代码行数:101,
示例17: list_descstatic void list_desc (ext2_filsys fs){ unsigned long i; blk_t first_block, last_block; blk_t super_blk, old_desc_blk, new_desc_blk; char *block_bitmap=NULL, *inode_bitmap=NULL; int inode_blocks_per_group, old_desc_blocks, reserved_gdt; int block_nbytes, inode_nbytes; int has_super; blk_t blk_itr = fs->super->s_first_data_block; ext2_ino_t ino_itr = 1; block_nbytes = EXT2_BLOCKS_PER_GROUP(fs->super) / 8; inode_nbytes = EXT2_INODES_PER_GROUP(fs->super) / 8; if (fs->block_map) block_bitmap = malloc(block_nbytes); if (fs->inode_map) inode_bitmap = malloc(inode_nbytes); inode_blocks_per_group = ((fs->super->s_inodes_per_group * EXT2_INODE_SIZE(fs->super)) + EXT2_BLOCK_SIZE(fs->super) - 1) / EXT2_BLOCK_SIZE(fs->super); reserved_gdt = fs->super->s_reserved_gdt_blocks; fputc('/n', stdout); first_block = fs->super->s_first_data_block; if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) old_desc_blocks = fs->super->s_first_meta_bg; else old_desc_blocks = fs->desc_blocks; for (i = 0; i < fs->group_desc_count; i++) { first_block = ext2fs_group_first_block(fs, i); last_block = ext2fs_group_last_block(fs, i); ext2fs_super_and_bgd_loc(fs, i, &super_blk, &old_desc_blk, &new_desc_blk, 0); printf (_("Group %lu: (Blocks "), i); print_range(first_block, last_block); fputs(")", stdout); print_bg_opts(fs, i); if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) printf(_(" Checksum 0x%04x, unused inodes %d/n"), fs->group_desc[i].bg_checksum, fs->group_desc[i].bg_itable_unused); has_super = ((i==0) || super_blk); if (has_super) { printf (_(" %s superblock at "), i == 0 ? _("Primary") : _("Backup")); print_number(super_blk); } if (old_desc_blk) { printf(_(", Group descriptors at ")); print_range(old_desc_blk, old_desc_blk + old_desc_blocks - 1); if (reserved_gdt) { printf(_("/n Reserved GDT blocks at ")); print_range(old_desc_blk + old_desc_blocks, old_desc_blk + old_desc_blocks + reserved_gdt - 1); } } else if (new_desc_blk) { fputc(has_super ? ',' : ' ', stdout); printf(_(" Group descriptor at ")); print_number(new_desc_blk); has_super++; } if (has_super) fputc('/n', stdout); fputs(_(" Block bitmap at "), stdout); print_number(fs->group_desc[i].bg_block_bitmap); print_bg_rel_offset(fs, fs->group_desc[i].bg_block_bitmap, 0, first_block, last_block); fputs(_(", Inode bitmap at "), stdout); print_number(fs->group_desc[i].bg_inode_bitmap); print_bg_rel_offset(fs, fs->group_desc[i].bg_inode_bitmap, 0, first_block, last_block); fputs(_("/n Inode table at "), stdout); print_range(fs->group_desc[i].bg_inode_table, fs->group_desc[i].bg_inode_table + inode_blocks_per_group - 1); print_bg_rel_offset(fs, fs->group_desc[i].bg_inode_table, 1, first_block, last_block); printf (_("/n %u free blocks, %u free inodes, " "%u directories%s"), fs->group_desc[i].bg_free_blocks_count, fs->group_desc[i].bg_free_inodes_count, fs->group_desc[i].bg_used_dirs_count, fs->group_desc[i].bg_itable_unused ? "" : "/n"); if (fs->group_desc[i].bg_itable_unused) printf (_(", %u unused inodes/n"), fs->group_desc[i].bg_itable_unused); if (block_bitmap) { fputs(_(" Free blocks: "), stdout); ext2fs_get_block_bitmap_range(fs->block_map, blk_itr, block_nbytes << 3, block_bitmap);//.........这里部分代码省略.........
开发者ID:119,项目名称:aircam-openwrt,代码行数:101,
示例18: ext2fs_write_inode_fullerrcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode * inode, int bufsize){ blk64_t block_nr; unsigned long group, block, offset; errcode_t retval = 0; struct ext2_inode_large *w_inode; char *ptr; unsigned i; int clen; int length = EXT2_INODE_SIZE(fs->super); EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); /* Check to see if user provided an override function */ if (fs->write_inode) { retval = (fs->write_inode)(fs, ino, inode); if (retval != EXT2_ET_CALLBACK_NOTHANDLED) return retval; } if ((ino == 0) || (ino > fs->super->s_inodes_count)) return EXT2_ET_BAD_INODE_NUM; /* Prepare our shadow buffer for read/modify/byteswap/write */ retval = ext2fs_get_mem(length, &w_inode); if (retval) return retval; if (bufsize < length) { int old_flags = fs->flags; fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS; retval = ext2fs_read_inode_full(fs, ino, (struct ext2_inode *)w_inode, length); fs->flags = (old_flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) | (fs->flags & ~EXT2_FLAG_IGNORE_CSUM_ERRORS); if (retval) goto errout; } /* Check to see if the inode cache needs to be updated */ if (fs->icache) { for (i=0; i < fs->icache->cache_size; i++) { if (fs->icache->cache[i].ino == ino) { memcpy(fs->icache->cache[i].inode, inode, (bufsize > length) ? length : bufsize); break; } } } else { retval = ext2fs_create_inode_cache(fs, 4); if (retval) goto errout; } memcpy(w_inode, inode, (bufsize > length) ? length : bufsize); if (!(fs->flags & EXT2_FLAG_RW)) { retval = EXT2_ET_RO_FILSYS; goto errout; }#ifdef WORDS_BIGENDIAN ext2fs_swap_inode_full(fs, w_inode, w_inode, 1, length);#endif retval = ext2fs_inode_csum_set(fs, ino, w_inode); if (retval) goto errout; group = (ino - 1) / EXT2_INODES_PER_GROUP(fs->super); offset = ((ino - 1) % EXT2_INODES_PER_GROUP(fs->super)) * EXT2_INODE_SIZE(fs->super); block = offset >> EXT2_BLOCK_SIZE_BITS(fs->super); if (!ext2fs_inode_table_loc(fs, (unsigned) group)) { retval = EXT2_ET_MISSING_INODE_TABLE; goto errout; } block_nr = ext2fs_inode_table_loc(fs, (unsigned) group) + block; offset &= (EXT2_BLOCK_SIZE(fs->super) - 1); ptr = (char *) w_inode; while (length) { clen = length; if ((offset + length) > fs->blocksize) clen = fs->blocksize - offset; if (fs->icache->buffer_blk != block_nr) { retval = io_channel_read_blk64(fs->io, block_nr, 1, fs->icache->buffer); if (retval) goto errout; fs->icache->buffer_blk = block_nr; } memcpy((char *) fs->icache->buffer + (unsigned) offset, ptr, clen);//.........这里部分代码省略.........
开发者ID:MIPS,项目名称:external-e2fsprogs,代码行数:101,
示例19: ext2fs_read_inode_full/* * Functions to read and write a single inode. */errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode * inode, int bufsize){ blk64_t block_nr; unsigned long group, block, offset; char *ptr; errcode_t retval; int clen, i, inodes_per_block, length; io_channel io; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); /* Check to see if user has an override function */ if (fs->read_inode && ((bufsize == sizeof(struct ext2_inode)) || (EXT2_INODE_SIZE(fs->super) == sizeof(struct ext2_inode)))) { retval = (fs->read_inode)(fs, ino, inode); if (retval != EXT2_ET_CALLBACK_NOTHANDLED) return retval; } if ((ino == 0) || (ino > fs->super->s_inodes_count)) return EXT2_ET_BAD_INODE_NUM; /* Create inode cache if not present */ if (!fs->icache) { retval = create_icache(fs); if (retval) return retval; } /* Check to see if it's in the inode cache */ if (bufsize == sizeof(struct ext2_inode)) { /* only old good inode can be retrieved from the cache */ for (i=0; i < fs->icache->cache_size; i++) { if (fs->icache->cache[i].ino == ino) { *inode = fs->icache->cache[i].inode; return 0; } } } if (fs->flags & EXT2_FLAG_IMAGE_FILE) { inodes_per_block = fs->blocksize / EXT2_INODE_SIZE(fs->super); block_nr = fs->image_header->offset_inode / fs->blocksize; block_nr += (ino - 1) / inodes_per_block; offset = ((ino - 1) % inodes_per_block) * EXT2_INODE_SIZE(fs->super); io = fs->image_io; } else { group = (ino - 1) / EXT2_INODES_PER_GROUP(fs->super); if (group > fs->group_desc_count) return EXT2_ET_BAD_INODE_NUM; offset = ((ino - 1) % EXT2_INODES_PER_GROUP(fs->super)) * EXT2_INODE_SIZE(fs->super); block = offset >> EXT2_BLOCK_SIZE_BITS(fs->super); if (!ext2fs_inode_table_loc(fs, (unsigned) group)) return EXT2_ET_MISSING_INODE_TABLE; block_nr = ext2fs_inode_table_loc(fs, group) + block; io = fs->io; } offset &= (EXT2_BLOCK_SIZE(fs->super) - 1); length = EXT2_INODE_SIZE(fs->super); if (bufsize < length) length = bufsize; ptr = (char *) inode; while (length) { clen = length; if ((offset + length) > fs->blocksize) clen = fs->blocksize - offset; if (block_nr != fs->icache->buffer_blk) { retval = io_channel_read_blk64(io, block_nr, 1, fs->icache->buffer); if (retval) return retval; fs->icache->buffer_blk = block_nr; } memcpy(ptr, ((char *) fs->icache->buffer) + (unsigned) offset, clen); offset = 0; length -= clen; ptr += clen; block_nr++; }#ifdef WORDS_BIGENDIAN ext2fs_swap_inode_full(fs, (struct ext2_inode_large *) inode, (struct ext2_inode_large *) inode, 0, bufsize);#endif /* Update the inode cache */ fs->icache->cache_last = (fs->icache->cache_last + 1) % fs->icache->cache_size; fs->icache->cache[fs->icache->cache_last].ino = ino;//.........这里部分代码省略.........
开发者ID:keyu-lai,项目名称:Geo-tagged-Filesystem,代码行数:101,
示例20: read_bitmapsstatic errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block){ dgrp_t i; char *block_bitmap = 0, *inode_bitmap = 0; char *buf; errcode_t retval; int block_nbytes = EXT2_CLUSTERS_PER_GROUP(fs->super) / 8; int inode_nbytes = EXT2_INODES_PER_GROUP(fs->super) / 8; int csum_flag = 0; unsigned int cnt; blk64_t blk; blk64_t blk_itr = EXT2FS_B2C(fs, fs->super->s_first_data_block); blk64_t blk_cnt; ext2_ino_t ino_itr = 1; ext2_ino_t ino_cnt; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); if ((block_nbytes > fs->blocksize) || (inode_nbytes > fs->blocksize)) return EXT2_ET_CORRUPT_SUPERBLOCK; fs->write_bitmaps = ext2fs_write_bitmaps; if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super, EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) csum_flag = 1; retval = ext2fs_get_mem(strlen(fs->device_name) + 80, &buf); if (retval) return retval; if (do_block) { if (fs->block_map) ext2fs_free_block_bitmap(fs->block_map); strcpy(buf, "block bitmap for "); strcat(buf, fs->device_name); retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map); if (retval) goto cleanup; retval = io_channel_alloc_buf(fs->io, 0, &block_bitmap); if (retval) goto cleanup; } else block_nbytes = 0; if (do_inode) { if (fs->inode_map) ext2fs_free_inode_bitmap(fs->inode_map); strcpy(buf, "inode bitmap for "); strcat(buf, fs->device_name); retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map); if (retval) goto cleanup; retval = io_channel_alloc_buf(fs->io, 0, &inode_bitmap); if (retval) goto cleanup; } else inode_nbytes = 0; ext2fs_free_mem(&buf); if (fs->flags & EXT2_FLAG_IMAGE_FILE) { blk = (fs->image_header->offset_inodemap / fs->blocksize); ino_cnt = fs->super->s_inodes_count; while (inode_nbytes > 0) { retval = io_channel_read_blk64(fs->image_io, blk++, 1, inode_bitmap); if (retval) goto cleanup; cnt = fs->blocksize << 3; if (cnt > ino_cnt) cnt = ino_cnt; retval = ext2fs_set_inode_bitmap_range2(fs->inode_map, ino_itr, cnt, inode_bitmap); if (retval) goto cleanup; ino_itr += fs->blocksize << 3; ino_cnt -= fs->blocksize << 3; inode_nbytes -= fs->blocksize; } blk = (fs->image_header->offset_blockmap / fs->blocksize); blk_cnt = (blk64_t)EXT2_CLUSTERS_PER_GROUP(fs->super) * fs->group_desc_count; while (block_nbytes > 0) { retval = io_channel_read_blk64(fs->image_io, blk++, 1, block_bitmap); if (retval) goto cleanup; cnt = fs->blocksize << 3; if (cnt > blk_cnt) cnt = blk_cnt; retval = ext2fs_set_block_bitmap_range2(fs->block_map, blk_itr, cnt, block_bitmap); if (retval) goto cleanup; blk_itr += fs->blocksize << 3; blk_cnt -= fs->blocksize << 3; block_nbytes -= fs->blocksize; } goto success_cleanup; }//.........这里部分代码省略.........
开发者ID:csmartin,项目名称:hddtest,代码行数:101,
示例21: ext2fs_write_inode_fullerrcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode * inode, int bufsize){ blk64_t block_nr; unsigned long group, block, offset; errcode_t retval = 0; struct ext2_inode_large temp_inode, *w_inode; char *ptr; int clen, i, length; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); /* Check to see if user provided an override function */ if (fs->write_inode) { retval = (fs->write_inode)(fs, ino, inode); if (retval != EXT2_ET_CALLBACK_NOTHANDLED) return retval; } /* Check to see if the inode cache needs to be updated */ if (fs->icache) { for (i=0; i < fs->icache->cache_size; i++) { if (fs->icache->cache[i].ino == ino) { fs->icache->cache[i].inode = *inode; break; } } } else { retval = create_icache(fs); if (retval) return retval; } if (!(fs->flags & EXT2_FLAG_RW)) return EXT2_ET_RO_FILSYS; if ((ino == 0) || (ino > fs->super->s_inodes_count)) return EXT2_ET_BAD_INODE_NUM; length = bufsize; if (length < EXT2_INODE_SIZE(fs->super)) length = EXT2_INODE_SIZE(fs->super); if (length > (int) sizeof(struct ext2_inode_large)) { w_inode = malloc(length); if (!w_inode) { retval = ENOMEM; goto errout; } } else w_inode = &temp_inode; memset(w_inode, 0, length);#ifdef WORDS_BIGENDIAN ext2fs_swap_inode_full(fs, w_inode, (struct ext2_inode_large *) inode, 1, bufsize);#else memcpy(w_inode, inode, bufsize);#endif group = (ino - 1) / EXT2_INODES_PER_GROUP(fs->super); offset = ((ino - 1) % EXT2_INODES_PER_GROUP(fs->super)) * EXT2_INODE_SIZE(fs->super); block = offset >> EXT2_BLOCK_SIZE_BITS(fs->super); if (!ext2fs_inode_table_loc(fs, (unsigned) group)) { retval = EXT2_ET_MISSING_INODE_TABLE; goto errout; } block_nr = ext2fs_inode_table_loc(fs, (unsigned) group) + block; offset &= (EXT2_BLOCK_SIZE(fs->super) - 1); length = EXT2_INODE_SIZE(fs->super); if (length > bufsize) length = bufsize; ptr = (char *) w_inode; while (length) { clen = length; if ((offset + length) > fs->blocksize) clen = fs->blocksize - offset; if (fs->icache->buffer_blk != block_nr) { retval = io_channel_read_blk64(fs->io, block_nr, 1, fs->icache->buffer); if (retval) goto errout; fs->icache->buffer_blk = block_nr; } memcpy((char *) fs->icache->buffer + (unsigned) offset, ptr, clen); retval = io_channel_write_blk64(fs->io, block_nr, 1, fs->icache->buffer); if (retval) goto errout;//.........这里部分代码省略.........
开发者ID:keyu-lai,项目名称:Geo-tagged-Filesystem,代码行数:101,
示例22: list_descstatic void list_desc (ext2_filsys fs){ unsigned long i; blk64_t first_block, last_block; blk64_t super_blk, old_desc_blk, new_desc_blk; char *block_bitmap=NULL, *inode_bitmap=NULL; const char *units = _("blocks"); int inode_blocks_per_group, old_desc_blocks, reserved_gdt; int block_nbytes, inode_nbytes; int has_super; blk64_t blk_itr = EXT2FS_B2C(fs, fs->super->s_first_data_block); ext2_ino_t ino_itr = 1; errcode_t retval; if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super, EXT4_FEATURE_RO_COMPAT_BIGALLOC)) units = _("clusters"); block_nbytes = EXT2_CLUSTERS_PER_GROUP(fs->super) / 8; inode_nbytes = EXT2_INODES_PER_GROUP(fs->super) / 8; if (fs->block_map) block_bitmap = malloc(block_nbytes); if (fs->inode_map) inode_bitmap = malloc(inode_nbytes); inode_blocks_per_group = ((fs->super->s_inodes_per_group * EXT2_INODE_SIZE(fs->super)) + EXT2_BLOCK_SIZE(fs->super) - 1) / EXT2_BLOCK_SIZE(fs->super); reserved_gdt = fs->super->s_reserved_gdt_blocks; fputc('/n', stdout); first_block = fs->super->s_first_data_block; if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) old_desc_blocks = fs->super->s_first_meta_bg; else old_desc_blocks = fs->desc_blocks; for (i = 0; i < fs->group_desc_count; i++) { first_block = ext2fs_group_first_block2(fs, i); last_block = ext2fs_group_last_block2(fs, i); ext2fs_super_and_bgd_loc2(fs, i, &super_blk, &old_desc_blk, &new_desc_blk, 0); printf (_("Group %lu: (Blocks "), i); print_range(first_block, last_block); fputs(")", stdout); print_bg_opts(fs, i); if (ext2fs_has_group_desc_csum(fs)) { unsigned csum = ext2fs_bg_checksum(fs, i); unsigned exp_csum = ext2fs_group_desc_csum(fs, i); printf(_(" Checksum 0x%04x"), csum); if (csum != exp_csum) printf(_(" (EXPECTED 0x%04x)"), exp_csum); printf(_(", unused inodes %u/n"), ext2fs_bg_itable_unused(fs, i)); } has_super = ((i==0) || super_blk); if (has_super) { printf (_(" %s superblock at "), i == 0 ? _("Primary") : _("Backup")); print_number(super_blk); } if (old_desc_blk) { printf("%s", _(", Group descriptors at ")); print_range(old_desc_blk, old_desc_blk + old_desc_blocks - 1); if (reserved_gdt) { printf("%s", _("/n Reserved GDT blocks at ")); print_range(old_desc_blk + old_desc_blocks, old_desc_blk + old_desc_blocks + reserved_gdt - 1); } } else if (new_desc_blk) { fputc(has_super ? ',' : ' ', stdout); printf("%s", _(" Group descriptor at ")); print_number(new_desc_blk); has_super++; } if (has_super) fputc('/n', stdout); fputs(_(" Block bitmap at "), stdout); print_number(ext2fs_block_bitmap_loc(fs, i)); print_bg_rel_offset(fs, ext2fs_block_bitmap_loc(fs, i), 0, first_block, last_block); if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) printf(_(", csum 0x%08x"), ext2fs_block_bitmap_checksum(fs, i)); fputs(_(", Inode bitmap at "), stdout); print_number(ext2fs_inode_bitmap_loc(fs, i)); print_bg_rel_offset(fs, ext2fs_inode_bitmap_loc(fs, i), 0, first_block, last_block); if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) printf(_(", csum 0x%08x"), ext2fs_inode_bitmap_checksum(fs, i)); fputs(_("/n Inode table at "), stdout); print_range(ext2fs_inode_table_loc(fs, i),//.........这里部分代码省略.........
开发者ID:Gwinel,项目名称:e2fsprogs,代码行数:101,
示例23: read_bitmapsstatic errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block){ dgrp_t i; char *block_bitmap = 0, *inode_bitmap = 0; char *buf; errcode_t retval; int block_nbytes = EXT2_CLUSTERS_PER_GROUP(fs->super) / 8; int inode_nbytes = EXT2_INODES_PER_GROUP(fs->super) / 8; int csum_flag; unsigned int cnt; blk64_t blk; blk64_t blk_itr = EXT2FS_B2C(fs, fs->super->s_first_data_block); blk64_t blk_cnt; ext2_ino_t ino_itr = 1; ext2_ino_t ino_cnt; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); if ((block_nbytes > (int) fs->blocksize) || (inode_nbytes > (int) fs->blocksize)) return EXT2_ET_CORRUPT_SUPERBLOCK; fs->write_bitmaps = ext2fs_write_bitmaps; csum_flag = ext2fs_has_group_desc_csum(fs); retval = ext2fs_get_mem(strlen(fs->device_name) + 80, &buf); if (retval) return retval; if (do_block) { if (fs->block_map) ext2fs_free_block_bitmap(fs->block_map); strcpy(buf, "block bitmap for "); strcat(buf, fs->device_name); retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map); if (retval) goto cleanup; retval = io_channel_alloc_buf(fs->io, 0, &block_bitmap); if (retval) goto cleanup; } else block_nbytes = 0; if (do_inode) { if (fs->inode_map) ext2fs_free_inode_bitmap(fs->inode_map); strcpy(buf, "inode bitmap for "); strcat(buf, fs->device_name); retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map); if (retval) goto cleanup; retval = io_channel_alloc_buf(fs->io, 0, &inode_bitmap); if (retval) goto cleanup; } else inode_nbytes = 0; ext2fs_free_mem(&buf); if (fs->flags & EXT2_FLAG_IMAGE_FILE) { blk = (ext2fs_le32_to_cpu(fs->image_header->offset_inodemap) / fs->blocksize); ino_cnt = fs->super->s_inodes_count; while (inode_bitmap && ino_cnt > 0) { retval = io_channel_read_blk64(fs->image_io, blk++, 1, inode_bitmap); if (retval) goto cleanup; cnt = fs->blocksize << 3; if (cnt > ino_cnt) cnt = ino_cnt; retval = ext2fs_set_inode_bitmap_range2(fs->inode_map, ino_itr, cnt, inode_bitmap); if (retval) goto cleanup; ino_itr += cnt; ino_cnt -= cnt; } blk = (ext2fs_le32_to_cpu(fs->image_header->offset_blockmap) / fs->blocksize); blk_cnt = EXT2_GROUPS_TO_CLUSTERS(fs->super, fs->group_desc_count); while (block_bitmap && blk_cnt > 0) { retval = io_channel_read_blk64(fs->image_io, blk++, 1, block_bitmap); if (retval) goto cleanup; cnt = fs->blocksize << 3; if (cnt > blk_cnt) cnt = blk_cnt; retval = ext2fs_set_block_bitmap_range2(fs->block_map, blk_itr, cnt, block_bitmap); if (retval) goto cleanup; blk_itr += cnt; blk_cnt -= cnt; } goto success_cleanup; } for (i = 0; i < fs->group_desc_count; i++) { if (block_bitmap) { blk = ext2fs_block_bitmap_loc(fs, i);//.........这里部分代码省略.........
开发者ID:JaedsonSerafim,项目名称:rufus,代码行数:101,
注:本文中的EXT2_INODES_PER_GROUP函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ EXT2_SB函数代码示例 C++ EXT2_I函数代码示例 |