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
if [ "${got_good_root}" = "1" ] && is_livecd && ! is_nfs
then
if [ "${got_good_root}" = "1" ] && is_livecd && ! is_nfs; then
# CD already mounted; no further checks necessary
break
elif [ "${LOOPTYPE}" = "sgimips" ]
then
fi
if [ "${LOOPTYPE}" = "sgimips" ]; then
# sgimips mounts the livecd root partition directly
# there is no isofs filesystem to worry about
break
else
good_msg "Mounting $REAL_ROOT as root..."
fi
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
if [ "$(zfs get -H -o value mountpoint ${REAL_ROOT})" = 'legacy' ]
then
MOUNT_STATE=rw
else
MOUNT_STATE=rw,zfsutil
fi
MOUNT_STATE=rw
else
MOUNT_STATE=ro
MOUNT_STATE=rw,zfsutil
fi
else
MOUNT_STATE=ro
fi
# Try to mount the device as ${NEW_ROOT}
if is_nfs; then
findnfsmount
# Try to mount the device as ${NEW_ROOT}
if is_nfs; then
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
# 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
good_msg "Using mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE},${REAL_ROOTFLAGS}"
mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE},${REAL_ROOTFLAGS} ${REAL_ROOT} ${NEW_ROOT}
fi
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
# If mount is successful break out of the loop
# else not a good root and start over.
if [ "$?" = '0' ]
then
# now that the root filesystem is mounted, before
# checking the validity of ${NEW_ROOT} and ${REAL_INIT},
# ensure that ${NEW_ROOT}/etc/initramfs.mounts entries
# are mounted.
ensure_initramfs_mounts
# NFS does not need further checks here.
if is_nfs; then
break
fi
# If mount is successful break out of the loop
# else not a good root and start over.
if [ "$?" = '0' ]
then
# now that the root filesystem is mounted, before
# checking the validity of ${NEW_ROOT} and ${REAL_INIT},
# ensure that ${NEW_ROOT}/etc/initramfs.mounts entries
# are mounted.
ensure_initramfs_mounts
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
# NFS does not need further checks here.
if is_nfs; then
break
else
bad_msg "Could not mount specified ROOT, try again"
got_good_root=0
REAL_ROOT=''
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
done
}

Loading…
Cancel
Save