If / block device as in /etc/fstab does not exist, use /dev/root if it's available in checkroot, #171593.

This commit is contained in:
Roy Marples 2007-10-11 09:49:54 +00:00
parent 07c8f8cfde
commit 64d1dd9da0
3 changed files with 29 additions and 12 deletions

View File

@ -1,6 +1,11 @@
# ChangeLog for Gentoo System Intialization ("rc") scripts # ChangeLog for Gentoo System Intialization ("rc") scripts
# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2 # 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>: 09 Oct 2007; Roy Marples <uberlord@gentoo.org>:
netmount, localmount, halt.sh and net scripts now check OS specific flags netmount, localmount, halt.sh and net scripts now check OS specific flags

View File

@ -36,7 +36,7 @@ root_rw() {
} }
do_fsck() { do_fsck() {
local retval=0 opts= local retval=0 opts= root=
case "${RC_UNAME}" in case "${RC_UNAME}" in
FreeBSD) opts="-F";; FreeBSD) opts="-F";;
Linux) opts="-T -C0";; Linux) opts="-T -C0";;
@ -52,9 +52,12 @@ do_fsck() {
return 0 return 0
fi fi
root=$(fstabinfo --blockdevice /)
[ ! -e "${root}" -a -e /dev/root ] && root=/dev/root
if [ -e /forcefsck ] || get_bootparam "forcefsck" ; then if [ -e /forcefsck ] || get_bootparam "forcefsck" ; then
ebegin "Checking root filesystem (full fsck forced)" ebegin "Checking root filesystem (full fsck forced)"
fsck ${opts} -f -n / fsck ${opts} -f -n "${root}"
# /forcefsck isn't deleted because checkfs needs it. # /forcefsck isn't deleted because checkfs needs it.
# it'll be deleted in that script. # it'll be deleted in that script.
retval=$? retval=$?
@ -63,7 +66,7 @@ do_fsck() {
local pass=$(fstabinfo --passno /) local pass=$(fstabinfo --passno /)
if [ ${pass:-0} != "0" ] ; then if [ ${pass:-0} != "0" ] ; then
ebegin "Checking root filesystem" ebegin "Checking root filesystem"
fsck ${opts} -p / fsck ${opts} -p "${root}"
retval=$? retval=$?
else else
ebegin "Skipping root filesystem check" "(fstab's passno == 0)" ebegin "Skipping root filesystem check" "(fstab's passno == 0)"
@ -92,7 +95,7 @@ do_fsck() {
else else
if [ "${RC_FORCE_AUTO}" = "yes" ] ; then if [ "${RC_FORCE_AUTO}" = "yes" ] ; then
eend 2 "Rerunning fsck in force mode" eend 2 "Rerunning fsck in force mode"
fsck ${opts} -y / fsck ${opts} -y "${root}"
retval=$? retval=$?
else else
eend 2 "Filesystem couldn't be fixed :(" eend 2 "Filesystem couldn't be fixed :("

View File

@ -24,7 +24,7 @@
#define GET_ENT getmntent (fp) #define GET_ENT getmntent (fp)
#define GET_ENT_FILE(_name) getmntfile (_name) #define GET_ENT_FILE(_name) getmntfile (_name)
#define END_ENT endmntent (fp) #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_FILE(_ent) ent->mnt_dir
#define ENT_TYPE(_ent) ent->mnt_type #define ENT_TYPE(_ent) ent->mnt_type
#define ENT_OPTS(_ent) ent->mnt_opts #define ENT_OPTS(_ent) ent->mnt_opts
@ -36,7 +36,7 @@
#define GET_ENT getfsent () #define GET_ENT getfsent ()
#define GET_ENT_FILE(_name) getfsfile (_name) #define GET_ENT_FILE(_name) getfsfile (_name)
#define END_ENT endfsent () #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_TYPE(_ent) ent->fs_vfstype
#define ENT_FILE(_ent) ent->fs_file #define ENT_FILE(_ent) ent->fs_file
#define ENT_OPTS(_ent) ent->fs_mntops #define ENT_OPTS(_ent) ent->fs_mntops
@ -65,17 +65,19 @@ static struct mntent *getmntfile (const char *file)
#endif #endif
#include "_usage.h" #include "_usage.h"
#define getoptstring "mop:t:" getoptstring_COMMON #define getoptstring "bmop:t:" getoptstring_COMMON
static struct option longopts[] = { static struct option longopts[] = {
{ "options", 0, NULL, 'o'}, { "blockdevice", 0, NULL, 'b' },
{ "passno", 1, NULL, 'p'}, { "options", 0, NULL, 'o' },
{ "fstype", 1, NULL, 't'}, { "passno", 1, NULL, 'p' },
{ "fstype", 1, NULL, 't' },
longopts_COMMON longopts_COMMON
}; };
static const char * const longopts_help[] = { static const char * const longopts_help[] = {
"Extract the block device",
"Extract the options field", "Extract the options field",
"Extract the pass number field", "Extract or query the pass number field",
"Extract the file system type", "List entries with matching file system type",
longopts_help_COMMON longopts_help_COMMON
}; };
#include "_usage.c" #include "_usage.c"
@ -83,6 +85,7 @@ static const char * const longopts_help[] = {
#define OUTPUT_FILE (1 << 1) #define OUTPUT_FILE (1 << 1)
#define OUTPUT_OPTIONS (1 << 3) #define OUTPUT_OPTIONS (1 << 3)
#define OUTPUT_PASSNO (1 << 4) #define OUTPUT_PASSNO (1 << 4)
#define OUTPUT_BLOCKDEV (1 << 5)
int fstabinfo (int argc, char **argv) int fstabinfo (int argc, char **argv)
{ {
@ -105,6 +108,9 @@ int fstabinfo (int argc, char **argv)
longopts, (int *) 0)) != -1) longopts, (int *) 0)) != -1)
{ {
switch (opt) { switch (opt) {
case 'b':
output = OUTPUT_BLOCKDEV;
break;
case 'o': case 'o':
output = OUTPUT_OPTIONS; output = OUTPUT_OPTIONS;
break; break;
@ -177,6 +183,9 @@ int fstabinfo (int argc, char **argv)
continue; continue;
switch (output) { switch (output) {
case OUTPUT_BLOCKDEV:
printf ("%s\n", ENT_BLOCKDEVICE (ent));
break;
case OUTPUT_OPTIONS: case OUTPUT_OPTIONS:
printf ("%s\n", ENT_OPTS (ent)); printf ("%s\n", ENT_OPTS (ent));
break; break;