2010-02-27 00:45:39 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# Copyright 2010 Vertical Communications
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
|
|
|
|
|
|
|
|
2010-09-23 16:58:05 +03:00
|
|
|
pi_include /lib/functions/block.sh
|
|
|
|
pi_include /lib/functions/fsck.sh
|
2010-02-27 00:45:39 +02:00
|
|
|
|
|
|
|
config_mount_by_section() {
|
|
|
|
local cfg="$1"
|
|
|
|
local find_rootfs="$2"
|
|
|
|
|
|
|
|
mount_cb() {
|
|
|
|
local cfg="$1"
|
|
|
|
local device="$2"
|
|
|
|
shift
|
|
|
|
local target="$2"
|
|
|
|
local cfgdevice="$3"
|
|
|
|
local fstype="$4"
|
|
|
|
local options="$5"
|
|
|
|
local enabled="$6"
|
|
|
|
local enabled_fsck="$7"
|
|
|
|
local uuid="$8"
|
|
|
|
local label="$9"
|
|
|
|
shift
|
|
|
|
local is_rootfs="$9"
|
|
|
|
shift
|
|
|
|
local found_device=""
|
|
|
|
|
|
|
|
found_device="$(libmount_find_device_by_id "$uuid" "$label" "$device" "$cfgdevice")"
|
|
|
|
if [ -n "$found_device" ]; then
|
2011-02-28 03:46:46 +02:00
|
|
|
if [ "$find_rootfs" != "1" ] || ( [ "$is_rootfs" -eq 1 ] || [ "$target" = "/" ] || [ "$target" = "/overlay" ] ); then
|
2010-02-27 00:45:39 +02:00
|
|
|
[ "$enabled_fsck" -eq 1 ] && {
|
|
|
|
grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
|
2010-07-01 02:09:13 +03:00
|
|
|
libmount_fsck "$found_device" "$fstype" "$enabled_fsck"
|
2010-02-27 00:45:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-28 03:46:46 +02:00
|
|
|
if [ "$find_rootfs" = "1" ]; then
|
2011-02-28 03:46:24 +02:00
|
|
|
if [ "$is_rootfs" -eq 1 ]; then
|
2010-02-27 00:45:39 +02:00
|
|
|
target=/overlay
|
2011-03-13 11:24:24 +02:00
|
|
|
elif [ "$target" = "/" ]; then
|
|
|
|
target=/rom
|
2011-02-28 03:46:24 +02:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ "$is_rootfs" -eq 1 ] || [ "$target" = "/overlay" ]; then
|
|
|
|
target=/tmp/overlay-disabled
|
2011-03-13 11:24:24 +02:00
|
|
|
elif [ "$target" = "/" ] || [ "$target" = "/rom" ]; then
|
2011-03-27 08:39:47 +03:00
|
|
|
target="/tmp/whole_root-disabled"
|
2011-02-28 03:46:24 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2010-02-27 00:45:39 +02:00
|
|
|
config_create_mount_fstab_entry "$found_device" "$target" "$fstype" "$options" "$enabled"
|
|
|
|
grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
|
|
|
|
[ "$enabled" -eq 1 ] && mkdir -p "$target" && mount "$target" 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'
|
|
|
|
}
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
2011-02-28 03:46:46 +02:00
|
|
|
[ "$find_rootfs" = "1" ] && {
|
2011-02-28 03:46:24 +02:00
|
|
|
[ "$target" = "/overlay" ] && {
|
2010-02-27 00:45:39 +02:00
|
|
|
rootfs_found=1
|
2011-02-28 03:46:24 +02:00
|
|
|
}
|
2011-03-13 11:24:24 +02:00
|
|
|
[ "$target" = "/rom" ] && {
|
|
|
|
rootfs_found=1
|
|
|
|
}
|
2010-02-27 00:45:39 +02:00
|
|
|
}
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
config_get_mount "$cfg"
|
|
|
|
reset_block_cb
|
|
|
|
}
|
|
|
|
|
|
|
|
config_swapon_by_section() {
|
|
|
|
local cfg="$1"
|
|
|
|
|
|
|
|
swap_cb() {
|
|
|
|
local cfg="$1"
|
|
|
|
local device="$2"
|
|
|
|
local cfgdevice="$3"
|
|
|
|
local enabled="$4"
|
|
|
|
local uuid="$5"
|
|
|
|
local label="$6"
|
|
|
|
local uuid
|
|
|
|
local label
|
|
|
|
|
|
|
|
local found_device=""
|
|
|
|
|
|
|
|
found_device="$(libmount_find_device_by_id "$uuid" "$label" "$device" "$cfgdevice")"
|
|
|
|
|
|
|
|
if [ -n "$found_device" ]; then
|
|
|
|
config_create_swap_fstab_entry "$found_device" "$enabled"
|
|
|
|
grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
|
|
|
|
[ "$enabled" -eq 1 ] && swapon "$found_device" | tee /proc/self/fd/2 | logger -t 'fstab'
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
config_get_swap "$cfg"
|
|
|
|
reset_block_cb
|
|
|
|
}
|