block-mount: drop package, ubox now does the job for us

Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 36988
master
John Crispin 11 years ago
parent 08de6fcc12
commit d55316af38
  1. 17
      package/block-mount/Config.in
  2. 70
      package/block-mount/Makefile
  3. 78
      package/block-mount/files/10-swap
  4. 83
      package/block-mount/files/20-fsck
  5. 91
      package/block-mount/files/40-mount
  6. 65
      package/block-mount/files/50_determine_usb_root
  7. 63
      package/block-mount/files/55_determine_extroot_sysupgrade
  8. 27
      package/block-mount/files/60_pivot_usb_root
  9. 264
      package/block-mount/files/block.sh
  10. 37
      package/block-mount/files/extmount.sh
  11. 34
      package/block-mount/files/fsck.sh
  12. 20
      package/block-mount/files/fstab.config
  13. 92
      package/block-mount/files/fstab.init
  14. 103
      package/block-mount/files/mount.sh

@ -1,17 +0,0 @@
#
# Copyright (C) 2010 Vertical Communications
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
config EXTROOT_SETTLETIME
int
prompt "Settle time for root block device (s)" if PACKAGE_block-mount
default 20
help
This is the amount of time, in seconds, to wait for the block device
the root filesystem is on to become available, after the kernel that
modules for the rootfs and device are loaded.

@ -1,70 +0,0 @@
#
# Copyright (C) 2006-2012 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=block-mount
PKG_VERSION:=0.2.0
PKG_RELEASE:=10
include $(INCLUDE_DIR)/package.mk
define Package/block-mount/Default
SECTION:=base
CATEGORY:=Base system
endef
define Package/block-mount
$(call Package/block-mount/Default)
TITLE:=Block device mounting and checking
DEPENDS:= +blkid +swap-utils
MENU:=1
endef
define Package/block-mount/description
Scripts used to mount and check block devices (filesystems and swap), as well
as hotplug scripts to automount and check block devices when hotplug event (e.g.
from plugging in a device) occurs.
Also includes preinit scripts for mounting a block device as the root filesystem.
This allows one to have the root filesystem on devices other than the built in flash
device.
endef
define Package/block-mount/config
source "$(SOURCE)/Config.in"
endef
define Build/Compile
endef
define Package/block-mount/conffiles
/etc/config/fstab
endef
define Package/block-mount/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/fstab.init $(1)/etc/init.d/fstab
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/fstab.config $(1)/etc/config/fstab
$(INSTALL_DIR) $(1)/lib/functions/fsck
$(INSTALL_DATA) ./files/mount.sh $(1)/lib/functions/
$(INSTALL_DATA) ./files/fsck.sh $(1)/lib/functions/
$(INSTALL_DATA) ./files/block.sh $(1)/lib/functions/
$(INSTALL_DIR) $(1)/etc/hotplug.d/block
$(INSTALL_DATA) ./files/10-swap $(1)/etc/hotplug.d/block/
$(INSTALL_DATA) ./files/20-fsck $(1)/etc/hotplug.d/block/
$(INSTALL_DATA) ./files/40-mount $(1)/etc/hotplug.d/block/
$(INSTALL_DATA) ./files/extmount.sh $(1)/lib/functions/
$(INSTALL_DIR) $(1)/lib/preinit
$(INSTALL_DATA) ./files/50_determine_usb_root $(1)/lib/preinit/
$(INSTALL_DATA) ./files/55_determine_extroot_sysupgrade $(1)/lib/preinit/
$(INSTALL_DATA) ./files/60_pivot_usb_root $(1)/lib/preinit/
echo "extroot_settle_time=\"$(CONFIG_EXTROOT_SETTLETIME)\"" >$(1)/lib/preinit/00_extroot.conf
$(INSTALL_DIR) $(1)/overlay
endef
$(eval $(call BuildPackage,block-mount))

@ -1,78 +0,0 @@
#!/bin/sh
# Copyright (C) 2009-2010 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
. /lib/functions/block.sh
blkdev=`dirname $DEVPATH`
if [ `basename $blkdev` != "block" ]; then
device=`basename $DEVPATH`
case "$ACTION" in
add)
local autoswap_from_fstab
local automount_from_fstab
local from_fstab
local anon_mount
local anon_swap
local anon_fsck
local mds_mount_device
local sds_swap_device
local sds_swap_enabled
local use_device
local do_swap=0
mount_dev_section_cb() {
mds_mount_device="$3"
}
swap_dev_section_cb() {
sds_swap_device="$2"
sds_swap_enabled="$3"
return 0
}
config_get_automount
automount_from_fstab="$from_fstab"
[ "$automount_from_fstab" -eq 1 ] && {
config_get_mount_section_by_device "/dev/$device"
}
# skip trying swap if this device is defined as a mount point
[ -z "$mds_mount_device" ] && {
config_get_autoswap
autoswap_from_fstab="$from_fstab"
[ "$autoswap_from_fstab" -eq 1 ] && {
config_get_swap_section_by_device "/dev/$device"
use_device="$sds_swap_device"
do_swap="$sds_swap_enabled"
}
[ -z "$use_device" ] && [ "$anon_swap" -eq 1 ] && {
use_device="/dev/$device" && do_swap=1
}
}
[ -n "$use_device" ] && [ "$do_swap" -eq 1 ] && {
grep -q "$use_device" /proc/swaps || grep -q "$use_device" /proc/mounts || {
swapon "$use_device"
}
}
reset_dev_section_cb
;;
remove)
grep -q "/dev/$device" /proc/swaps && {
swapoff "/dev/$device"
}
;;
esac
fi

@ -1,83 +0,0 @@
#!/bin/sh
# Copyright (C) 2009-2010 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
. /lib/functions/block.sh
. /lib/functions/fsck.sh
blkdev=`dirname $DEVPATH`
if [ `basename $blkdev` != "block" ]; then
device=`basename $DEVPATH`
case "$ACTION" in
add)
local from_fstab
local anon_mount
local anon_swap
local anon_fsck
local mds_mount_target
local mds_mount_device
local mds_mount_fstype
local mds_mount_enabled_fsck
local sds_swap_device
local use_device
local do_fsck=0
local fsck_type
local autoswap_from_fstab
local automount_from_fstab
local hotplug_blkid_fstype_match
mount_dev_section_cb() {
mds_mount_device="$3"
mds_mount_fstype="$4"
mds_mount_enabled_fsck="$7"
}
swap_dev_section_cb() {
sds_swap_device="$2"
return 0
}
config_get_automount
automount_from_fstab="$from_fstab"
[ "$automount_from_fstab" -eq 1 ] && {
config_get_mount_section_by_device "/dev/$device"
use_device="$mds_mount_device"
[ "$mds_mount_enabled_fsck" -eq 1 ] && {
do_fsck=1
fsck_type="$mds_mount_fstype"
}
}
[ -z "$use_device" ] && {
config_get_autoswap
autoswap_from_fstab="$from_fstab"
[ "$autoswap_from_fstab" -eq 1 ] && {
config_get_swap_section_by_device "/dev/$device"
use_device="$sds_swap_device" && do_fsck=0
}
}
grep -q "/dev/$device" /proc/swaps || grep -q "/dev/$device" /proc/mounts || {
[ "$anon_fsck" -eq 1 ] && [ -z "$use_device" ] && {
use_device="/dev/$device" && do_fsck=1 && mds_mount_fstype="" && hotplug_blkid_fstype_match=0
}
}
[ "$do_fsck" -eq 1 ] && {
libmount_fsck "$use_device" "$fsck_type" "$do_fsck"
}
reset_dev_section_cb
;;
esac
fi

@ -1,91 +0,0 @@
#!/bin/sh
# Copyright (C) 2009-2012 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
. /lib/functions/block.sh
blkdev=`dirname $DEVPATH`
if [ `basename $blkdev` != "block" ]; then
device=`basename $DEVPATH`
mountpoint=`sed -ne "s|^[^ ]*/$device ||; T; s/ .*//p" /proc/self/mounts`
case "$ACTION" in
add)
local from_fstab
local anon_mount
local anon_swap
local anon_fsck
local mds_mount_target
local mds_mount_device
local mds_mount_fstype
local sds_swap_device
local use_device
local do_fsck=0
local fsck_type
local autoswap_from_fstab
local automount_from_fstab
mount_dev_section_cb() {
mds_mount_target="$2"
mds_mount_device="$3"
mds_mount_fstype="$4"
mds_mount_enabled="$6"
}
swap_dev_section_cb() {
sds_swap_device="$2"
return 0
}
config_get_automount
automount_from_fstab="$from_fstab"
[ "$automount_from_fstab" -eq 1 ] && {
config_get_mount_section_by_device "/dev/$device"
use_device="$mds_mount_device"
[ "$mds_mount_enabled" -eq 1 ] && {
if [ -n "$mds_mount_target" ]; then
grep -q "/dev/$device" /proc/swaps || grep -q "/dev/$device" /proc/mounts || {
( mkdir -p "$mds_mount_target" && mount "$mds_mount_target" ) 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'
}
else
logger -t 'fstab' "Mount enabled for $mds_mount_device but it doesn't have a defined mountpoint (target)"
fi
}
}
[ -z "$use_device" ] && {
config_get_autoswap
autoswap_from_fstab="$from_fstab"
[ "$autoswap_from_fstab" -eq 1 ] && {
config_get_swap_section_by_device "/dev/$device"
use_device="$sds_swap_device"
}
}
grep -q "/dev/$device" /proc/swaps || grep -q "/dev/$device" /proc/mounts || {
[ "$anon_mount" -eq 1 -a -z "$use_device" ] && {
case "$device" in
mtdblock*) ;;
*)
( mkdir -p /mnt/$device && mount /dev/$device /mnt/$device ) 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'
;;
esac
}
}
reset_dev_section_cb
;;
remove)
umount /dev/$device
umount $mountpoint
;;
esac
fi

@ -1,65 +0,0 @@
#!/bin/sh
# Copyright (C) 2010 Vertical Communications
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
determine_external_root() {
pi_include /lib/functions/extmount.sh
pi_include /lib/functions/mount.sh
local OLD_UCI_CONFIG_DIR="$UCI_CONFIG_DIR"
local OLD_PATH="$PATH"
local OLD_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
set_jffs_mp
determine_root_device
# extroot requires extroot and fstab config files, therefore
# we assume configuration is incomplete and not to be used if either of them
# is missing (for jffs versions of these files on squashfs image)
if [ "$jffs" = "/tmp/overlay" ] && [ -r "/tmp/overlay/etc/config/fstab" ]; then
UCI_CONFIG_DIR="/tmp/overlay/etc/config"
ER_IS_SQUASHFS=true
ER_OVERLAY_PREFIX="/tmp/overlay"
PATH=$ER_OVERLAY_PREFIX/sbin:$PATH
LD_LIBRARY_PATH=$ER_OVERLAY_PREFIX/usr/lib:$LD_LIBRARY_PATH
export PATH LD_LIBRARY_PATH
fi
# For squashfs on firstboot root_device will be tmpfs for the ramoverlay,
# unless there is a saved config, in which case it will be /dev/root,
# however in the case of a saved config, it won't be restored until after
# this script, so there won't be a config on the first boot after
# flashing a squashfs-based filesystem
# For ext2, ramdisk, or jffs2 root filesystems root_device is /dev/root
# For squashfs after firstboot, root filesystem is /dev/root
# We only use the config from the root or jffs if the root_device is
# /dev/root
[ "$root_device" = "/dev/root" ] && {
er_load_modules
[ -n "$extroot_settle_time" ] && [ "$extroot_settle_time" -gt 0 ] && {
sleep $extroot_settle_time
}
config_load fstab
config_foreach config_mount_by_section mount 1
ER_OVERLAY_ROM="/no-extroot"
[ "$rootfs_found" = "1" ] && grep -q ' /overlay ' /proc/mounts && {
pi_extroot_mount_success=true
pi_mount_skip_next=false
ER_OVERLAY_ROM="/overlay"
}
[ "$rootfs_found" = "1" ] && grep -q ' /rom ' /proc/mounts && {
pi_extroot_mount_success=true
pi_mount_skip_next=false
ER_OVERLAY_ROM="/rom"
}
}
UCI_CONFIG_DIR="$OLD_UCI_CONFIG_DIR"
PATH="$OLD_PATH"
LD_LIBRARY_PATH="$OLD_LD_LIBRARY_PATH"
export PATH LD_LIBRARY_PATH
}
boot_hook_add preinit_mount_root determine_external_root

@ -1,63 +0,0 @@
#!/bin/sh
# Copyright (C) 2010 Daniel Dickinson
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
check_set_md5sum() {
local er_md5sum_file
er_md5sum_file="${ER_OVERLAY_PREFIX}/.extroot.md5sum"
local er_disabled
if [ "${ER_OVERLAY_ROM}" = "/rom" ]; then
er_disabled=/tmp/whole_root-disabled
else
er_disabled=/tmp${ER_OVERLAY_ROM}-disabled
fi
local er_extroot_md5sum
if [ -f $md5sum_file ]; then
er_extroot_md5sum="$(cat $er_md5sum_file)"
fi
local er_overlay_file="${ER_OVERLAY_ROM}/etc/extroot.md5sum"
local er_extroot_overlay_md5sum
if [ -f "$er_overlay_file" ]; then
er_extroot_overlay_md5sum="$(cat $er_overlay_file)"
fi
if [ -z "$er_extroot_overlay_md5sum" ]; then
cat $er_md5sum_file >$er_overlay_file
elif [ "$er_extroot_overlay_md5sum" != "$er_extroot_md5sum" ]; then
pi_extroot_mount_success="false"
mkdir -p $er_disabled
mount --move ${ER_OVERLAY_ROM} $er_disabled
fi
}
set_jffs_md5sum() {
# We do this anytime block-extroot exists, even on the first boot with
# no extroot defined.
local er_md5sum_file
er_md5sum_file="${ER_OVERLAY_PREFIX}/.extroot.md5sum"
local er_extroot_md5sum
if [ -f $er_md5sum_file ]; then
er_extroot_md5sum="$(cat $er_md5sum_file)"
fi
if [ -z "$er_extroot_md5sum" ]; then
dd if=/dev/urandom count=32 bs=1k 2>/dev/null | md5sum | cut -f1 -d\ >$er_md5sum_file
fi
}
determine_extroot_sysupgrade() {
check_skip || set_jffs_md5sum
check_skip || [ "$pi_extroot_mount_success" != "true" ] || {
check_set_md5sum
}
}
boot_hook_add preinit_mount_root determine_extroot_sysupgrade

@ -1,27 +0,0 @@
#!/bin/sh
# Copyright (C) 2010 Vertical Communications
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
# Determine if we are requested to mount external root
external_root_pivot() {
check_skip || [ "$pi_extroot_mount_success" != "true" ] || {
echo "switching to external rootfs"
if [ "$ER_OVERLAY_ROM" = "/overlay" ]; then
if [ "$ER_IS_SQUASHFS" = "true" ]; then
umount /tmp/overlay
fi
mount -o remount,ro / && fopivot /overlay /rom && pi_mount_skip_next=true
elif [ "$ER_OVERLAY_ROM" = "/rom" ]; then
if [ "$ER_IS_SQUASHFS" = "true" ]; then
umount /tmp/overlay
fi
mount -o remount,ro / && pivot_rom /rom /rom && pi_mount_skip_next=true
fi
}
}
boot_hook_add preinit_mount_root external_root_pivot

@ -1,264 +0,0 @@
#!/bin/sh
# Copyright 2010 Vertical Communications
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
. /lib/functions.sh
reset_block_cb() {
mount_cb() {
dmc_mount_cfg="$1"
shift # skip optional param
dmc_target="$2"
dmc_mount_device="$3"
dmc_fstype="$4"
dmc_options="$5"
dmc_enabled="$6"
dmc_enabled_fsck="$7"
dmc_uuid="$8"
dmc_label="$9"
shift
dmc_is_rootfs="$9"
return 0
}
swap_cb() {
dsc_swap_cfg="$1"
shift # skip optional param
dsc_swap_device="$2"
dsc_enabled="$3"
dsc_uuid="$4"
dsc_label="$5"
return 0
}
}
reset_block_cb
reset_dev_section_cb() {
mount_dev_section_cb() {
dmds_mount_cfg="$1"
dmds_mount_target="$2"
dmds_mount_device="$3"
dmds_mount_fstype="$4"
dmds_mount_options="$5"
dmds_mount_enabled="$6"
dmds_mount_enabled_fsck="$7"
dmds_mount_uuid="$8"
dmds_mount_label="$9"
shift
dmds_is_rootfs="$9"
return 0
}
swap_dev_section_cb() {
dsds_swap_cfg="$1"
dsds_swap_device="$2"
dsds_swap_enabled="$3"
dsds_swap_uuid="$4"
dsds_swap_label="$5"
return 0
}
}
reset_dev_section_cb
config_get_mount() {
local gm_cfg="$1"
local gm_param="$2"
local gm_target
local gm_device
local gm_fstype
local gm_options
local gm_enabled
local gm_enabled_fsck
local gm_uuid
local gm_label
local gm_is_rootfs
config_get gm_target "$1" target
config_get gm_device "$1" device
config_get gm_fstype "$1" fstype 'auto'
config_get gm_options "$1" options 'rw'
config_get_bool gm_enabled "$1" enabled 1
config_get_bool gm_enabled_fsck "$1" enabled_fsck 0
config_get gm_uuid "$1" uuid
config_get gm_label "$1" label
config_get_bool gm_is_rootfs "$1" is_rootfs 0
mount_cb "$gm_cfg" "$gm_param" "$gm_target" "$gm_device" "$gm_fstype" "$gm_options" "$gm_enabled" "$gm_enabled_fsck" "$gm_uuid" "$gm_label" "$gm_is_rootfs"
}
config_get_swap() {
local gs_cfg="$1"
local gs_param="$2"
local gs_device
local gs_enabled
local gs_uuid
local gs_label
config_get gs_device "$1" device
config_get_bool gs_enabled "$1" enabled 1
config_get gs_uuid "$1" uuid
config_get gs_label "$1" label
swap_cb "$gs_cfg" "$gs_param" "$gs_device" "$gs_enabled" "$gs_uuid" "$gs_label"
}
config_get_automount() {
config_load fstab
config_get_bool from_fstab "automount" from_fstab 1
config_get_bool anon_mount "automount" anon_mount 1
config_get_bool anon_fsck "automount" anon_fsck 0
}
config_get_autoswap() {
config_load fstab
config_get_bool from_fstab "autoswap" from_fstab 1
config_get_bool anon_swap "autoswap" anon_swap 0
}
config_create_swap_fstab_entry() {
local device="$1"
local enabled="$2"
[ -n "$device" ] || return 0
local fstabnew
mkdir -p /var/lock
lock /var/lock/fstab.lck
fstabnew="$(mktemp -t '.fstab.XXXXXXXX')"
cat /tmp/fstab | grep -E -v "^$device[[:blank:]]" >>"$fstabnew"
[ "$enabled" -eq 1 ] && echo "$device none swap sw 0 0" >> "$fstabnew"
cat "$fstabnew" >/tmp/fstab
rm -f $fstabnew
lock -u /var/lock/fstab.lck
}
config_create_mount_fstab_entry() {
local device="$1"
local target="$2"
local fstype="$3"
local options="$4"
local enabled="$5"
options="${options:-rw}"
[ "$enabled" -eq 0 ] && options="noauto,$options"
[ -n "$target" ] || return 0
[ -n "$device" ] || return 0
local fstabnew
mkdir -p /var/lock
lock /var/lock/fstab.lck
fstabnew="$(mktemp -t '.fstab.XXXXXXXX')"
cat /tmp/fstab | grep -E -v "^$device[[:blank:]]" | grep -v "$target" >>"$fstabnew"
echo "$device $target $fstype $options 0 0" >>"$fstabnew"
cat "$fstabnew" >/tmp/fstab
rm -f $fstabnew
lock -u /var/lock/fstab.lck
}
libmount_find_token() {
local token="$1"
local value="$2"
local device
device="$(blkid -w /dev/null -c /dev/null | grep "$token=\"$value\"" | cut -f1 -d:)"
echo "$device"
}
libmount_find_device_by_id() {
local uuid="$1"
local label="$2"
local device="$3"
local cfg_device="$4"
local found_device
if [ -n "$uuid" ]; then
found_device="$(libmount_find_token "UUID" "$uuid")"
elif [ -n "$label" ]; then
found_device="$(libmount_find_token "LABEL" "$label")"
elif [ "$device" = "$cfg_device" ]; then
found_device="$device"
elif [ -z "$device" ] && [ -e "$cfg_device" ]; then
found_device="$cfg_device"
fi
[ -n "$device" ] && [ "$device" != "$found_device" ] && {
found_device=""
}
echo "$found_device"
}
config_get_mount_section_by_device() {
local msbd_device="$1"
local msbd_mount_cfg=
local msbd_target=
local msbd_mount_device=
local msbd_fstype=
local msbd_options=
local msbd_enabled=
local msbd_enabled_fsck=
local msbd_uuid=
local msbd_label=
local msbd_is_rootfs
local msbd_blkid_fstype_match=
mount_cb() {
local mc_cfg="$1"
local mc_device="$2"
shift
local mc_target="$2"
local mc_cfgdevice="$3"
local mc_fstype="$4"
local mc_uuid="$8"
local mc_label="$9"
shift
local mc_is_rootfs="$9"
local mc_found_device=""
mc_found_device="$(libmount_find_device_by_id "$mc_uuid" "$mc_label" "$mc_device" "$mc_cfgdevice")"
if [ -n "$mc_found_device" ]; then
msbd_mount_cfg="$mc_cfg"
msbd_target="$mc_target"
msbd_mount_device="$mc_found_device"
msbd_fstype="$mc_fstype"
msbd_options="$4"
msbd_enabled="$5"
msbd_enabled_fsck="$6"
msbd_uuid="$7"
msbd_label="$8"
msbd_is_rootfs="$9"
fi
return 0
}
config_foreach config_get_mount mount "$msbd_device"
[ -n "$msbd_mount_device" ] && config_create_mount_fstab_entry "$msbd_mount_device" "$msbd_target" "$msbd_fstype" "$msbd_options" "$msbd_enabled"
mount_dev_section_cb "$msbd_mount_cfg" "$msbd_target" "$msbd_mount_device" "$msbd_fstype" "$msbd_options" "$msbd_enabled" "$msbd_enabled_fsck" "$msbd_uuid" "$msbd_label" "$msbd_is_rootfs"
reset_block_cb
}
config_get_swap_section_by_device() {
local ssbd_device="$1"
local ssbd_swap_cfg=
local ssbd_swap_device=
local ssbd_enabled=
local ssbd_uuid=
local ssbd_label=
swap_cb() {
local sc_cfg="$1"
local sc_device="$2"
local sc_uuid="$5"
local sc_label="$6"
local sc_cfgdevice="$3"
local sc_found_device
sc_found_device="$(libmount_find_device_by_id "$sc_uuid" "$sc_label" "$sc_device" "$sc_cfgdevice")"
if [ -n "$sc_found_device" ]; then
ssbd_swap_cfg="$sc_cfg"
ssbd_swap_device="$sc_found_device"
ssbd_enabled="$4"
ssbd_uuid="$5"
ssbd_label="$6"
fi
return 0
}
config_foreach config_get_swap swap "$ssbd_device"
[ -n "$ssbd_swap_device" ] && config_create_swap_fstab_entry "$ssbd_swap_device" "$ssbd_enabled"
swap_dev_section_cb "$ssbd_swap_cfg" "$ssbd_swap_device" "$ssbd_enabled" "$ssbd_uuid" "$ssbd_label"
reset_block_cb
}

