2 * journal.c --- code for handling the "ext3" journal
10 * This is a list of directories to try. The first element may get
11 * replaced by a mktemp'ed generated temp directory if possible.
13 static char *dirlist[] = { "/mnt", "/tmp", "/root", "/boot", 0 };
16 * This function attempts to mount and unmount an ext3 filesystem,
17 * which is a cheap way to force the kernel to run the journal and
18 * handle the recovery for us.
20 int e2fsck_run_ext3_journal(const char *device)
24 char template[] = "/tmp/ext3.XXXXXX";
28 * First try to make a temporary directory. This may fail if
29 * the root partition is still mounted read-only.
31 tmpdir = mktemp(template);
33 ret = mkdir(template, 0700);
38 ret = mount(device, tmpdir, "ext3", 0xC0ED, NULL);
46 * OK, creating a temporary directory didn't work.
47 * Let's try a list of possible temporary mountpoints.
49 for (cpp = dirlist; dir = *cpp; cpp++) {
50 ret = mount(device, dir, "ext3", 0xC0ED, NULL);
59 * Now that it mounted cleanly, the filesystem will have been
60 * recovered, so we can now unmount it.
66 * Remove the temporary directory, if it was created.