Comment 4 for bug 175772

Revision history for this message
Agostino Russo (ago) wrote :

Safer code

loop_file=$(awk '$2=="/" && $4~"loop" {print $1}' /etc/fstab)
if [ -f "$loop_file" ]; then
    dev_mountpoint=$(awk '"'${loop_file}'"~"^"$2 && $2!="/" {print $1";"$2}' /proc/mounts|tail -n 1)
    host_device="${dev_mountpoint%;*}"
    host_mountpoint="${dev_mountpoint#*;}"
fi
if [ -n "$host_device" ]; then
    boot_device=
    root_device="$host_device"
    default_kopt="root=$host_device loop=${loop_file#$host_mountpoint} ro"
else
    default_kopt="root=$root_device ro"
fi
kopt="$default_kopt"