summaryrefslogtreecommitdiffstats
path: root/sbin/fsck_ffs
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2007-08-10 06:29:54 +0000
committerpjd <pjd@FreeBSD.org>2007-08-10 06:29:54 +0000
commit5b34e16cb7a7743a4bcf782f6946d1b68b15f853 (patch)
tree02b549ac3a1a713bb0800b26ef58110d3161885b /sbin/fsck_ffs
parent1e2d5f7f4ae5c6c278371f5d357ee949df152bcc (diff)
downloadFreeBSD-src-5b34e16cb7a7743a4bcf782f6946d1b68b15f853.zip
FreeBSD-src-5b34e16cb7a7743a4bcf782f6946d1b68b15f853.tar.gz
Fix fscking gjournaled root file system: root file system is already mounted
read-only, so we can't simply exit right after calling gjournal_check(), instead we need to ask about super block reload. Submitted by: Niki Denev <niki@totalterror.net> PR: misc/113889 Approved by: re (kensmith)
Diffstat (limited to 'sbin/fsck_ffs')
-rw-r--r--sbin/fsck_ffs/main.c55
1 files changed, 36 insertions, 19 deletions
diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c
index 2529c87..9407739 100644
--- a/sbin/fsck_ffs/main.c
+++ b/sbin/fsck_ffs/main.c
@@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$");
static void usage(void) __dead2;
static int argtoi(int flag, const char *req, const char *str, int base);
static int checkfilesys(char *filesys);
+static int chkdoreload(struct statfs *mntp);
static struct statfs *getmntpt(const char *);
int
@@ -197,7 +198,7 @@ checkfilesys(char *filesys)
struct stat snapdir;
struct group *grp;
ufs2_daddr_t blks;
- int cylno, ret;
+ int cylno;
ino_t files;
size_t size;
@@ -253,7 +254,9 @@ checkfilesys(char *filesys)
}
if ((sblock.fs_flags & (FS_UNCLEAN | FS_NEEDSFSCK)) == 0) {
gjournal_check(filesys);
- exit(0);
+ if (chkdoreload(mntp) == 0)
+ exit(0);
+ exit(4);
} else {
pfatal("UNEXPECTED INCONSISTENCY, %s\n",
"CANNOT RUN FAST FSCK\n");
@@ -483,23 +486,7 @@ checkfilesys(char *filesys)
printf("\n***** FILE SYSTEM WAS MODIFIED *****\n");
if (rerun)
printf("\n***** PLEASE RERUN FSCK *****\n");
- if (mntp != NULL) {
- /*
- * We modified a mounted file system. Do a mount update on
- * it unless it is read-write, so we can continue using it
- * as safely as possible.
- */
- if (mntp->f_flags & MNT_RDONLY) {
- args.fspec = 0;
- args.export.ex_flags = 0;
- args.export.ex_root = 0;
- ret = mount("ufs", mntp->f_mntonname,
- mntp->f_flags | MNT_UPDATE | MNT_RELOAD, &args);
- if (ret == 0)
- return (0);
- pwarn("mount reload of '%s' failed: %s\n\n",
- mntp->f_mntonname, strerror(errno));
- }
+ if (chkdoreload(mntp) != 0) {
if (!fsmodified)
return (0);
if (!preen)
@@ -510,6 +497,36 @@ checkfilesys(char *filesys)
return (0);
}
+static int
+chkdoreload(struct statfs *mntp)
+{
+ struct ufs_args args;
+
+ if (mntp == NULL)
+ return (0);
+ /*
+ * We modified a mounted file system. Do a mount update on
+ * it unless it is read-write, so we can continue using it
+ * as safely as possible.
+ */
+ if (mntp->f_flags & MNT_RDONLY) {
+ memset(&args, 0, sizeof args);
+ /*
+ * args.fspec = 0;
+ * args.export.ex_flags = 0;
+ * args.export.ex_root = 0;
+ */
+ if (mount("ufs", mntp->f_mntonname,
+ mntp->f_flags | MNT_UPDATE | MNT_RELOAD, &args) == 0) {
+ return (0);
+ }
+ pwarn("mount reload of '%s' failed: %s\n\n",
+ mntp->f_mntonname, strerror(errno));
+ return (1);
+ }
+ return (0);
+}
+
/*
* Get the mount point information for name.
*/
OpenPOWER on IntegriCloud