Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 68697 - halt.sh: more simple filesystem unmounting
Summary: halt.sh: more simple filesystem unmounting
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-24 05:55 UTC by Georg Sauthoff
Modified: 2004-12-03 19:47 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
diff against halt.sh from baselayout 1.9.4-r6 (halt.sh.diff,2.24 KB, patch)
2004-10-24 05:56 UTC, Georg Sauthoff
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Georg Sauthoff 2004-10-24 05:55:04 UTC
halt.sh uses the sort program in the mount_readonly() method. Since sort is located at /usr/bin/sort this is a problem, if you have /usr at a separate partition.
In this case the /usr partition is already unmounted and sort could not be found by the bash.

Hence my patch uses awk to reverse the /proc/mounts content. Let's assume that / is at the first line in every case, you don't need to sort the file, before reversing. But this patch does sorting before reversing.

2nd the patch simplifies the unmounting filesystem statements. Reducing time from O(n^2) to O(n) (n is the number of lines of the mount output).

The patch is against baselayout 1.9.4-r6. I looked at 1.10.4 and 1.11.2, where halt.sh has the same problems.

The first part is critical, because / isn't remounted readonly if you have /usr at a separate partition.

Patch is attached.

Regards
Georg Sauthoff

Reproducible: Always
Steps to Reproduce:
1.
2.
3.
Comment 1 Georg Sauthoff 2004-10-24 05:56:30 UTC
Created attachment 42489 [details, diff]
diff against halt.sh from baselayout 1.9.4-r6
Comment 2 SpanKY gentoo-dev 2004-10-24 21:11:47 UTC
sort is in /bin ... if it isnt on your system, you need to update your coreutils

that means the only thing here is a suggested update from using sort to awk
Comment 3 Georg Sauthoff 2004-10-25 00:27:55 UTC
Hi,

> sort is in /bin ... if it isnt on your system, you need to update your coreutils

ok, then the baselayout package should depend on a recent coreutils version, rigt?

> that means the only thing here is a suggested update from using sort to awk

No, I suggested two things with that patch. The 2nd thing is to simplify the unmounting fs loop. Of course this is not critical. But the current loop is somehow stupid.

Regards
Comment 4 SpanKY gentoo-dev 2004-10-25 06:01:33 UTC
not really ... it's moved around between versions, latest stable should have it in the right place
Comment 5 Georg Sauthoff 2004-10-30 04:58:36 UTC
> not really ... it's moved around between versions, latest stable should
> have it in the right place

Hm, the /usr/bin/sort is from sys-apps/textutils-2.1. Hence baselayout-1.9.4-r6 (stable version) needs a sort at /bin/sort, which is provided by sys-apps/coreutils-5.2.1, why shouldn't depend the baselayout package at a recent coreutils version?

Without that dependency, you get a broken baselayout upgrade from older systems.

Regards
Comment 6 Martin Schlemmer (RETIRED) gentoo-dev 2004-11-15 11:48:23 UTC
Your awk is broken for one:

-----
nosferatu ~ # mount | awk '{ \
if (($5 !~ /^(proc|sysfs|devfs|tmpfs|usb(dev)?fs)$/) &&
                                ($1 != "none") &&
                                ($1 !~ /^(rootfs|\/dev\/root)$/) &&
                                ($3 != "/"))
                            print $3
                        }' | sort | uniq
nosferatu ~ # mount | awk '{ if (($5 ~ /^(proc|sysfs|devfs|tmpfs|usb(dev)?fs)$/) ||
                                ($1 == "none") ||
                                ($1 ~ /^(rootfs|\/dev\/root)$/) ||
                                ($3 == "/"))
                            print $3
                        }' | sort | uniq
/
/dev
/dev/pts
/dev/shm
/proc
/proc/bus/usb
/sys
nosferatu ~ # mount | awk '{ \
if (($5 !~ /^(proc|sysfs|devfs|tmpfs|usb(dev)?fs)$/) &&
                                ($1 != "none") &&
                                ($1 !~ /^(rootfs|\/dev\/root)$/) &&
                                ($3 != "/"))
                            print $3
                        }' | sort | uniq
nosferatu ~ # 
-----

Secondly, sort have been in /bin since whenever.
Comment 7 Martin Schlemmer (RETIRED) gentoo-dev 2004-11-15 11:52:28 UTC
Below has been the case since coreutils-5.0 at least:

-----
nosferatu ~ # ls -l /bin/sort
-rwxr-xr-x  1 root root 62112 Oct 21 07:16 /bin/sort
nosferatu ~ # ls -l /usr/bin/sort
lrwxrwxrwx  1 root root 14 Oct 21 07:16 /usr/bin/sort -> ../../bin/sort
nosferatu ~ # epm -qf /bin/sort
coreutils-5.2.1-r2
nosferatu ~ # epm -qf /usr/bin/sort
coreutils-5.2.1-r2
nosferatu ~ #
-----
Comment 8 Martin Schlemmer (RETIRED) gentoo-dev 2004-11-15 11:57:01 UTC
Sorry, I was on drugs.  The first part of the patch is fine.  The second part
is bugus though, as we have moved sort to /bin a long time ago (baselayout
only started to use it there when moved).
Comment 9 Martin Schlemmer (RETIRED) gentoo-dev 2004-11-15 12:01:52 UTC
Another thing to change might be 'sort | uniq' -> 'sort -u' ...
Comment 10 Georg Sauthoff 2004-11-21 06:47:37 UTC
Hi,

> Secondly, sort have been in /bin since whenever.

> the second part
> is bugus though, as we have moved sort to /bin a long time ago (baselayout
> only started to use it there when moved).

If baselayout started using /bin/sort when moved - why don't express this change with a correct dependency?

There are users, who doesn't reinstall their sytem from scratch every month. This dependency cost anything nor have side effects. Smooth updating should be a very important goal for a distribution.

In the current state, if something depend on a current baselayout, you get a broken baselayout, because it doesn't depend on a recent coretutils.

Hence, that sort is in /bin since whenever is really no argument.

Of course the 2nd part is bogus. If sort is now in /bin, you need a right dependency and no sort replacement by awk.

Regards
Comment 11 Martin Schlemmer (RETIRED) gentoo-dev 2004-11-26 12:52:12 UTC
Because it has been like that for over a year now?  If somebody have not updated
in a year, and wants to do that now (or only update baselayout), there are other
more severe issues he will have to worry about.  It really will be a redundent
dependency, and might cause issues during bootstrap again (will have to figure
out correct checking of 'build' and 'bootstrap' and prob other build flags these
days ...).
Comment 12 SpanKY gentoo-dev 2004-12-03 19:47:59 UTC
merged your ideas into cvs, look for it in 1.11.7

thanks :)