diff options
author | Harald Hoyer <harald@redhat.com> | 2013-07-30 15:33:10 +0200 |
---|---|---|
committer | Harald Hoyer <harald@redhat.com> | 2013-07-30 15:33:10 +0200 |
commit | 7fd850d58e1fea97783e5dc9426e4c523bd2324e (patch) | |
tree | df4e67ba690616d4d17154bf1cbd0676e77ab518 /dracut.sh | |
parent | 71bb2ecd79ca72ca6a82a43b37c3d34889c8099e (diff) | |
download | dracut-7fd850d58e1fea97783e5dc9426e4c523bd2324e.tar.gz dracut-7fd850d58e1fea97783e5dc9426e4c523bd2324e.tar.bz2 dracut-7fd850d58e1fea97783e5dc9426e4c523bd2324e.zip |
dracut.sh: check for file existance before trying to read from it
Diffstat (limited to 'dracut.sh')
-rwxr-xr-x | dracut.sh | 49 |
1 files changed, 27 insertions, 22 deletions
@@ -876,30 +876,35 @@ if [[ $hostonly ]]; then push host_devs "$_dev" done - while read dev type rest; do - [[ -b $dev ]] || continue - [[ "$type" == "partition" ]] || continue - while read _d _m _t _o _r; do - [[ "$_d" == \#* ]] && continue - [[ $_d ]] || continue - [[ $_t != "swap" ]] || [[ $_m != "swap" ]] && continue - [[ "$_o" == *noauto* ]] && continue - [[ "$_d" == UUID\=* ]] && _d="/dev/disk/by-uuid/${_d#UUID=}" - [[ "$_d" == LABEL\=* ]] && _d="/dev/disk/by-label/$_d#LABEL=}" - [[ "$_d" -ef "$dev" ]] || continue - - while read _mapper _a _p _o; do - [[ $_mapper = \#* ]] && continue - [[ "$_d" -ef /dev/mapper/"$_mapper" ]] || continue - [[ "$_o" ]] || _o="$_p" + if [[ -f /proc/swaps ]] && [[ -f /etc/fstab ]]; then + while read dev type rest; do + [[ -b $dev ]] || continue + [[ "$type" == "partition" ]] || continue + + while read _d _m _t _o _r; do + [[ "$_d" == \#* ]] && continue + [[ $_d ]] || continue + [[ $_t != "swap" ]] || [[ $_m != "swap" ]] && continue + [[ "$_o" == *noauto* ]] && continue + [[ "$_d" == UUID\=* ]] && _d="/dev/disk/by-uuid/${_d#UUID=}" + [[ "$_d" == LABEL\=* ]] && _d="/dev/disk/by-label/$_d#LABEL=}" + [[ "$_d" -ef "$dev" ]] || continue + + if [[ -f /etc/crypttab ]]; then + while read _mapper _a _p _o; do + [[ $_mapper = \#* ]] && continue + [[ "$_d" -ef /dev/mapper/"$_mapper" ]] || continue + [[ "$_o" ]] || _o="$_p" # skip mkswap swap - [[ $_o == *swap* ]] && continue 2 - done < /etc/crypttab + [[ $_o == *swap* ]] && continue 2 + done < /etc/crypttab + fi - push host_devs "$(readlink -f "$dev")" - break - done < /etc/fstab - done < /proc/swaps + push host_devs "$(readlink -f "$dev")" + break + done < /etc/fstab + done < /proc/swaps + fi fi _get_fs_type() { ( |