* util/grub-install.in (find_device): New function - find block
device for given file or directory. Resolve symlinks to fix problem on Linux with devfs and old device names in /etc/fstab. Use find_device() for root_device, bootdir_device and grubdir_device.
This commit is contained in:
parent
c34bb04818
commit
a751da838c
2 changed files with 41 additions and 8 deletions
|
@ -1,3 +1,11 @@
|
|||
2002-02-11 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* util/grub-install.in (find_device): New function - find block
|
||||
device for given file or directory. Resolve symlinks to fix
|
||||
problem on Linux with devfs and old device names in /etc/fstab.
|
||||
Use find_device() for root_device, bootdir_device and
|
||||
grubdir_device.
|
||||
|
||||
2002-02-08 Yoshinori K. Okuji <okuji@enbug.org>
|
||||
|
||||
* grub/main.c (OPT_NO_PAGER): New macro.
|
||||
|
|
|
@ -175,6 +175,35 @@ convert () {
|
|||
fi
|
||||
}
|
||||
|
||||
# Usage: find_device file
|
||||
# Find block device on which the file resides.
|
||||
find_device () {
|
||||
# For now, this uses the program `df' to get the device name, but is
|
||||
# this really portable?
|
||||
tmp_fname=`df $1/ | sed -n 's%.*\(/dev/[^ ]*\).*%\1%p'`
|
||||
|
||||
if test -z "$tmp_fname"; then
|
||||
echo "Could not find device for $1" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Resolve symlinks
|
||||
while test -L $tmp_fname; do
|
||||
tmp_new_fname=`ls -al /dev/hda1 | sed -n 's%.*-> %\1%p'`
|
||||
if test -z "$tmp_new_fname"; then
|
||||
echo "Unrecognized ls output" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Convert relative symlinks
|
||||
case $tmp_new_fname in
|
||||
/*) tmp_fname="$tmp_new_fname" ;;
|
||||
*) tmp_fname="`echo $tmp_fname | sed 's%/[^/]*$%%'`/$tmp_new_fname" ;;
|
||||
esac
|
||||
done
|
||||
echo "$tmp_fname"
|
||||
}
|
||||
|
||||
# Check the arguments.
|
||||
for option in "$@"; do
|
||||
case "$option" in
|
||||
|
@ -308,12 +337,8 @@ case "$install_device" in
|
|||
esac
|
||||
|
||||
# Get the root drive.
|
||||
# For now, this uses the program `df' to get the device name, but is
|
||||
# this really portable?
|
||||
root_device=`df ${rootdir}/ | grep /dev/ \
|
||||
| sed 's%.*\(/dev/[^ ]*\).*%\1%'`
|
||||
bootdir_device=`df ${bootdir} | grep /dev/ \
|
||||
| sed 's%.*\(/dev/[^ ]*\).*%\1%'`
|
||||
root_device=`find_device ${rootdir}`
|
||||
bootdir_device=`find_device ${bootdir}`
|
||||
|
||||
# Check if the boot directory is in the same device as the root directory.
|
||||
if test "x$root_device" != "x$bootdir_device"; then
|
||||
|
@ -330,8 +355,8 @@ fi
|
|||
|
||||
# Check if the root directory exists in the same device as the grub
|
||||
# directory.
|
||||
grubdir_device=`df ${grubdir} | grep /dev/ \
|
||||
| sed 's%.*\(/dev/[^ ]*\).*%\1%'`
|
||||
grubdir_device=`find_device ${grubdir}`
|
||||
|
||||
if test "x$grubdir_device" != "x$root_device"; then
|
||||
# For now, cannot deal with this situation.
|
||||
cat <<EOF 1>&2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue