* 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>
|
2002-02-08 Yoshinori K. Okuji <okuji@enbug.org>
|
||||||
|
|
||||||
* grub/main.c (OPT_NO_PAGER): New macro.
|
* grub/main.c (OPT_NO_PAGER): New macro.
|
||||||
|
|
|
@ -175,6 +175,35 @@ convert () {
|
||||||
fi
|
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.
|
# Check the arguments.
|
||||||
for option in "$@"; do
|
for option in "$@"; do
|
||||||
case "$option" in
|
case "$option" in
|
||||||
|
@ -308,12 +337,8 @@ case "$install_device" in
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Get the root drive.
|
# Get the root drive.
|
||||||
# For now, this uses the program `df' to get the device name, but is
|
root_device=`find_device ${rootdir}`
|
||||||
# this really portable?
|
bootdir_device=`find_device ${bootdir}`
|
||||||
root_device=`df ${rootdir}/ | grep /dev/ \
|
|
||||||
| sed 's%.*\(/dev/[^ ]*\).*%\1%'`
|
|
||||||
bootdir_device=`df ${bootdir} | grep /dev/ \
|
|
||||||
| sed 's%.*\(/dev/[^ ]*\).*%\1%'`
|
|
||||||
|
|
||||||
# Check if the boot directory is in the same device as the root directory.
|
# Check if the boot directory is in the same device as the root directory.
|
||||||
if test "x$root_device" != "x$bootdir_device"; then
|
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
|
# Check if the root directory exists in the same device as the grub
|
||||||
# directory.
|
# directory.
|
||||||
grubdir_device=`df ${grubdir} | grep /dev/ \
|
grubdir_device=`find_device ${grubdir}`
|
||||||
| sed 's%.*\(/dev/[^ ]*\).*%\1%'`
|
|
||||||
if test "x$grubdir_device" != "x$root_device"; then
|
if test "x$grubdir_device" != "x$root_device"; then
|
||||||
# For now, cannot deal with this situation.
|
# For now, cannot deal with this situation.
|
||||||
cat <<EOF 1>&2
|
cat <<EOF 1>&2
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue