summaryrefslogtreecommitdiffstats
path: root/rescue/tree
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2001-06-11 21:38:14 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2001-06-11 21:38:14 +0000
commitdf52dd03d51f1728f15db0d89df54532811c1870 (patch)
tree129f30aa0488a013f19ce83c2107938ebd9a175f /rescue/tree
parentfa371367f838fb7dac00ff06e0e711ed68eb199e (diff)
downloaddrakx-backup-do-not-use-df52dd03d51f1728f15db0d89df54532811c1870.tar
drakx-backup-do-not-use-df52dd03d51f1728f15db0d89df54532811c1870.tar.gz
drakx-backup-do-not-use-df52dd03d51f1728f15db0d89df54532811c1870.tar.bz2
drakx-backup-do-not-use-df52dd03d51f1728f15db0d89df54532811c1870.tar.xz
drakx-backup-do-not-use-df52dd03d51f1728f15db0d89df54532811c1870.zip
umount as much as possible before rebooting the rescue
Diffstat (limited to 'rescue/tree')
-rw-r--r--rescue/tree/etc/inittab2
-rwxr-xr-xrescue/tree/sbin/fakeshutdown39
2 files changed, 40 insertions, 1 deletions
diff --git a/rescue/tree/etc/inittab b/rescue/tree/etc/inittab
index 0ee36784f..0348c66f4 100644
--- a/rescue/tree/etc/inittab
+++ b/rescue/tree/etc/inittab
@@ -4,7 +4,7 @@ id:3:initdefault:
si::sysinit:/etc/rc.sysinit
re:6:wait:/etc/rc.reboot
-ca:12345:ctrlaltdel:/sbin/init 6
+ca:12345:ctrlaltdel:/sbin/fakeshutdown
1:12345:respawn:/bin/bash --login
2:23:respawn:/sbin/mingetty tty2
diff --git a/rescue/tree/sbin/fakeshutdown b/rescue/tree/sbin/fakeshutdown
new file mode 100755
index 000000000..c6d9b8440
--- /dev/null
+++ b/rescue/tree/sbin/fakeshutdown
@@ -0,0 +1,39 @@
+#!/usr/bin/perl
+
+#
+# Guillaume Cottenceau (gc@mandrakesoft.com)
+#
+# Copyright 2001 MandrakeSoft
+#
+# This software may be freely redistributed under the terms of the GNU
+# public license.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+sub cat_ { local *F; open F, $_[0] or $_[1] ? die "cat of file $_[0] failed: $!\n" : return; my @l = <F>; wantarray ? @l : join '', @l }
+
+print "\n";
+
+
+#- try to umount as much as possible; uses Pixel's ultra optimized algo (let you guess how it works..)
+print "Umounting:\n";
+my @mounts = cat_('/proc/mounts');
+my $something_moved;
+do {
+ $something_moved = 0;
+ foreach (@mounts) {
+ my $where = (split)[1];
+ next if $where eq '/'; #- ouch! umounting the ramdisk on / always succeeds, and makes it becoming ro :-(
+ if (!system("umount $where 2>/dev/null")) {
+ print "\t$where\n";
+ $something_moved++;
+ }
+ }
+} while $something_moved;
+
+
+#- shutdown with init
+exec '/sbin/init', 6;