5 ROOTMOUNTPT=/media/realroot
6 REALMOUNT=/bin/mount.busybox
8 INCDIRS="^/media/\|^/mnt/"
13 ONESHIFTARGS='aVhvfFilnsrw'
15 IGNOREARGS='--bind --move'
25 # Retrieves arguments/mount-point
27 if [ -z "$SKIP" ]; then
28 if echo $var | grep -q "^-.*"; then
29 # argument is an option
30 if echo $var | grep -q "[$TWOSHIFTARGS]"; then
34 if echo $var | grep -q "^-[^- ]*a"; then
39 if [ -z "$MOUNT_POINT" ]; then
40 # argument apears to be the mountpoint
43 # A mountpoint was found earlier, so the other non-option
44 # must be the real mountpoint, and the first non-option is a device
45 DEV_PATH="$MOUNT_POINT"
55 # Parse fstab if -a is used
56 if ! [ -z "$DO_FSTAB" ]; then
57 # FIXME: This doesn't handle -t or -O
58 awk '/^[^ #]/ {print "-t " $3 " -o " $4 " " $1 " " $2}' /etc/fstab |
65 # Get mount-point for device name, if device name is given
66 if echo "$MOUNT_POINT" | grep -q "^${DEVICE}"; then
67 MOUNT_POINT_TEMP=`echo $MOUNT_POINT | sed -e "s/\//\\\\\\\\\//g"`
68 NEW_MOUNT_POINT=`awk "/$MOUNT_POINT_TEMP/ {print "'$2'"}" /etc/fstab`
69 if ! [ -z "$NEW_MOUNT_POINT" ]; then
70 MOUNT_POINT=$NEW_MOUNT_POINT
74 # Mount anything but /media/* and / with the real mount
75 if ! (echo "$MOUNT_POINT" | grep -q "$INCDIRS" || [ "$MOUNT_POINT" = "/" ]); then
79 # Replace requests to mount '/' (from init scripts and such)
80 # with mount ROOTMOUNTPT (the real-root mount point for the
83 if ([ "$MOUNT_POINT" = "/" ] || [ "$MOUNT_POINT" = "${ROOTMOUNTPT}" ]); then
84 MOUNT_POINT=${ROOTMOUNTPT}
86 # FIXME: A hard-coded path is bad - see ipkg-link
87 PACKAGE_DIR="/packages"
91 # Finally, mount and union-mount
92 #echo "<<DEBUG>> Running command: [${REALMOUNT} $ARGS $DEV_PATH $MOUNT_POINT]"
93 if ${REALMOUNT} $ARGS $DEV_PATH $MOUNT_POINT; then
94 if mkdir -p $MOUNT_POINT$PACKAGE_DIR; then
95 #echo "<<DEBUG>> Running command: [unionctl /. --add --after ${ROOTMOUNTPT} --mode rw `resolvelink $MOUNT_POINT`$PACKAGE_DIR]"
96 #unionctl /. --add --after ${ROOTMOUNTPT} --mode rw `resolvelink $MOUNT_POINT`$PACKAGE_DIR
97 unionctl /. --add `resolvelink $MOUNT_POINT`$PACKAGE_DIR