本文整理汇总了C++中io_manager类的典型用法代码示例。如果您正苦于以下问题:C++ io_manager类的具体用法?C++ io_manager怎么用?C++ io_manager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了io_manager类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: test_open
static errcode_t test_open(const char *name, int flags, io_channel *channel)
{
io_channel io = NULL;
struct test_private_data *data = NULL;
errcode_t retval;
if (name == 0)
return EXT2_ET_BAD_DEVICE_NAME;
retval = ext2fs_get_mem(sizeof(struct struct_io_channel),
(void **) &io);
if (retval)
return retval;
memset(io, 0, sizeof(struct struct_io_channel));
io->magic = EXT2_ET_MAGIC_IO_CHANNEL;
retval = ext2fs_get_mem(sizeof(struct test_private_data),
(void **) &data);
if (retval) {
retval = EXT2_ET_NO_MEMORY;
goto cleanup;
}
io->manager = test_io_manager;
retval = ext2fs_get_mem(strlen(name)+1, (void **) &io->name);
if (retval)
goto cleanup;
strcpy(io->name, name);
io->private_data = data;
io->block_size = 1024;
io->read_error = 0;
io->write_error = 0;
io->refcount = 1;
memset(data, 0, sizeof(struct test_private_data));
data->magic = EXT2_ET_MAGIC_TEST_IO_CHANNEL;
if (test_io_backing_manager) {
retval = test_io_backing_manager->open(name, flags,
&data->real);
if (retval)
goto cleanup;
} else
data->real = 0;
data->read_blk = test_io_cb_read_blk;
data->write_blk = test_io_cb_write_blk;
data->set_blksize = test_io_cb_set_blksize;
data->write_byte = test_io_cb_write_byte;
*channel = io;
return 0;
cleanup:
if (io)
ext2fs_free_mem((void **) &io);
if (data)
ext2fs_free_mem((void **) &data);
return retval;
}
开发者ID:DentonGentry,项目名称:gfiber-gfrg100,代码行数:56,代码来源:test_io.c
示例2: test_open
static errcode_t test_open(const char *name, int flags, io_channel *channel)
{
io_channel io = NULL;
struct test_private_data *data = NULL;
errcode_t retval;
char *value;
if (name == 0)
return EXT2_ET_BAD_DEVICE_NAME;
retval = ext2fs_get_mem(sizeof(struct struct_io_channel), &io);
if (retval)
return retval;
memset(io, 0, sizeof(struct struct_io_channel));
io->magic = EXT2_ET_MAGIC_IO_CHANNEL;
retval = ext2fs_get_mem(sizeof(struct test_private_data), &data);
if (retval) {
retval = EXT2_ET_NO_MEMORY;
goto cleanup;
}
io->manager = test_io_manager;
retval = ext2fs_get_mem(strlen(name)+1, &io->name);
if (retval)
goto cleanup;
strcpy(io->name, name);
io->private_data = data;
io->block_size = 1024;
io->read_error = 0;
io->write_error = 0;
io->refcount = 1;
memset(data, 0, sizeof(struct test_private_data));
data->magic = EXT2_ET_MAGIC_TEST_IO_CHANNEL;
if (test_io_backing_manager) {
retval = test_io_backing_manager->open(name, flags,
&data->real);
if (retval)
goto cleanup;
} else
data->real = 0;
data->read_blk = test_io_cb_read_blk;
data->write_blk = test_io_cb_write_blk;
data->set_blksize = test_io_cb_set_blksize;
data->write_byte = test_io_cb_write_byte;
data->read_blk64 = test_io_cb_read_blk64;
data->write_blk64 = test_io_cb_write_blk64;
data->outfile = NULL;
if ((value = safe_getenv("TEST_IO_LOGFILE")) != NULL)
data->outfile = fopen(value, "w");
if (!data->outfile)
data->outfile = stderr;
data->flags = 0;
if ((value = safe_getenv("TEST_IO_FLAGS")) != NULL)
data->flags = strtoul(value, NULL, 0);
data->block = 0;
if ((value = safe_getenv("TEST_IO_BLOCK")) != NULL)
data->block = strtoul(value, NULL, 0);
data->read_abort_count = 0;
if ((value = safe_getenv("TEST_IO_READ_ABORT")) != NULL)
data->read_abort_count = strtoul(value, NULL, 0);
data->write_abort_count = 0;
if ((value = safe_getenv("TEST_IO_WRITE_ABORT")) != NULL)
data->write_abort_count = strtoul(value, NULL, 0);
*channel = io;
return 0;
cleanup:
if (io)
ext2fs_free_mem(&io);
if (data)
ext2fs_free_mem(&data);
return retval;
}
开发者ID:119,项目名称:aircam-openwrt,代码行数:79,代码来源:test_io.c
示例3: get_backup_sb
blk64_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name,
io_manager manager)
{
struct ext2_super_block *sb;
io_channel io = NULL;
void *buf = NULL;
int blocksize;
blk64_t superblock, ret_sb = 8193;
if (fs && fs->super) {
ret_sb = (fs->super->s_blocks_per_group +
fs->super->s_first_data_block);
if (ctx) {
ctx->superblock = ret_sb;
ctx->blocksize = fs->blocksize;
}
return ret_sb;
}
if (ctx) {
if (ctx->blocksize) {
ret_sb = ctx->blocksize * 8;
if (ctx->blocksize == 1024)
ret_sb++;
ctx->superblock = ret_sb;
return ret_sb;
}
ctx->superblock = ret_sb;
ctx->blocksize = 1024;
}
if (!name || !manager)
goto cleanup;
if (manager->open(name, 0, &io) != 0)
goto cleanup;
if (ext2fs_get_mem(SUPERBLOCK_SIZE, &buf))
goto cleanup;
sb = (struct ext2_super_block *) buf;
for (blocksize = EXT2_MIN_BLOCK_SIZE;
blocksize <= EXT2_MAX_BLOCK_SIZE ; blocksize *= 2) {
superblock = blocksize*8;
if (blocksize == 1024)
superblock++;
io_channel_set_blksize(io, blocksize);
if (io_channel_read_blk64(io, superblock,
-SUPERBLOCK_SIZE, buf))
continue;
#ifdef WORDS_BIGENDIAN
if (sb->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC))
ext2fs_swap_super(sb);
#endif
if ((sb->s_magic == EXT2_SUPER_MAGIC) &&
(EXT2_BLOCK_SIZE(sb) == blocksize)) {
ret_sb = superblock;
if (ctx) {
ctx->superblock = superblock;
ctx->blocksize = blocksize;
}
break;
}
}
cleanup:
if (io)
io_channel_close(io);
if (buf)
ext2fs_free_mem(&buf);
return (ret_sb);
}
开发者ID:guaneryu,项目名称:e2fsprogs,代码行数:72,代码来源:util.c
示例4: ext2fs_open2
/*
* Note: if superblock is non-zero, block-size must also be non-zero.
* Superblock and block_size can be zero to use the default size.
*
* Valid flags for ext2fs_open()
*
* EXT2_FLAG_RW - Open the filesystem for read/write.
* EXT2_FLAG_FORCE - Open the filesystem even if some of the
* features aren't supported.
* EXT2_FLAG_JOURNAL_DEV_OK - Open an ext3 journal device
* EXT2_FLAG_SKIP_MMP - Open without multi-mount protection check.
* EXT2_FLAG_64BITS - Allow 64-bit bitfields (needed for large
* filesystems)
*/
errcode_t ext2fs_open2(const char *name, const char *io_options,
int flags, int superblock,
unsigned int block_size, io_manager manager,
ext2_filsys *ret_fs)
{
ext2_filsys fs;
errcode_t retval;
unsigned long i, first_meta_bg;
__u32 features;
unsigned int blocks_per_group, io_flags;
blk64_t group_block, blk;
char *dest, *cp;
int group_zero_adjust = 0;
#ifdef WORDS_BIGENDIAN
unsigned int groups_per_block;
struct ext2_group_desc *gdp;
int j;
#endif
char *time_env;
EXT2_CHECK_MAGIC(manager, EXT2_ET_MAGIC_IO_MANAGER);
retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs);
if (retval)
return retval;
memset(fs, 0, sizeof(struct struct_ext2_filsys));
fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS;
fs->flags = flags;
/* don't overwrite sb backups unless flag is explicitly cleared */
fs->flags |= EXT2_FLAG_MASTER_SB_ONLY;
fs->umask = 022;
time_env = getenv("E2FSPROGS_FAKE_TIME");
if (time_env)
fs->now = strtoul(time_env, NULL, 0);
retval = ext2fs_get_mem(strlen(name)+1, &fs->device_name);
if (retval)
goto cleanup;
strcpy(fs->device_name, name);
cp = strchr(fs->device_name, '?');
if (!io_options && cp) {
*cp++ = 0;
io_options = cp;
}
io_flags = 0;
if (flags & EXT2_FLAG_RW)
io_flags |= IO_FLAG_RW;
if (flags & EXT2_FLAG_EXCLUSIVE)
io_flags |= IO_FLAG_EXCLUSIVE;
if (flags & EXT2_FLAG_DIRECT_IO)
io_flags |= IO_FLAG_DIRECT_IO;
retval = manager->open(fs->device_name, io_flags, &fs->io);
if (retval)
goto cleanup;
if (io_options &&
(retval = io_channel_set_options(fs->io, io_options)))
goto cleanup;
fs->image_io = fs->io;
fs->io->app_data = fs;
retval = io_channel_alloc_buf(fs->io, -SUPERBLOCK_SIZE, &fs->super);
if (retval)
goto cleanup;
if (flags & EXT2_FLAG_IMAGE_FILE) {
retval = ext2fs_get_mem(sizeof(struct ext2_image_hdr),
&fs->image_header);
if (retval)
goto cleanup;
retval = io_channel_read_blk(fs->io, 0,
-(int)sizeof(struct ext2_image_hdr),
fs->image_header);
if (retval)
goto cleanup;
if (fs->image_header->magic_number != EXT2_ET_MAGIC_E2IMAGE)
return EXT2_ET_MAGIC_E2IMAGE;
superblock = 1;
block_size = fs->image_header->fs_blocksize;
}
/*
* If the user specifies a specific block # for the
* superblock, then he/she must also specify the block size!
* Otherwise, read the master superblock located at offset
* SUPERBLOCK_OFFSET from the start of the partition.
//.........这里部分代码省略.........
开发者ID:MIPS,项目名称:external-e2fsprogs,代码行数:101,代码来源:openfs.c
示例5: ext2fs_initialize
errcode_t ext2fs_initialize(const char *name, int flags,
struct ext2_super_block *param,
io_manager manager, ext2_filsys *ret_fs)
{
ext2_filsys fs;
errcode_t retval;
struct ext2_super_block *super;
int frags_per_block;
unsigned int rem;
unsigned int overhead = 0;
unsigned int ipg;
dgrp_t i;
blk_t numblocks;
int rsv_gdt;
int io_flags;
char *buf;
char c;
if (!param || !param->s_blocks_count)
return EXT2_ET_INVALID_ARGUMENT;
retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs);
if (retval)
return retval;
memset(fs, 0, sizeof(struct struct_ext2_filsys));
fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS;
fs->flags = flags | EXT2_FLAG_RW;
fs->umask = 022;
#ifdef WORDS_BIGENDIAN
fs->flags |= EXT2_FLAG_SWAP_BYTES;
#endif
io_flags = IO_FLAG_RW;
if (flags & EXT2_FLAG_EXCLUSIVE)
io_flags |= IO_FLAG_EXCLUSIVE;
retval = manager->open(name, io_flags, &fs->io);
if (retval)
goto cleanup;
fs->image_io = fs->io;
fs->io->app_data = fs;
retval = ext2fs_get_mem(strlen(name)+1, &fs->device_name);
if (retval)
goto cleanup;
strcpy(fs->device_name, name);
retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &super);
if (retval)
goto cleanup;
fs->super = super;
memset(super, 0, SUPERBLOCK_SIZE);
#define set_field(field, default) (super->field = param->field ? \
param->field : (default))
super->s_magic = EXT2_SUPER_MAGIC;
super->s_state = EXT2_VALID_FS;
set_field(s_log_block_size, 0); /* default blocksize: 1024 bytes */
set_field(s_log_frag_size, 0); /* default fragsize: 1024 bytes */
set_field(s_first_data_block, super->s_log_block_size ? 0 : 1);
set_field(s_max_mnt_count, EXT2_DFL_MAX_MNT_COUNT);
set_field(s_errors, EXT2_ERRORS_DEFAULT);
set_field(s_feature_compat, 0);
set_field(s_feature_incompat, 0);
set_field(s_feature_ro_compat, 0);
set_field(s_first_meta_bg, 0);
if (super->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP) {
retval = EXT2_ET_UNSUPP_FEATURE;
goto cleanup;
}
if (super->s_feature_ro_compat & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP) {
retval = EXT2_ET_RO_UNSUPP_FEATURE;
goto cleanup;
}
set_field(s_rev_level, EXT2_GOOD_OLD_REV);
if (super->s_rev_level >= EXT2_DYNAMIC_REV) {
set_field(s_first_ino, EXT2_GOOD_OLD_FIRST_INO);
set_field(s_inode_size, EXT2_GOOD_OLD_INODE_SIZE);
}
set_field(s_checkinterval, EXT2_DFL_CHECKINTERVAL);
super->s_mkfs_time = super->s_lastcheck = fs->now ? fs->now : time(NULL);
super->s_creator_os = CREATOR_OS;
fs->blocksize = EXT2_BLOCK_SIZE(super);
fs->fragsize = EXT2_FRAG_SIZE(super);
frags_per_block = fs->blocksize / fs->fragsize;
/* default: (fs->blocksize*8) blocks/group, up to 2^16 (GDT limit) */
set_field(s_blocks_per_group, fs->blocksize * 8);
if (super->s_blocks_per_group > EXT2_MAX_BLOCKS_PER_GROUP(super))
super->s_blocks_per_group = EXT2_MAX_BLOCKS_PER_GROUP(super);
super->s_frags_per_group = super->s_blocks_per_group * frags_per_block;
super->s_blocks_count = param->s_blocks_count;
super->s_r_blocks_count = param->s_r_blocks_count;
if (super->s_r_blocks_count >= param->s_blocks_count) {
//.........这里部分代码省略.........
开发者ID:mmeeks,项目名称:ext2tools,代码行数:101,代码来源:initialize.c
示例6: ext2fs_open2
/*
* Note: if superblock is non-zero, block-size must also be non-zero.
* Superblock and block_size can be zero to use the default size.
*
* Valid flags for ext2fs_open()
*
* EXT2_FLAG_RW - Open the filesystem for read/write.
* EXT2_FLAG_FORCE - Open the filesystem even if some of the
* features aren't supported.
* EXT2_FLAG_JOURNAL_DEV_OK - Open an ext3 journal device
*/
errcode_t ext2fs_open2(const char *name, const char *io_options,
int flags, int superblock,
unsigned int block_size, io_manager manager,
ext2_filsys *ret_fs)
{
ext2_filsys fs;
errcode_t retval;
unsigned long i;
int groups_per_block, blocks_per_group;
blk_t group_block, blk;
char *dest, *cp;
#ifdef EXT2FS_ENABLE_SWAPFS
int j;
struct ext2_group_desc *gdp;
#endif
EXT2_CHECK_MAGIC(manager, EXT2_ET_MAGIC_IO_MANAGER);
retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs);
if (retval)
return retval;
memset(fs, 0, sizeof(struct struct_ext2_filsys));
fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS;
fs->flags = flags;
fs->umask = 022;
retval = ext2fs_get_mem(strlen(name)+1, &fs->device_name);
if (retval)
goto cleanup;
strcpy(fs->device_name, name);
cp = strchr(fs->device_name, '?');
if (!io_options && cp) {
*cp++ = 0;
io_options = cp;
}
retval = manager->open(fs->device_name,
(flags & EXT2_FLAG_RW) ? IO_FLAG_RW : 0,
&fs->io);
if (retval)
goto cleanup;
if (io_options &&
(retval = io_channel_set_options(fs->io, io_options)))
goto cleanup;
fs->image_io = fs->io;
fs->io->app_data = fs;
retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &fs->super);
if (retval)
goto cleanup;
if (flags & EXT2_FLAG_IMAGE_FILE) {
retval = ext2fs_get_mem(sizeof(struct ext2_image_hdr),
&fs->image_header);
if (retval)
goto cleanup;
retval = io_channel_read_blk(fs->io, 0,
-(int)sizeof(struct ext2_image_hdr),
fs->image_header);
if (retval)
goto cleanup;
if (fs->image_header->magic_number != EXT2_ET_MAGIC_E2IMAGE)
return EXT2_ET_MAGIC_E2IMAGE;
superblock = 1;
block_size = fs->image_header->fs_blocksize;
}
/*
* If the user specifies a specific block # for the
* superblock, then he/she must also specify the block size!
* Otherwise, read the master superblock located at offset
* SUPERBLOCK_OFFSET from the start of the partition.
*
* Note: we only save a backup copy of the superblock if we
* are reading the superblock from the primary superblock location.
*/
if (superblock) {
if (!block_size) {
retval = EXT2_ET_INVALID_ARGUMENT;
goto cleanup;
}
io_channel_set_blksize(fs->io, block_size);
group_block = superblock;
fs->orig_super = 0;
} else {
io_channel_set_blksize(fs->io, SUPERBLOCK_OFFSET);
superblock = 1;
group_block = 0;
retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &fs->orig_super);
if (retval)
goto cleanup;
//.........这里部分代码省略.........
开发者ID:K0T0LI,项目名称:busybox,代码行数:101,代码来源:openfs.c
示例7: ext2fs_initialize
errcode_t ext2fs_initialize(const char *name, int flags,
struct ext2_super_block *param,
io_manager manager, ext2_filsys *ret_fs)
{
ext2_filsys fs;
errcode_t retval;
struct ext2_super_block *super;
unsigned int rem;
unsigned int overhead = 0;
unsigned int ipg;
dgrp_t i;
blk64_t free_blocks;
blk_t numblocks;
int rsv_gdt;
int csum_flag;
int bigalloc_flag;
int io_flags;
unsigned reserved_inos;
char *buf = 0;
char c;
double reserved_ratio;
if (!param || !ext2fs_blocks_count(param))
return EXT2_ET_INVALID_ARGUMENT;
retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs);
if (retval)
return retval;
memset(fs, 0, sizeof(struct struct_ext2_filsys));
fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS;
fs->flags = flags | EXT2_FLAG_RW;
fs->umask = 022;
fs->default_bitmap_type = EXT2FS_BMAP64_RBTREE;
#ifdef WORDS_BIGENDIAN
fs->flags |= EXT2_FLAG_SWAP_BYTES;
#endif
io_flags = IO_FLAG_RW;
if (flags & EXT2_FLAG_EXCLUSIVE)
io_flags |= IO_FLAG_EXCLUSIVE;
if (flags & EXT2_FLAG_DIRECT_IO)
io_flags |= IO_FLAG_DIRECT_IO;
retval = manager->open(name, io_flags, &fs->io);
if (retval)
goto cleanup;
fs->image_io = fs->io;
fs->io->app_data = fs;
retval = ext2fs_get_mem(strlen(name)+1, &fs->device_name);
if (retval)
goto cleanup;
strcpy(fs->device_name, name);
retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &super);
if (retval)
goto cleanup;
fs->super = super;
memset(super, 0, SUPERBLOCK_SIZE);
#define set_field(field, default) (super->field = param->field ? \
param->field : (default))
#define assign_field(field) (super->field = param->field)
super->s_magic = EXT2_SUPER_MAGIC;
super->s_state = EXT2_VALID_FS;
bigalloc_flag = EXT2_HAS_RO_COMPAT_FEATURE(param,
EXT4_FEATURE_RO_COMPAT_BIGALLOC);
assign_field(s_log_block_size);
if (bigalloc_flag) {
set_field(s_log_cluster_size, super->s_log_block_size+4);
if (super->s_log_block_size > super->s_log_cluster_size) {
retval = EXT2_ET_INVALID_ARGUMENT;
goto cleanup;
}
} else
super->s_log_cluster_size = super->s_log_block_size;
set_field(s_first_data_block, super->s_log_cluster_size ? 0 : 1);
set_field(s_max_mnt_count, 0);
set_field(s_errors, EXT2_ERRORS_DEFAULT);
set_field(s_feature_compat, 0);
set_field(s_feature_incompat, 0);
set_field(s_feature_ro_compat, 0);
set_field(s_default_mount_opts, 0);
set_field(s_first_meta_bg, 0);
set_field(s_raid_stride, 0); /* default stride size: 0 */
set_field(s_raid_stripe_width, 0); /* default stripe width: 0 */
set_field(s_log_groups_per_flex, 0);
set_field(s_flags, 0);
assign_field(s_backup_bgs[0]);
assign_field(s_backup_bgs[1]);
if (super->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP) {
retval = EXT2_ET_UNSUPP_FEATURE;
goto cleanup;
}
if (super->s_feature_ro_compat & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP) {
retval = EXT2_ET_RO_UNSUPP_FEATURE;
//.........这里部分代码省略.........
开发者ID:DebdutBiswas,项目名称:WinFLASHTool,代码行数:101,代码来源:initialize.c
注:本文中的io_manager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论