/* Open the journal and check it. */ errno_t repair_journal_open(reiser4_fs_t *fs, aal_device_t *journal_device, uint8_t mode, uint32_t options) { reiser4_plug_t *plug; errno_t res = 0; rid_t pid; aal_assert("vpf-445", fs != NULL); aal_assert("vpf-446", fs->format != NULL); aal_assert("vpf-476", journal_device != NULL); /* Try to open the journal. */ if ((fs->journal = reiser4_journal_open(fs, journal_device)) == NULL) { /* failed to open a journal. Build a new one. */ aal_error("Failed to open a journal by its id (0x%x).", reiser4_format_journal_pid(fs->format)); if (mode != RM_BUILD) return RE_FATAL; if ((pid = reiser4_format_journal_pid(fs->format)) == INVAL_PID) { aal_error("Invalid journal plugin id has been found."); return -EINVAL; } if (!(plug = reiser4_factory_ifind(JOURNAL_PLUG_TYPE, pid))) { aal_error("Cannot find journal plugin by its id 0x%x.", pid); return -EINVAL; } if (!(options & (1 << REPAIR_YES))) { if (aal_yesno("Do you want to create a new journal " "(%s)?", plug->label) == EXCEPTION_OPT_NO) { return -EINVAL; } } if (!(fs->journal = reiser4_journal_create(fs, journal_device))) { aal_error("Cannot create a journal by its id (0x%x).", reiser4_format_journal_pid(fs->format)); return -EINVAL; } } else { /* Check the structure of the opened journal or rebuild it if needed. */ if ((res = repair_journal_check_struct(fs->journal))) goto error_journal_close; } return 0; error_journal_close: reiser4_journal_close(fs->journal); fs->journal = NULL; return res; }
/// open device static void fs_open(char* device){ unsigned long long int state, extended; if (libreiser4_init()) { log_mesg(0, 1, 1, fs_opt.debug, "%s: Can't initialize libreiser4.\n", __FILE__); } if (!(fs_device = aal_device_open(&file_ops, device, 512, O_RDONLY))) { log_mesg(0, 1, 1, fs_opt.debug, "%s: Cannot open the partition (%s).\n", __FILE__, device); } if (!(fs = reiser4_fs_open(fs_device, 0))) { log_mesg(0, 1, 1, fs_opt.debug, "%s: Can't open reiser4 on %s\n", __FILE__, device); } //reiser4_opset_profile(fs->tree->ent.opset); if (!(fs->journal = reiser4_journal_open(fs, fs_device))) { log_mesg(0, 1, 1, fs_opt.debug, "%s: Can't open journal on %s", __FILE__, device); } state = get_ss_status(STATUS(fs->status)); extended = get_ss_extended(STATUS(fs->status)); if(fs_opt.ignore_fschk){ log_mesg(1, 0, 0, fs_opt.debug, "%s: Ignore filesystem check\n", __FILE__); }else{ if (!state) log_mesg(0, 1, 1, fs_opt.debug, "%s: REISER4 can't get status\n", __FILE__); if (state) log_mesg(3, 0, 0, fs_opt.debug, "%s: REISER4 stat : %i\n", __FILE__, state); if (state != FS_OK) log_mesg(0, 1, 1, fs_opt.debug, "%s: Filesystem isn't in valid state. May be it is not cleanly unmounted.\n\n", __FILE__); if (extended) log_mesg(3, 0, 0, fs_opt.debug, "%s: Extended status: %0xllx\n", extended, __FILE__); } //reiser4_opset_profile(fs->tree->ent.opset); fs->format = reiser4_format_open(fs); }
static reiser4_fs_t *busy_fs_open(char *name) { aal_device_t *device; reiser4_fs_t *fs; if (!(device = aal_device_open(&file_ops, name, 512, O_RDWR))) { aal_error("Can't open device %s.", name); return NULL; } if (!(fs = reiser4_fs_open(device, 1))) { aal_error("Can't open filesystem on %s.", name); goto error_close_device; } if (!(fs->journal = reiser4_journal_open(fs, device))) { aal_error("Failed to open the journal on %s.", name); goto error_close_fs; } fs->tree->mpc_func = misc_mpressure_detect; if (reiser4_journal_replay(fs->journal)) { aal_error("Failed to replay the journal on %s.", name); goto error_close_journal; } reiser4_journal_close(fs->journal); fs->journal = NULL; reiser4_fs_sync(fs); return fs; error_close_journal: reiser4_journal_close(fs->journal); error_close_fs: reiser4_fs_close(fs); error_close_device: aal_device_close(device); return NULL; }