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; }
int main (int argc, char **argv) { ocfs2_filesys *fs = NULL; errcode_t ret = 1; initialize_ocfs_error_table(); #define INSTALL_SIGNAL(sig) \ do { \ if (signal(sig, handle_signal) == SIG_ERR) { \ printf("Could not set " #sig "\n"); \ goto bail; \ } \ } while (0) INSTALL_SIGNAL(SIGTERM); INSTALL_SIGNAL(SIGINT); memset(&options, 0, sizeof(options)); if (read_options(argc, argv)) { usage(progname); goto bail; } if (!device || !options.ops) goto bail; ret = ocfs2_open(device, OCFS2_FLAG_RW, 0, 0, &fs); if (ret) { com_err(progname, ret, "while opening \"%s\"", device); goto bail; } srand((unsigned long)fs); switch (options.ops) { case CREATE_LOCAL_ALLOC: ret = create_local_alloc(fs, options.slot); break; case CREATE_ORPHAN_FILE: ret = create_orphan_file(fs, options.slot); break; case CREATE_TRUNCATE_LOG: ret = create_truncate_log(fs, options.slot); break; } bail: if (fs) ocfs2_close(fs); return ret; }