diff options
Diffstat (limited to 'packages/unionfs')
-rw-r--r-- | packages/unionfs/unionroot-utils/mount.unionroot | 88 | ||||
-rw-r--r-- | packages/unionfs/unionroot-utils/umount.unionroot | 86 | ||||
-rw-r--r-- | packages/unionfs/unionroot-utils_0.1.1.bb | 0 | ||||
-rw-r--r-- | packages/unionfs/unionroot-utils_0.1.bb | 42 | ||||
-rw-r--r-- | packages/unionfs/unionroot/init.unionroot | 87 | ||||
-rw-r--r-- | packages/unionfs/unionroot/init.unionroot.old | 0 | ||||
-rw-r--r-- | packages/unionfs/unionroot_0.1.1.bb | 0 | ||||
-rw-r--r-- | packages/unionfs/unionroot_0.1.bb | 40 |
8 files changed, 185 insertions, 158 deletions
diff --git a/packages/unionfs/unionroot-utils/mount.unionroot b/packages/unionfs/unionroot-utils/mount.unionroot index e69de29bb2..5fcf3cadf6 100644 --- a/packages/unionfs/unionroot-utils/mount.unionroot +++ b/packages/unionfs/unionroot-utils/mount.unionroot @@ -0,0 +1,88 @@ +#!/bin/sh + +#set -x + +ROOTMOUNTPT=/media/realroot +REALMOUNT=/bin/mount.busybox +UNIONMOUNT=$0 +INCDIRS="^/media/\|^/mnt/" +DEVICE="\/dev\/" + +newargs="" + +ONESHIFTARGS='aVhvfFilnsrw' +TWOSHIFTARGS="pLUtOo" +IGNOREARGS='--bind --move' + +resolvelink () { + if test -h $1; then + echo `readlink $1` + else + echo $1 + fi +} + +# Retrieves arguments/mount-point +for var in $@; do + if [ -z "$SKIP" ]; then + if echo $var | grep -q "^-.*"; then + if echo $var | grep -q "[$TWOSHIFTARGS]"; then + SKIP="yes" + fi + if echo $var | grep -q "^-[^- ]*a"; then + DO_FSTAB="yes" + fi + ARGS="$ARGS $var" + else + if [ -z "$MOUNT_POINT" ]; then + MOUNT_POINT=$var + else + DEV_PATH="$MOUNT_POINT" + MOUNT_POINT="$var" + fi + fi + else + ARGS="$ARGS $var" + unset SKIP + fi +done + +# Parse fstab if -a is used +if ! [ -z "$DO_FSTAB" ]; then + # FIXME: This doesn't handle -t or -O + awk '/^[^ #]/ {print "-t " $3 " -o " $4 " " $1 " " $2}' /etc/fstab | + while read line; do + ${UNIONMOUNT} $line + done + exit 0 +fi + +# Get mount-point for device name, if device name is given +if echo "$MOUNT_POINT" | grep -q "^${DEVICE}"; then + MOUNT_POINT_TEMP=`echo $MOUNT_POINT | sed -e "s/\//\\\\\\\\\//g"` + NEW_MOUNT_POINT=`awk "/$MOUNT_POINT_TEMP/ {print "'$2'"}" /etc/fstab` + if ! [ -z "$NEW_MOUNT_POINT" ]; then + MOUNT_POINT=$NEW_MOUNT_POINT + fi +fi + +if ! (echo "$MOUNT_POINT" | grep -q "$INCDIRS"||[ "$MOUNT_POINT" = "/" ]); then + exec ${REALMOUNT} $@ +fi + +# Replace requests to mount '/' (from init scripts and such) +# with mount ROOTMOUNTPT (the real-root mount point for the +# unionfs'd system). +packagedir="" +if ([ "$MOUNT_POINT" = "/" ]||[ "$MOUNT_POINT" = "${ROOTMOUNTPT}" ]); then + MOUNT_POINT=${ROOTMOUNTPT} +else + PACKAGE_DIR="/packages" +fi + +# Finally, mount and union-mount +if ${REALMOUNT} $ARGS $DEV_PATH $MOUNT_POINT; then + if mkdir -p $MOUNT_POINT$PACKAGE_DIR; then + unionctl /. --add --after ${ROOTMOUNTPT} --mode rw `resolvelink $MOUNT_POINT`$PACKAGE_DIR + fi +fi diff --git a/packages/unionfs/unionroot-utils/umount.unionroot b/packages/unionfs/unionroot-utils/umount.unionroot index e69de29bb2..df0eccb353 100644 --- a/packages/unionfs/unionroot-utils/umount.unionroot +++ b/packages/unionfs/unionroot-utils/umount.unionroot @@ -0,0 +1,86 @@ +#!/bin/sh + +#set -x + +ROOTMOUNTPT=/media/realroot +REALUMOUNT=/bin/umount.busybox +UNIONUMOUNT=$0 +INCDIRS="^/media/\|^/mnt/" +DEVICE="\/dev\/" + +newargs="" + +ONESHIFTARGS='adflnrv' +TWOSHIFTARGS="tO" + +resolvelink () { + if test -h $1; then + echo `readlink $1` + else + echo $1 + fi +} + +# Retrieves arguments/mount-point +for var in $@; do + if [ -z "$SKIP" ]; then + if echo $var | grep -q "^-.*"; then + if echo $var | grep -q "[$TWOSHIFTARGS]"; then + SKIP="yes" + fi + if echo $var | grep -q "^-[^- ]*a"; then + DO_FSTAB="yes" + fi + ARGS="$ARGS $var" + else + if [ -z "$MOUNT_POINT" ]; then + MOUNT_POINT=$var + else + # This really shouldn't happen when unmounting + DEV_PATH="$MOUNT_POINT" + MOUNT_POINT="$var" + fi + fi + else + ARGS="$ARGS $var" + unset SKIP + fi +done + +# Parse fstab if -a is used +if ! [ -z "$DO_FSTAB" ]; then + # FIXME: This doesn't handle -t or -O + awk '/^[^ #]/ {print $1}' /etc/fstab | + while read line; do + ${UNIONUMOUNT} $line + done + exit 0 +fi + +# Get mount-point for device name, if device name is given +if echo "$MOUNT_POINT" | grep -q "^${DEVICE}"; then + MOUNT_POINT_TEMP=`echo $MOUNT_POINT | sed -e "s/\//\\\\\\\\\//g"` + NEW_MOUNT_POINT=`awk "/$MOUNT_POINT_TEMP/ {print "'$2'"}" /etc/fstab` + if ! [ -z "$NEW_MOUNT_POINT" ]; then + MOUNT_POINT=$NEW_MOUNT_POINT + fi +fi + +if ! (echo "$MOUNT_POINT" | grep -q "$INCDIRS"||[ "$MOUNT_POINT" = "/" ]); then + exec ${REALMOUNT} $@ +fi + +# Replace requests to mount '/' (from init scripts and such) +# with mount ROOTMOUNTPT (the real-root mount point for the +# unionfs'd system). +packagedir="" +if ([ "$MOUNT_POINT" = "/" ]||[ "$MOUNT_POINT" = "${ROOTMOUNTPT}" ]); then + MOUNT_POINT=${ROOTMOUNTPT} +else + PACKAGE_DIR="/packages" +fi + +# Finally, umount and union-umount +unionctl /. --remove `resolvelink $MOUNT_POINT`$PACKAGE_DIR +exec ${REALUMOUNT} $ARGS $MOUNT_POINT + diff --git a/packages/unionfs/unionroot-utils_0.1.1.bb b/packages/unionfs/unionroot-utils_0.1.1.bb new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/unionfs/unionroot-utils_0.1.1.bb diff --git a/packages/unionfs/unionroot-utils_0.1.bb b/packages/unionfs/unionroot-utils_0.1.bb deleted file mode 100644 index ec5daecf57..0000000000 --- a/packages/unionfs/unionroot-utils_0.1.bb +++ /dev/null @@ -1,42 +0,0 @@ -LICENSE = "GPL" - -DESCRIPTION = "Tools for administering a system that utilises unionroot." -DEPENDS = "ipkg-collateral unionroot busybox" -RDEPENDS = "ipkg-collateral unionroot busybox" -SECTION = "base" -PRIORITY = "optional" -MAINTAINER = "Chris Lord <cwiiis@handhelds.org>" -PR = "r1" - -SRC_URI = "file://mount.unionroot \ - file://umount.unionroot" - -do_install () { - install -d ${D}/bin - install -m 0755 ${WORKDIR}/mount.unionroot ${D}/bin/ - install -m 0755 ${WORKDIR}/umount.unionroot ${D}/bin/ -} - -pkg_postinst () { - update-alternatives --install /bin/mount mount /bin/mount.unionroot 100 - update-alternatives --install /bin/umount umount /bin/umount.unionroot 100 - - # Alter /etc/ipkg.conf - mv $D/${sysconfdir}/ipkg.conf $D/${sysconfdir}/ipkg.conf.old - awk 'BEGIN { print "# Altered by unionroot" } - { if ( $3 == "/" ) - { - print $1 " " $2 " /media/realroot" - } - else - { - print $0 - } - }' $D/${sysconfdir}/ipkg.conf.old > $D/${sysconfdir}/ipkg.conf -} - -pkg_prerm () { - update-alternatives --remove mount /bin/mount.unionroot - update-alternatives --remove umount /bin/umount.unionroot -} - diff --git a/packages/unionfs/unionroot/init.unionroot b/packages/unionfs/unionroot/init.unionroot index 90aa4b015e..bfd86886a0 100644 --- a/packages/unionfs/unionroot/init.unionroot +++ b/packages/unionfs/unionroot/init.unionroot @@ -1,90 +1,25 @@ #!/bin/sh +PATH=/usr/bin:/usr/sbin:/bin:/sbin INIT=/sbin/init.sysvinit -#OVERLAYS=/media/ram /media/cf /media/card ROOTBACKUP=/media/realroot UNION=/media/union -PATH=/usr/bin:/usr/sbin:/bin:/sbin - -if ! test -e ${INIT}; then - echo >&2 "ERROR: ${INIT} not found" - exit 1 -fi -if test x"$*" != "x"; then - exec ${INIT} $* +if ! which unionctl; then + echo >&2 "ERROR: Package unionfs-utils not installed!" + exec ${INIT} $@ fi -if ! which unionctl; then - exec ${INIT} +# For shutdown +if ! [ -z "$@" ]; then + exec ${INIT} $@ fi -nodupmount () { - opts="" - type="" - while true; do - if test "$1" = "-o"; then - shift - opts="-o $1" - shift - elif test "$1" = "-t"; then - shift - type="$1" - shift - else - break - fi - done - if test x"$2" = "x"; then - mountpt="$1" - else - device="$1" - mountpt="$2" - fi - mountmatch="^[^ ]+ $mountpt $type" - # echo "NOTE: grep -E -q \"$mountmatch\" /proc/mounts" - if grep -E -q "$mountmatch" /proc/mounts; then - return 0; - fi - if test x"$type" != "x"; then - type="-t $type" - fi - echo >&2 "NOTE: executing mount $type $opts $device $mountpt" - mkdir -p $mountpt - /bin/mount.busybox $type $opts $device $mountpt - ret="$?" - if test "$ret" = "0"; then - wemounted="$wemounted $mountpt" - fi - return $ret -} +mount.busybox /proc +insmod /lib/modules/`uname -r`/kernel/fs/unionfs.o +mount.busybox -t unionfs -o dirs=/.=rw,setattr=all none ${UNION} +umount.busybox /proc -#set -x -wemounted="" -( - set -e - /bin/mount.busybox /proc - insmod /lib/modules/`uname -r`/kernel/fs/unionfs.o - nodupmount -t unionfs -o dirs=/.=rw none ${UNION} -# nodupmount -o bind / ${UNION}/${ROOTBACKUP} -# for OVERLAY in ${OVERLAYS}; do -# nodupmount ${OVERLAY} -# union-ctl /. --add --mode rw ${OVERLAY} -# nodupmount -o bind ${OVERLAY} ${UNION}/${OVERLAY} -# done - /bin/umount.busybox /proc -# nodupmount -o bind /proc ${UNION}/proc -# nodupmount -o bind / ${ROOTBACKUP} -) || ( - echo >&2 "ERROR: unable to setup mounts for chroot"; - if test x"$wemounted" != "x"; then - # cleanup - for mount in $wemounted; do - /bin/umount.busybox $mount - done - fi - exec ${INIT} -) cd ${UNION} pivot_root . ./${ROOTBACKUP} exec chroot . ${INIT} diff --git a/packages/unionfs/unionroot/init.unionroot.old b/packages/unionfs/unionroot/init.unionroot.old new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/unionfs/unionroot/init.unionroot.old diff --git a/packages/unionfs/unionroot_0.1.1.bb b/packages/unionfs/unionroot_0.1.1.bb new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/unionfs/unionroot_0.1.1.bb diff --git a/packages/unionfs/unionroot_0.1.bb b/packages/unionfs/unionroot_0.1.bb deleted file mode 100644 index 79b79b5f94..0000000000 --- a/packages/unionfs/unionroot_0.1.bb +++ /dev/null @@ -1,40 +0,0 @@ -LICENSE = "GPL" - -DESCRIPTION = "Provides an init script that changes the root file-system to unionfs." -DEPENDS = "busybox base-files" -RDEPENDS = "busybox base-files" -SECTION = "base" -PRIORITY = "optional" -MAINTAINER = "Chris Lord <cwiiis@handhelds.org>" - -PR = "r2" - -SRC_URI = "file://init.unionroot" - -inherit update-alternatives - -ALTERNATIVE_NAME = "init" -ALTERNATIVE_LINK = "/sbin/init" -ALTERNATIVE_PATH = "/sbin/init.unionroot" -ALTERNATIVE_PRIORITY = "100" - -do_install () { - install -d ${D}/sbin - install -m 0755 ${WORKDIR}/init.unionroot ${D}/sbin/ -} - -pkg_postinst () { - # Alter /etc/fstab - mv $D/${sysconfdir}/fstab $D/${sysconfdir}/fstab.old - awk 'BEGIN { print "# Altered by unionroot" } - { if ( $2 == "/" ) - { - print $1 "\t/media/realroot\t" $3 "\t" $4 "\t" $5 "\t" $6 - } - else - { - print $0 - } - }' $D/${sysconfdir}/fstab.old > $D/${sysconfdir}/fstab -} - |