aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-10-11 09:49:54 +0000
committerRoy Marples <roy@marples.name>2007-10-11 09:49:54 +0000
commit64d1dd9da0c80691a562dad932dbca37bcfd6195 (patch)
treea60690d2cdfec53ad9bbf85c8f53e250fc5920ea
parent07c8f8cfde375df0601020ecd656dc825571f17b (diff)
If / block device as in /etc/fstab does not exist, use /dev/root if it's available in checkroot, #171593.
-rw-r--r--ChangeLog5
-rwxr-xr-xinit.d/checkroot11
-rw-r--r--src/fstabinfo.c25
3 files changed, 29 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index d18d0935..ff57c9df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
# ChangeLog for Gentoo System Intialization ("rc") scripts
# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2
+ 11 Oct 2007; Roy Marples <uberlord@gentoo.org>:
+
+ If / block device as in /etc/fstab does not exist, use /dev/root if
+ it's available in checkroot, #171593.
+
09 Oct 2007; Roy Marples <uberlord@gentoo.org>:
netmount, localmount, halt.sh and net scripts now check OS specific flags
diff --git a/init.d/checkroot b/init.d/checkroot
index a392ea36..a45265cf 100755
--- a/init.d/checkroot
+++ b/init.d/checkroot
@@ -36,7 +36,7 @@ root_rw() {
}
do_fsck() {
- local retval=0 opts=
+ local retval=0 opts= root=
case "${RC_UNAME}" in
FreeBSD) opts="-F";;
Linux) opts="-T -C0";;
@@ -52,9 +52,12 @@ do_fsck() {
return 0
fi
+ root=$(fstabinfo --blockdevice /)
+ [ ! -e "${root}" -a -e /dev/root ] && root=/dev/root
+
if [ -e /forcefsck ] || get_bootparam "forcefsck" ; then
ebegin "Checking root filesystem (full fsck forced)"
- fsck ${opts} -f -n /
+ fsck ${opts} -f -n "${root}"
# /forcefsck isn't deleted because checkfs needs it.
# it'll be deleted in that script.
retval=$?
@@ -63,7 +66,7 @@ do_fsck() {
local pass=$(fstabinfo --passno /)
if [ ${pass:-0} != "0" ] ; then
ebegin "Checking root filesystem"
- fsck ${opts} -p /
+ fsck ${opts} -p "${root}"
retval=$?
else
ebegin "Skipping root filesystem check" "(fstab's passno == 0)"
@@ -92,7 +95,7 @@ do_fsck() {
else
if [ "${RC_FORCE_AUTO}" = "yes" ] ; then
eend 2 "Rerunning fsck in force mode"
- fsck ${opts} -y /
+ fsck ${opts} -y "${root}"
retval=$?
else
eend 2 "Filesystem couldn't be fixed :("
diff --git a/src/fstabinfo.c b/src/fstabinfo.c
index 23b5c42a..4d927f71 100644
--- a/src/fstabinfo.c
+++ b/src/fstabinfo.c
@@ -24,7 +24,7 @@
#define GET_ENT getmntent (fp)
#define GET_ENT_FILE(_name) getmntfile (_name)
#define END_ENT endmntent (fp)
-#define ENT_DEVICE(_ent) ent->mnt_fsname
+#define ENT_BLOCKDEVICE(_ent) ent->mnt_fsname
#define ENT_FILE(_ent) ent->mnt_dir
#define ENT_TYPE(_ent) ent->mnt_type
#define ENT_OPTS(_ent) ent->mnt_opts
@@ -36,7 +36,7 @@
#define GET_ENT getfsent ()
#define GET_ENT_FILE(_name) getfsfile (_name)
#define END_ENT endfsent ()
-#define ENT_DEVICE(_ent) ent->fs_spec
+#define ENT_BLOCKDEVICE(_ent) ent->fs_spec
#define ENT_TYPE(_ent) ent->fs_vfstype
#define ENT_FILE(_ent) ent->fs_file
#define ENT_OPTS(_ent) ent->fs_mntops
@@ -65,17 +65,19 @@ static struct mntent *getmntfile (const char *file)
#endif
#include "_usage.h"
-#define getoptstring "mop:t:" getoptstring_COMMON
+#define getoptstring "bmop:t:" getoptstring_COMMON
static struct option longopts[] = {
- { "options", 0, NULL, 'o'},
- { "passno", 1, NULL, 'p'},
- { "fstype", 1, NULL, 't'},
+ { "blockdevice", 0, NULL, 'b' },
+ { "options", 0, NULL, 'o' },
+ { "passno", 1, NULL, 'p' },
+ { "fstype", 1, NULL, 't' },
longopts_COMMON
};
static const char * const longopts_help[] = {
+ "Extract the block device",
"Extract the options field",
- "Extract the pass number field",
- "Extract the file system type",
+ "Extract or query the pass number field",
+ "List entries with matching file system type",
longopts_help_COMMON
};
#include "_usage.c"
@@ -83,6 +85,7 @@ static const char * const longopts_help[] = {
#define OUTPUT_FILE (1 << 1)
#define OUTPUT_OPTIONS (1 << 3)
#define OUTPUT_PASSNO (1 << 4)
+#define OUTPUT_BLOCKDEV (1 << 5)
int fstabinfo (int argc, char **argv)
{
@@ -105,6 +108,9 @@ int fstabinfo (int argc, char **argv)
longopts, (int *) 0)) != -1)
{
switch (opt) {
+ case 'b':
+ output = OUTPUT_BLOCKDEV;
+ break;
case 'o':
output = OUTPUT_OPTIONS;
break;
@@ -177,6 +183,9 @@ int fstabinfo (int argc, char **argv)
continue;
switch (output) {
+ case OUTPUT_BLOCKDEV:
+ printf ("%s\n", ENT_BLOCKDEVICE (ent));
+ break;
case OUTPUT_OPTIONS:
printf ("%s\n", ENT_OPTS (ent));
break;