本文整理汇总了C++中OCFS2_RAW_SB函数的典型用法代码示例。如果您正苦于以下问题:C++ OCFS2_RAW_SB函数的具体用法?C++ OCFS2_RAW_SB怎么用?C++ OCFS2_RAW_SB使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OCFS2_RAW_SB函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fs_is_clean
static int fs_is_clean(o2fsck_state *ost, char *filename)
{
struct ocfs2_super_block *sb = OCFS2_RAW_SB(ost->ost_fs->fs_super);
time_t now = time(NULL);
time_t next = sb->s_lastcheck + sb->s_checkinterval;
static char reason[4096] = {'\0', };
struct tm local;
if (ost->ost_force)
strcpy(reason, "was run with -f");
else if ((OCFS2_RAW_SB(ost->ost_fs->fs_super)->s_feature_incompat &
OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG))
strcpy(reason, "incomplete volume resize detected");
else if ((OCFS2_RAW_SB(ost->ost_fs->fs_super)->s_feature_incompat &
OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG))
strcpy(reason, "incomplete tunefs operation detected");
else if (sb->s_state & OCFS2_ERROR_FS)
strcpy(reason, "contains a file system with errors");
else if (sb->s_max_mnt_count > 0 &&
sb->s_mnt_count > sb->s_max_mnt_count) {
sprintf(reason, "has been mounted %u times without being "
"checked", sb->s_mnt_count);
} else if (sb->s_checkinterval > 0 && now >= next) {
unsigned scaled_time;
char *scaled_units;
scale_time(now - sb->s_lastcheck, &scaled_time, &scaled_units);
sprintf(reason, "has gone %u %s without being checked",
scaled_time, scaled_units);
}
if (reason[0]) {
printf("%s %s, check forced.\n", filename, reason);
return 0;
}
reason[0] = '\0';
if (sb->s_max_mnt_count > 0)
sprintf(reason, "after %u additional mounts",
sb->s_max_mnt_count - sb->s_mnt_count);
if (sb->s_checkinterval > 0) {
localtime_r(&next, &local);
if (reason[0])
ftso_strftime(reason + strlen(reason),
sizeof(reason) - strlen(reason),
" or by %c, whichever comes first", &local);
else
ftso_strftime(reason, sizeof(reason), "by %c", &local);
}
printf("%s is clean.", filename);
if (reason[0])
printf(" It will be checked %s.\n", reason);
return 1;
}
示例2: print_uuid
static void print_uuid(o2fsck_state *ost)
{
unsigned char *uuid = OCFS2_RAW_SB(ost->ost_fs->fs_super)->s_uuid;
size_t i, max = sizeof(OCFS2_RAW_SB(ost->ost_fs->fs_super)->s_uuid);
for(i = 0; i < max; i++)
printf("%02X", uuid[i]);
printf("\n");
}
示例3: mess_up_inode_field
void mess_up_inode_field(ocfs2_filesys *fs, enum fsck_type type, uint64_t blkno)
{
errcode_t ret;
uint64_t tmpblkno;
uint32_t clusters = 10;
char *buf = NULL;
struct ocfs2_dinode *di;
create_file(fs, blkno, &tmpblkno);
if ((type == INODE_SPARSE_SIZE) || (type == INODE_SPARSE_CLUSTERS)) {
if (!ocfs2_sparse_alloc(OCFS2_RAW_SB(fs->fs_super)))
FSWRK_FATAL("should specfiy a sparse file supported "
"volume to do this corruption\n");
ret = ocfs2_malloc_block(fs->fs_io, &buf);
if (ret)
FSWRK_COM_FATAL(progname, ret);
ret = ocfs2_read_inode(fs, tmpblkno, buf);
if (ret)
FSWRK_COM_FATAL(progname, ret);
di = (struct ocfs2_dinode *)buf;
di->i_size = fs->fs_clustersize * 2;
ret = ocfs2_write_inode(fs, tmpblkno, buf);
if (ret)
FSWRK_COM_FATAL(progname, ret);
if (buf)
ocfs2_free(&buf);
}
if ((type == INODE_CLUSTERS) || (type == INODE_SPARSE_CLUSTERS) ||
(type == INODE_SPARSE_SIZE)) {
ret = ocfs2_extend_allocation(fs, tmpblkno, clusters);
if (ret)
FSWRK_COM_FATAL(progname, ret);
}
if (type == REFCOUNT_FLAG_INVALID &&
ocfs2_refcount_tree(OCFS2_RAW_SB(fs->fs_super)))
FSWRK_FATAL("should specfiy a norefcount volume\n");
if (type == REFCOUNT_LOC_INVALID &&
!ocfs2_refcount_tree(OCFS2_RAW_SB(fs->fs_super)))
FSWRK_FATAL("Should specify a refcount supported volume\n");
damage_inode(fs, tmpblkno, type);
return;
}
示例4: update_volume_label
static void update_volume_label(ocfs2_filesys *fs,
const char *new_label)
{
int len;
char label_buf[OCFS2_MAX_VOL_LABEL_LEN];
struct ocfs2_super_block *sb = OCFS2_RAW_SB(fs->fs_super);
memset(label_buf, 0, OCFS2_MAX_VOL_LABEL_LEN);
if (new_label) {
len = strlen(new_label);
if (len > OCFS2_MAX_VOL_LABEL_LEN)
len = OCFS2_MAX_VOL_LABEL_LEN;
if (!memcmp(sb->s_label, new_label, len)) {
verbosef(VL_APP,
"Device \"%s\" already has the label "
"\"%.*s\"; label not updated\n",
fs->fs_devname, OCFS2_MAX_VOL_LABEL_LEN,
new_label);
return;
}
strncpy(label_buf, new_label, OCFS2_MAX_VOL_LABEL_LEN);
} else {
strncpy(label_buf, (char *)sb->s_label,
OCFS2_MAX_VOL_LABEL_LEN);
len = strnlen(label_buf, OCFS2_MAX_VOL_LABEL_LEN);
/*
* If we don't have CLONED_LABEL at the end of the label,
* add it. Truncate the existing label if necessary to
* fit CLONED_LABEL.
*/
if (strncmp(label_buf + len - CLONED_LABEL_LEN,
CLONED_LABEL, CLONED_LABEL_LEN)) {
if ((len + CLONED_LABEL_LEN) > OCFS2_MAX_VOL_LABEL_LEN)
len = OCFS2_MAX_VOL_LABEL_LEN -
CLONED_LABEL_LEN;
strncpy(label_buf + len, CLONED_LABEL,
CLONED_LABEL_LEN);
}
}
verbosef(VL_APP,
"Setting the label \"%.*s\" on device \"%s\"\n",
OCFS2_MAX_VOL_LABEL_LEN, label_buf, fs->fs_devname);
memset(OCFS2_RAW_SB(fs->fs_super)->s_label, 0,
OCFS2_MAX_VOL_LABEL_LEN);
strncpy((char *)sb->s_label, label_buf,
OCFS2_MAX_VOL_LABEL_LEN);
}
示例5: empty_journal
/* Empty the content of the specified journal file.
* Most of the code is copied from ocfs2_format_journal.
*/
static errcode_t empty_journal(ocfs2_filesys *fs,
ocfs2_cached_inode *ci)
{
errcode_t ret = 0;
char *buf = NULL;
int bs_bits = OCFS2_RAW_SB(fs->fs_super)->s_blocksize_bits;
uint64_t offset = 0;
uint32_t wrote, count;
#define BUFLEN 1048576
ret = ocfs2_malloc_blocks(fs->fs_io, (BUFLEN >> bs_bits), &buf);
if (ret)
goto out;
memset(buf, 0, BUFLEN);
count = (uint32_t) ci->ci_inode->i_size;
while (count) {
ret = ocfs2_file_write(ci, buf, ocfs2_min((uint32_t) BUFLEN, count),
offset, &wrote);
if (ret)
goto out;
offset += wrote;
count -= wrote;
}
out:
return ret;
}
示例6: print_label
static void print_label(o2fsck_state *ost)
{
unsigned char *label = OCFS2_RAW_SB(ost->ost_fs->fs_super)->s_label;
size_t i, max = sizeof(OCFS2_RAW_SB(ost->ost_fs->fs_super)->s_label);
for(i = 0; i < max && label[i]; i++) {
if (isprint(label[i]))
printf("%c", label[i]);
else
printf(".");
}
if (i == 0)
printf("<NONE>");
printf("\n");
}
示例7: orphan_dir_check
static errcode_t orphan_dir_check(ocfs2_filesys *fs,
uint16_t new_slots)
{
errcode_t ret = 0;
uint64_t blkno;
int i, has_orphan = 0;
uint16_t max_slots = OCFS2_RAW_SB(fs->fs_super)->s_max_slots;
for (i = new_slots ; i < max_slots; ++i) {
ret = ocfs2_lookup_system_inode(fs, ORPHAN_DIR_SYSTEM_INODE,
i, &blkno);
if (ret) {
verbosef(VL_APP,
"%s while looking up orphan dir for "
"slot %u during orphan dir check\n",
error_message(ret), i);
break;
}
ret = ocfs2_dir_iterate(fs, blkno,
OCFS2_DIRENT_FLAG_EXCLUDE_DOTS, NULL,
orphan_iterate, &has_orphan);
if (has_orphan) {
ret = TUNEFS_ET_ORPHAN_DIR_NOT_EMPTY;
verbosef(VL_APP,
"Entries found in orphan dir for slot %u\n",
i);
break;
}
}
return ret;
}
示例8: check_journal_walk
static errcode_t check_journal_walk(o2fsck_state *ost,
errcode_t (*func)(o2fsck_state *ost,
ocfs2_cached_inode *ci,
struct journal_check_context *jc),
struct journal_check_context *jc)
{
errcode_t ret = 0;
uint64_t blkno;
ocfs2_filesys *fs = ost->ost_fs;
uint16_t i, max_slots = OCFS2_RAW_SB(fs->fs_super)->s_max_slots;
ocfs2_cached_inode *ci = NULL;
for (i = 0; i < max_slots; i++) {
ret = ocfs2_lookup_system_inode(fs, JOURNAL_SYSTEM_INODE, i,
&blkno);
if (ret)
break;
ret = ocfs2_read_cached_inode(fs, blkno, &ci);
if (ret)
break;
jc->jc_this_slot = i;
ret = func(ost, ci, jc);
if (ret)
break;
}
if (ci)
ocfs2_free_cached_inode(fs, ci);
return ret;
}
示例9: ocfs2_write_backup_super
errcode_t ocfs2_write_backup_super(ocfs2_filesys *fs, uint64_t blkno)
{
errcode_t ret;
char *buf = NULL;
struct ocfs2_dinode *di;
if (!(fs->fs_flags & OCFS2_FLAG_RW))
return OCFS2_ET_RO_FILESYS;
ret = ocfs2_malloc_block(fs->fs_io, &buf);
if (ret)
goto out_blk;
memcpy(buf, (char *)fs->fs_super, fs->fs_blocksize);
di = (struct ocfs2_dinode *)buf;
ret = OCFS2_ET_BAD_MAGIC;
if (memcmp(di->i_signature, OCFS2_SUPER_BLOCK_SIGNATURE,
strlen(OCFS2_SUPER_BLOCK_SIGNATURE)))
goto out_blk;
di->i_blkno = blkno;
OCFS2_SET_COMPAT_FEATURE(OCFS2_RAW_SB(di),
OCFS2_FEATURE_COMPAT_BACKUP_SB);
ret = ocfs2_write_inode(fs, blkno, buf);
if (ret)
goto out_blk;
ret = 0;
out_blk:
if (buf)
ocfs2_free(&buf);
return ret;
}
示例10: open_ocfs2_volume
int open_ocfs2_volume(char *device_name)
{
int open_flags = OCFS2_FLAG_HEARTBEAT_DEV_OK | OCFS2_FLAG_RO;
int ret;
ret = ocfs2_open(device_name, open_flags, 0, 0, &fs);
if (ret < 0) {
fprintf(stderr, "Not a ocfs2 volume!\n");
return ret;
}
ocfs2_sb = OCFS2_RAW_SB(fs->fs_super);
if (!(ocfs2_sb->s_feature_incompat &
OCFS2_FEATURE_INCOMPAT_INLINE_DATA)) {
fprintf(stderr, "Inline-data not supported"
" on this ocfs2 volume\n");
return -1;
}
blocksize = 1 << ocfs2_sb->s_blocksize_bits;
clustersize = 1 << ocfs2_sb->s_clustersize_bits;
max_inline_size = ocfs2_max_inline_data_with_xattr(blocksize, NULL);
return 0;
}
示例11: mess_up_sys_chains
static void mess_up_sys_chains(ocfs2_filesys *fs, uint16_t slotnum,
enum fsck_type type)
{
errcode_t ret;
char sysfile[OCFS2_MAX_FILENAME_LEN];
uint64_t blkno;
struct ocfs2_super_block *sb = OCFS2_RAW_SB(fs->fs_super);
if (slotnum == UINT16_MAX)
snprintf(sysfile, sizeof(sysfile), "%s",
ocfs2_system_inodes[GLOBAL_BITMAP_SYSTEM_INODE].si_name);
else
snprintf(sysfile, sizeof(sysfile),
ocfs2_system_inodes[INODE_ALLOC_SYSTEM_INODE].si_name,
slotnum);
ret = ocfs2_lookup(fs, sb->s_system_dir_blkno, sysfile,
strlen(sysfile), NULL, &blkno);
if (ret)
FSWRK_COM_FATAL(progname, ret);
mess_up_sys_file(fs, blkno, type);
return ;
}
示例12: mess_up_local_alloc_used
void mess_up_local_alloc_used(ocfs2_filesys *fs, enum fsck_type type,
uint16_t slotnum)
{
errcode_t ret;
uint64_t blkno;
char alloc_inode[OCFS2_MAX_FILENAME_LEN];
struct ocfs2_super_block *sb = OCFS2_RAW_SB(fs->fs_super);
if (slotnum == UINT16_MAX)
slotnum = 0;
snprintf(alloc_inode, sizeof(alloc_inode),
ocfs2_system_inodes[LOCAL_ALLOC_SYSTEM_INODE].si_name,slotnum);
ret = ocfs2_lookup(fs, sb->s_system_dir_blkno, alloc_inode,
strlen(alloc_inode), NULL, &blkno);
if (ret)
FSWRK_COM_FATAL(progname, ret);
create_local_alloc(fs, blkno);
damage_local_alloc(fs, blkno, type);
return;
}
示例13: set_journal_block64_run
static int set_journal_block64_run(struct tunefs_operation *op,
ocfs2_filesys *fs, int flags)
{
errcode_t err;
int rc = 0;
ocfs2_fs_options mask, options;
struct ocfs2_super_block *super = OCFS2_RAW_SB(fs->fs_super);
memset(&mask, 0, sizeof(ocfs2_fs_options));
memset(&options, 0, sizeof(ocfs2_fs_options));
mask.opt_incompat |= JBD2_FEATURE_INCOMPAT_64BIT;
options.opt_incompat |= JBD2_FEATURE_INCOMPAT_64BIT;
if (!tools_interact("Enable block64 journal feature on device \"%s\"? ",
fs->fs_devname))
goto out;
tunefs_block_signals();
super->s_feature_compat |= OCFS2_FEATURE_COMPAT_JBD2_SB;
err = ocfs2_write_super(fs);
if (!err)
err = tunefs_set_journal_size(fs, 0, mask, options);
tunefs_unblock_signals();
if (err) {
rc = 1;
tcom_err(err,
"; unable to enable block64 journal feature on "
"device \"%s\"", fs->fs_devname);
}
out:
return rc;
}
示例14: ocfs2_clear_backup_super_list
errcode_t ocfs2_clear_backup_super_list(ocfs2_filesys *fs,
uint64_t *blocks, size_t len)
{
size_t i;
errcode_t ret = 0;
if (!len || !blocks || !*blocks)
goto bail;
len = ocfs2_min(len,(size_t)OCFS2_MAX_BACKUP_SUPERBLOCKS);
/*
* Don't clear anything if backup superblocks aren't enabled -
* there might be real data there! If backup superblocks are
* enabled, we know these blocks are backups, and we're
* safe to clear them.
*/
if (!OCFS2_HAS_COMPAT_FEATURE(OCFS2_RAW_SB(fs->fs_super),
OCFS2_FEATURE_COMPAT_BACKUP_SB))
goto bail;
for (i = 0; i < len; i++) {
ret = ocfs2_free_clusters(fs, 1, blocks[i]);
if (ret)
break;
}
bail:
return ret;
}
示例15: mess_up_inode_orphaned
void mess_up_inode_orphaned(ocfs2_filesys *fs, enum fsck_type type,
uint16_t slotnum)
{
errcode_t ret;
uint64_t blkno, tmpblkno;
char parentdir[OCFS2_MAX_FILENAME_LEN];
struct ocfs2_super_block *sb = OCFS2_RAW_SB(fs->fs_super);
if (slotnum == UINT16_MAX)
slotnum = 0;
snprintf(parentdir, sizeof(parentdir),
ocfs2_system_inodes[ORPHAN_DIR_SYSTEM_INODE].si_name, slotnum);
ret = ocfs2_lookup(fs, sb->s_system_dir_blkno, parentdir,
strlen(parentdir), NULL, &blkno);
if (ret)
FSWRK_COM_FATAL(progname, ret);
create_file(fs, blkno, &tmpblkno);
fprintf(stdout, "INODE_ORPHANED: "
"Create an inode#%"PRIu64" under directory %s\n",
tmpblkno, parentdir);
return;
}