diff options
author | Matthias Hentges <oe@hentges.net> | 2005-07-21 03:28:55 +0000 |
---|---|---|
committer | OpenEmbedded Project <openembedded-devel@lists.openembedded.org> | 2005-07-21 03:28:55 +0000 |
commit | 5c8f0ac921d317857f53af063b6158fe450e3977 (patch) | |
tree | 1d419644017f9a9f2acc62908c7066806cdd078a /packages/openslug-init/openslug-init-0.10 | |
parent | 106a843b00bc7003f3dcdaeca83d453b595b49c3 (diff) | |
parent | 79854f3a16e4bd18ae87450fde8061778f192585 (diff) |
merge of 60b47beac72c6f1f23514b42a309716b470d471b
and a6f1ef5bbb3cac8192d0a7bc6d5c64b301e70463
Diffstat (limited to 'packages/openslug-init/openslug-init-0.10')
-rwxr-xr-x | packages/openslug-init/openslug-init-0.10/functions | 87 | ||||
-rw-r--r-- | packages/openslug-init/openslug-init-0.10/reflash | 54 | ||||
-rw-r--r-- | packages/openslug-init/openslug-init-0.10/turnup | 32 |
3 files changed, 108 insertions, 65 deletions
diff --git a/packages/openslug-init/openslug-init-0.10/functions b/packages/openslug-init/openslug-init-0.10/functions index ac8e195abd..55f3397462 100755 --- a/packages/openslug-init/openslug-init-0.10/functions +++ b/packages/openslug-init/openslug-init-0.10/functions @@ -209,10 +209,13 @@ ifup(){ # is not left running so this will only work for # the lease length time! ifconfig "$iface" up - test -n "$hostname" && HOSTNAME="-H $hostname" - # The script writes the required shell variable assignments - # to file descriptor 9 - eval $(udhcpc -i "$iface" -n -q -r "$ip" $HOSTNAME -s /boot/udhcpc.script 9>&1 >/dev/null) + if test "$(config boot)" != static + then + test -n "$hostname" && HOSTNAME="-H $hostname" + # The script writes the required shell variable assignments + # to file descriptor 9 + eval $(udhcpc -i "$iface" -n -q -r "$ip" $HOSTNAME -s /boot/udhcpc.script 9>&1 >/dev/null) + fi test -n "$broadcast" && BROADCAST="broadcast $broadcast" test -n "$subnet" && NETMASK="netmask $subnet" @@ -236,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 @@ -248,14 +258,71 @@ 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 "$mp/$type" in + //jffs2);; # skip / + */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 } |