summaryrefslogtreecommitdiff
path: root/packages/openslug-init
diff options
context:
space:
mode:
authorJohn Bowler <jbowler@nslu2-linux.org>2005-07-19 06:31:56 +0000
committerOpenEmbedded Project <openembedded-devel@lists.openembedded.org>2005-07-19 06:31:56 +0000
commit1b45793e53bc6eb1ac71ef2f051359b674815788 (patch)
tree945695c44dcd9ca1ad8e0bd8fc514a6c6db0eda5 /packages/openslug-init
parente76d9a8ba9c798803949a61da8d5e72c66ec7f7b (diff)
slugbug 206: fix the tmpfs directories in NFS
slugbug 207: fix the flashdisk mount so that it works in the presence of an existing readonly mount (turnup, like reflash, now removes all existing flashdisk mounts)
Diffstat (limited to 'packages/openslug-init')
-rwxr-xr-xpackages/openslug-init/openslug-init-0.10/functions75
-rw-r--r--packages/openslug-init/openslug-init-0.10/reflash54
-rw-r--r--packages/openslug-init/openslug-init-0.10/turnup32
-rw-r--r--packages/openslug-init/openslug-init_0.10.bb2
4 files changed, 101 insertions, 62 deletions
diff --git a/packages/openslug-init/openslug-init-0.10/functions b/packages/openslug-init/openslug-init-0.10/functions
index 61b5eb2776..43b109977d 100755
--- a/packages/openslug-init/openslug-init-0.10/functions
+++ b/packages/openslug-init/openslug-init-0.10/functions
@@ -239,11 +239,18 @@ ifdown(){
ifconfig "$1" down
}
#
-# mountflash "flash root directory" {mount options}
+# mountflash "flash device" "flash root directory" {mount options}
# Finds and mounts the flash file system on the given directory
mountflash() {
local ffsdev ffsdir
+ ffsdev="$1"
+ test -n "$ffsdev" -a -b "$ffsdev" || {
+ echo "$0: unable to find flash file system to copy ($ffsdev)" >&2
+ return 1
+ }
+ shift
+
ffsdir="$1"
test -n "$ffsdir" -a -d "$ffsdir" || {
echo "$0: mountflash $ffsdir: not a directory (internal error)" >&2
@@ -251,14 +258,70 @@ mountflash() {
}
shift
- ffsdev="$(mtblockdev Flashdisk)"
- test -n "$ffsdev" -a -b "$ffsdev" || {
- echo "$0: unable to find flash file system to copy ($ffsdev)" >&2
- return 1
- }
mount -t jffs2 "$@" "$ffsdev" "$ffsdir" || {
echo "$0: $ffsdev: unable to mount flash file system on $ffsdir" >&2
return 1
}
return 0
}
+#
+# umountflash [-r] "flash device"
+# unmount any instance of the given flash device, if -r is specified a mount on
+# root is an error, otherwise a mount on root is ignored (and remains).
+umountflash() {
+ local rootok ffsno ffsdev
+ rootok=1
+ case "$1" in
+ -r) rootok=
+ shift;;
+ esac
+ #
+ # The argument is ffsdev
+ ffsdev="$1"
+ ffsno="$(devio "<<$ffsdev" prd)"
+ test -n "$ffsno" -a "$ffsno" -ge 0 || {
+ echo "$0: $ffsdev: device number $ffsno is not valid, cannot continue." >&2
+ return 1
+ }
+ #
+ # Make sure that Flashdisk isn't mounted on /
+ if test -z "$rootok" -a "$(devio "<</etc/init.d/sysconfsetup" prd)" -eq "$ffsno"
+ then
+ echo "$0: $ffsdev is mounted on /, use turnup ram" >&2
+ return 1
+ fi
+ #
+ # The function is currently always used interactively, so output
+ echo "$0: umounting any existing mount of $ffsdev" >&2
+ #
+ # check each mount point, do this last first because otherwise nested
+ # mounts of ffsdev cannot be umounted.
+ ffs_umount() {
+ local device mp type options stuff
+
+ read device mp type options stuff
+ test -z "$device" && return 0
+
+ # handle following entries first
+ ffs_umount || return 1
+
+ # handle this entry, since this is currently only used for unmounting
+ # the flash root partition we know a file which must exist...
+ case "$type" in
+ jffs2) test "$(devio "<<$mp/etc/init.d/sysconfsetup" prd 2>/dev/null)" -ne "$ffsno" ||
+ umount "$mp" || {
+ echo "$0: $mp: unable to umount $ffsdev" >&2
+ return 1
+ };;
+ esac
+
+ return 0
+ }
+ #
+ ffs_umount </proc/mounts || {
+ echo "$0: umount $ffsdev from all mount points then re-run reflash" >&2
+ return 1
+ }
+
+ return 0
+}
diff --git a/packages/openslug-init/openslug-init-0.10/reflash b/packages/openslug-init/openslug-init-0.10/reflash
index 504e78f694..bcf51fc606 100644
--- a/packages/openslug-init/openslug-init-0.10/reflash
+++ b/packages/openslug-init/openslug-init-0.10/reflash
@@ -213,59 +213,15 @@ then
exit 1
}
fi
-#
-# find the device number of the flash partition then make sure it isn't
-# mounted anywhere.
-if test -n "$ffsdev"
-then
- ffsno="$(devio "<<$ffsdev" prd)"
- test -n "$ffsno" -a "$ffsno" -ge 0 || {
- echo "reflash: $ffsdev: device number $ffsno is not valid, cannot continue." >&2
- exit 1
- }
- #
- # Make sure that Flashdisk isn't mounted on /
- if test "$(devio "<</etc/init.d/sysconfsetup" prd)" -eq "$ffsno"
- then
- echo "reflash: $ffsdev is mounted on /, use turnup ram to reflash" >&2
- exit 1
- fi
-fi
+
#
# INPUTS OK, ENVIRONMENT OK, UMOUNT ANY EXISTING MOUNT OF THE FLASHDISK
# ---------------------------------------------------------------------
# This is only required if the device is going to be used
if test -n "$ffsdev"
then
- echo "reflash: umounting any existing mount of $ffsdev" >&2
- #
- # check each mount point, do this last first because otherwise nested
- # mounts of ffsdev cannot be umounted.
- ffs_umount() {
- local device mp type options stuff
-
- read device mp type options stuff
- test -z "$device" && return 0
-
- # handle following entries first
- ffs_umount || return 1
-
- # handle this entry
- case "$type" in
- jffs2) test "$(devio "<<$mp/etc/init.d/sysconfsetup" prd)" -ne "$ffsno" ||
- umount "$mp" || {
- echo "reflash: $mp: unable to umount $ffsdev" >&2
- return 1
- };;
- esac
-
- return 0
- }
- #
- ffs_umount </proc/mounts || {
- echo "reflash: umount $ffsdev from all mount points then re-run reflash" >&2
- exit 1
- }
+ # -r causes this to fail if the flash device is mounted on /
+ umountflash -r "$ffsdev" || exit 1
#
# Everything is umounted, now remount on a temporary directory.
ffsdir="/tmp/flashdisk.$$"
@@ -274,7 +230,7 @@ then
exit 1
}
#
- mountflash "$ffsdir" -o ro || {
+ mountflash "$ffsdev" "$ffsdir" -o ro || {
rmdir "$ffsdir"
exit 1
}
@@ -471,7 +427,7 @@ echo "reflash: restoring saved configuration files" >&2
# /etc/rcS.d/S99finish on first boot (if it does not exist). We need
# a timestamp earlier than any files we create so touch it here, this
# also acts as a test on the mounted file system
-mountflash "$ffsdir" && :>"$ffsdir/etc/.configured" || {
+mountflash "$ffsdev" "$ffsdir" && :>"$ffsdir/etc/.configured" || {
rmdir "$ffsdir"
echo "reflash: mount of new flash root file system failed" >&2
if test -d "$ffsdir/etc"
diff --git a/packages/openslug-init/openslug-init-0.10/turnup b/packages/openslug-init/openslug-init-0.10/turnup
index ce504b022e..0029697c50 100644
--- a/packages/openslug-init/openslug-init-0.10/turnup
+++ b/packages/openslug-init/openslug-init-0.10/turnup
@@ -4,10 +4,13 @@
#
. /etc/default/functions
+#
+# configuration
+# The following variables control which directories in /var end up on the rootfs
+# and which end up in a temporary file system.
INRAM_MEMSTICK="/var/cache /var/lock /var/log /var/run /var/tmp /var/lib/ipkg"
-INRAM_NFS="/var/cache /var/run"
+INRAM_NFS="/var/cache /var/lock /var/run /var/tmp"
INRAM_DISK=""
-
#
# force: override certain checks
force=
@@ -61,6 +64,23 @@ fsoptions() {
fi
}
#
+# get_flash <directory> {mount options}
+# mount the flash device, writeable, on the given directory
+get_flash() {
+ local ffsdir ffsdev
+
+ ffsdir="$1"
+ shift
+ test -n "$ffsdir" -a -d "$ffsdir" || {
+ echo "$0: $ffsdir: internal error, flash mount point not a directory" >&2
+ return 1
+ }
+
+ ffsdev="$(mtblockdev Flashdisk)"
+ umountflash "$ffsdev" &&
+ mountflash "$ffsdev" "$ffsdir" "$@"
+}
+#
# check_rootfs [-i] <root fs directory>
# Make sure the candidate rootfs is empty
check_rootfs() {
@@ -425,7 +445,7 @@ disk() {
}
# make sure we can get to the flash file system first
- mountflash "$ffs" || {
+ get_flash "$ffs" || {
rmdir "$new" "$ffs"
return 1
}
@@ -509,7 +529,7 @@ boot_reset() {
return 1
}
- mountflash "$ffs" || {
+ get_flash "$ffs" || {
rmdir "$ffs"
return 1
}
@@ -558,7 +578,7 @@ nfs() {
}
# make sure we can get to the flash file system first
- mountflash "$ffs" || {
+ get_flash "$ffs" || {
rmdir "$new" "$ffs"
return 1
}
@@ -670,7 +690,7 @@ fix_hw_addr() {
# this isn't the flash device
ffs="/tmp/flashdisk.$$"
# make sure we can get to the flash file system first
- mountflash "$ffs" || {
+ get_flash "$ffs" || {
rmdir "$ffs"
return 1
}
diff --git a/packages/openslug-init/openslug-init_0.10.bb b/packages/openslug-init/openslug-init_0.10.bb
index 60726d8dc2..fd2080ff65 100644
--- a/packages/openslug-init/openslug-init_0.10.bb
+++ b/packages/openslug-init/openslug-init_0.10.bb
@@ -3,7 +3,7 @@ SECTION = "console/network"
LICENSE = "GPL"
DEPENDS = "base-files devio"
RDEPENDS = "busybox devio"
-PR = "r39"
+PR = "r40"
SRC_URI = "file://linuxrc \
file://boot/flash \