@ -1,37 +0,0 @@
#!/bin/sh
# Copyright (C) 2006-2011 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
determine_root_device() {
root_device="$(mount | grep ' / ' | cut -f1 -d\ | grep -v rootfs )"
}
set_jffs_mp() {
jffs="$(awk '/jffs2/ {print $2}' /proc/mounts)"
}
er_load_modules() {
mkdir -p /tmp/extroot_modules/modules.d
mkdir -p /tmp/extroot_modules/modules
cp -L /etc/modules-boot.d/* /tmp/overlay/etc/modules-boot.d/* /tmp/extroot_modules/modules.d
ln -sf /lib/modules/*/* /tmp/overlay/lib/modules/*/* /tmp/extroot_modules/modules
local modules="$(cat /tmp/extroot_modules/modules.d/* 2>/dev/null)"
cd /tmp/extroot_modules/modules && [ -n "$modules" ] && {
echo "$modules" | sed -e 's/^\([^#].*\)/insmod \.\/\1.ko/'| sh 2>&- || :
}
rm -rf /tmp/extroot_modules
}
pivot_rom() { # <new_root> <old_root>
mount -o move /proc $1/proc && \
pivot_root $1 $1$2 && {
mount -o move $2/dev /dev
mount -o move $2/tmp /tmp
mount -o move $2/sys /sys 2>&-
return 0
}
}

@ -1,34 +0,0 @@
#!/bin/sh
# Copyright 2010 Vertical Communications
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
libmount_fsck() {
local device="$1"
local fsck_fstype="$2"
local fsck_enabled="$3"
local known_type
local found_fsck=0
grep -q "$device" /proc/swaps || grep -q "$device" /proc/mounts || {
[ -e "$device" ] && [ "$fsck_enabled" -eq 1 ] && {
for known_type in $libmount_known_fsck; do
if [ "$known_type" = "$fsck_fstype" ]; then
fsck_${known_type} "$device"
found_fsck=1
break
fi
done
if [ "$found_fsck" -ne 1 ]; then
logger -t 'fstab' "Unable to check/repair $device; no known fsck for filesystem type $fstype"
fi
}
}
}
libmount_known_fsck=""
pi_include /lib/functions/fsck

@ -1,20 +0,0 @@
config global automount
option from_fstab 1
option anon_mount 1
config global autoswap
option from_fstab 1
option anon_swap 0
config mount
option target /home
option device /dev/sda1
option fstype ext4
option options rw,sync
option enabled 0
option enabled_fsck 0
config swap
option device /dev/sda2
option enabled 0

@ -1,92 +0,0 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2007 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
START=20
EXTRA_COMMANDS="overlay_enable whole_root_enable"
EXTRA_HELP=" overlay_enable Reenable overlay rootfs. (After you fix it).
whole_root_enable Reenable whole-disk rootfs. (After you fix it)."
rootfs_enable() {
local extroot_type="$1"
if [ ! -d /tmp/${extroot_type}-disabled ]; then
echo "No disabled ${extroot_type} present (/tmp/${extroot_type}-disabled). Can't renable."
exit 1
fi
rm -f /tmp/${extroot_type}-disabled/.extroot.md5sum
rm -f /tmp/${extroot_type}-disabled/etc/extroot.md5sum
echo "Please reboot router to complete re-enabling external rootfs."
}
overlay_enable() {
rootfs_enable overlay
}
whole_root_enable() {
rootfs_enable whole_root
}
do_mount() {
local cfg="$1"
config_mount_by_section "$cfg"
}
do_swapon() {
local cfg="$1"
config_swapon_by_section "$cfg"
}
do_unmount() {
local cfg="$1"
config_get target "$cfg" target
config_get_bool enabled "$cfg" "enabled" '1'
[ -n "$target" -a "$enabled" -gt 0 ] || return 0
umount $target
}
do_swapoff() {
local cfg="$1"
config_get device "$cfg" device
config_get_bool enabled "$cfg" "enabled" '1'
[ -n "$device" -a "$enabled" -gt 0 ] && type swapoff >/dev/null || return 0
swapoff $device
}
start() {
. /lib/functions/mount.sh
config_load fstab
mkdir -p /var/lock
lock /var/lock/fstab.lck
[ -e /tmp/fstab ] || {
echo '# WARNING: this is an auto generated file, please use uci to set defined filesystems' > /tmp/fstab
}
lock -u /var/lock/fstab.lck
config_foreach do_swapon swap
config_foreach do_mount mount
config_foreach do_swapon swap # do swap a second time so that swap on filesystems is enabled
}
stop() {
. /lib/functions/mount.sh
config_load fstab
config_foreach do_unmount mount
config_foreach do_swapoff swap
swapoff -a
}
restart() {
stop
sleep 1
start
}

@ -1,103 +0,0 @@
#!/bin/sh
# Copyright 2010 Vertical Communications
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
pi_include /lib/functions/block.sh
pi_include /lib/functions/fsck.sh
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
if [ "$find_rootfs" != "1" ] || ( [ "$is_rootfs" -eq 1 ] || [ "$target" = "/" ] || [ "$target" = "/overlay" ] ); then
[ "$enabled_fsck" -eq 1 ] && {
grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
libmount_fsck "$found_device" "$fstype" "$enabled_fsck"
}
}
if [ "$find_rootfs" = "1" ]; then
if [ "$is_rootfs" -eq 1 ]; then
target=/overlay
elif [ "$target" = "/" ]; then
target=/rom
fi
else
if [ "$is_rootfs" -eq 1 ] || [ "$target" = "/overlay" ]; then
target=/tmp/overlay-disabled
elif [ "$target" = "/" ] || [ "$target" = "/rom" ]; then
target="/tmp/whole_root-disabled"
fi
fi
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
[ "$find_rootfs" = "1" ] && {
[ "$target" = "/overlay" ] && {
rootfs_found=1
}
[ "$target" = "/rom" ] && {
rootfs_found=1
}
}
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
}
Loading…
Cancel
Save