initrd.scripts: simplify rootdev_init. Break if conditions for better readability

master
Fabio Erculiani 12 years ago
parent f5d1084646
commit 43a4651da2

@ -2017,79 +2017,78 @@ rootdev_init() {
done done
if [ "${got_good_root}" = "1" ] && is_livecd && ! is_nfs if [ "${got_good_root}" = "1" ] && is_livecd && ! is_nfs; then
then
# CD already mounted; no further checks necessary # CD already mounted; no further checks necessary
break break
elif [ "${LOOPTYPE}" = "sgimips" ] fi
then if [ "${LOOPTYPE}" = "sgimips" ]; then
# sgimips mounts the livecd root partition directly # sgimips mounts the livecd root partition directly
# there is no isofs filesystem to worry about # there is no isofs filesystem to worry about
break break
else fi
good_msg "Mounting $REAL_ROOT as root..."
good_msg "Mounting $REAL_ROOT as root..."
if [ "${ROOTFSTYPE}" = 'zfs' ] if [ "${ROOTFSTYPE}" = 'zfs' ]
then
if [ "$(zfs get -H -o value mountpoint ${REAL_ROOT})" = 'legacy' ]
then then
if [ "$(zfs get -H -o value mountpoint ${REAL_ROOT})" = 'legacy' ] MOUNT_STATE=rw
then
MOUNT_STATE=rw
else
MOUNT_STATE=rw,zfsutil
fi
else else
MOUNT_STATE=ro MOUNT_STATE=rw,zfsutil
fi fi
else
MOUNT_STATE=ro
fi
# Try to mount the device as ${NEW_ROOT} # Try to mount the device as ${NEW_ROOT}
if is_nfs; then if is_nfs; then
findnfsmount findnfsmount
else
# mount ro so fsck doesn't barf later
if [ "${REAL_ROOTFLAGS}" = '' ]; then
good_msg "Using mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE}"
mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE} ${REAL_ROOT} ${NEW_ROOT}
else else
# mount ro so fsck doesn't barf later good_msg "Using mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE},${REAL_ROOTFLAGS}"
if [ "${REAL_ROOTFLAGS}" = '' ]; then mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE},${REAL_ROOTFLAGS} ${REAL_ROOT} ${NEW_ROOT}
good_msg "Using mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE}"
mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE} ${REAL_ROOT} ${NEW_ROOT}
else
good_msg "Using mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE},${REAL_ROOTFLAGS}"
mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE},${REAL_ROOTFLAGS} ${REAL_ROOT} ${NEW_ROOT}
fi
fi fi
fi
# If mount is successful break out of the loop # If mount is successful break out of the loop
# else not a good root and start over. # else not a good root and start over.
if [ "$?" = '0' ] if [ "$?" = '0' ]
then then
# now that the root filesystem is mounted, before # now that the root filesystem is mounted, before
# checking the validity of ${NEW_ROOT} and ${REAL_INIT}, # checking the validity of ${NEW_ROOT} and ${REAL_INIT},
# ensure that ${NEW_ROOT}/etc/initramfs.mounts entries # ensure that ${NEW_ROOT}/etc/initramfs.mounts entries
# are mounted. # are mounted.
ensure_initramfs_mounts ensure_initramfs_mounts
# NFS does not need further checks here.
if is_nfs; then
break
fi
if [ ! -d "${NEW_ROOT}/dev" ]; then # NFS does not need further checks here.
_msg="The filesystem ${REAL_ROOT}," if is_nfs; then
_msg="${_msg} mounted at ${NEW_ROOT}"
_msg="${_msg} does not contain /dev"
_msg="${_msg}, init will likely fail..."
bad_msg "${_msg}"
fi
if [ ! -x "${NEW_ROOT}${REAL_INIT}" ]; then
_msg="The filesystem ${REAL_ROOT},"
_msg="${_msg} mounted at ${NEW_ROOT}"
_msg="${_msg} does not contain a valid"
_msg="${_msg} init=${REAL_INIT}"
bad_msg "${_msg}"
fi
break break
else
bad_msg "Could not mount specified ROOT, try again"
got_good_root=0
REAL_ROOT=''
fi fi
if [ ! -d "${NEW_ROOT}/dev" ]; then
_msg="The filesystem ${REAL_ROOT},"
_msg="${_msg} mounted at ${NEW_ROOT}"
_msg="${_msg} does not contain /dev"
_msg="${_msg}, init will likely fail..."
bad_msg "${_msg}"
fi
if [ ! -x "${NEW_ROOT}${REAL_INIT}" ]; then
_msg="The filesystem ${REAL_ROOT},"
_msg="${_msg} mounted at ${NEW_ROOT}"
_msg="${_msg} does not contain a valid"
_msg="${_msg} init=${REAL_INIT}"
bad_msg "${_msg}"
fi
break
else
bad_msg "Could not mount specified ROOT, try again"
got_good_root=0
REAL_ROOT=''
fi fi
done done
} }

Loading…
Cancel
Save