175 |
fi |
fi |
176 |
} |
} |
177 |
|
|
178 |
|
# Usage: find_device file |
179 |
|
# Find block device on which the file resides. |
180 |
|
find_device () { |
181 |
|
# For now, this uses the program `df' to get the device name, but is |
182 |
|
# this really portable? |
183 |
|
tmp_fname=`df $1/ | sed -n 's%.*\(/dev/[^ ]*\).*%\1%p'` |
184 |
|
|
185 |
|
if test -z "$tmp_fname"; then |
186 |
|
echo "Could not find device for $1" 2>&1 |
187 |
|
exit 1 |
188 |
|
fi |
189 |
|
|
190 |
|
# Resolve symlinks |
191 |
|
while test -L $tmp_fname; do |
192 |
|
tmp_new_fname=`ls -al /dev/hda1 | sed -n 's%.*-> %\1%p'` |
193 |
|
if test -z "$tmp_new_fname"; then |
194 |
|
echo "Unrecognized ls output" 2>&1 |
195 |
|
exit 1 |
196 |
|
fi |
197 |
|
|
198 |
|
# Convert relative symlinks |
199 |
|
case $tmp_new_fname in |
200 |
|
/*) tmp_fname="$tmp_new_fname" ;; |
201 |
|
*) tmp_fname="`echo $tmp_fname | sed 's%/[^/]*$%%'`/$tmp_new_fname" ;; |
202 |
|
esac |
203 |
|
done |
204 |
|
echo "$tmp_fname" |
205 |
|
} |
206 |
|
|
207 |
# Check the arguments. |
# Check the arguments. |
208 |
for option in "$@"; do |
for option in "$@"; do |
209 |
case "$option" in |
case "$option" in |
337 |
esac |
esac |
338 |
|
|
339 |
# Get the root drive. |
# Get the root drive. |
340 |
# For now, this uses the program `df' to get the device name, but is |
root_device=`find_device ${rootdir}` |
341 |
# 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%'` |
|
342 |
|
|
343 |
# 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. |
344 |
if test "x$root_device" != "x$bootdir_device"; then |
if test "x$root_device" != "x$bootdir_device"; then |
355 |
|
|
356 |
# 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 |
357 |
# directory. |
# directory. |
358 |
grubdir_device=`df ${grubdir} | grep /dev/ \ |
grubdir_device=`find_device ${grubdir}` |
359 |
| sed 's%.*\(/dev/[^ ]*\).*%\1%'` |
|
360 |
if test "x$grubdir_device" != "x$root_device"; then |
if test "x$grubdir_device" != "x$root_device"; then |
361 |
# For now, cannot deal with this situation. |
# For now, cannot deal with this situation. |
362 |
cat <<EOF 1>&2 |
cat <<EOF 1>&2 |