block-extroot, block-mount: Fixed multiple bugs which prevented e2fsck from being...
[openwrt.git] / package / block-mount / files / mount.sh
1 #!/bin/sh
2 # Copyright 2010 Vertical Communications
3 # This is free software, licensed under the GNU General Public License v2.
4 # See /LICENSE for more information.
5 #
6
7
8 . /lib/functions/block.sh
9 . /lib/functions/fsck.sh
10
11 config_mount_by_section() {
12 local cfg="$1"
13 local find_rootfs="$2"
14
15 mount_cb() {
16 local cfg="$1"
17 local device="$2"
18 shift
19 local target="$2"
20 local cfgdevice="$3"
21 local fstype="$4"
22 local options="$5"
23 local enabled="$6"
24 local enabled_fsck="$7"
25 local uuid="$8"
26 local label="$9"
27 shift
28 local is_rootfs="$9"
29 shift
30 local found_device=""
31
32 found_device="$(libmount_find_device_by_id "$uuid" "$label" "$device" "$cfgdevice")"
33 if [ -n "$found_device" ]; then
34 if [ -z "$find_rootfs" ] || [ "$find_rootfs" -eq 0 ] || [ "$is_rootfs" -eq 1 ]; then
35 [ "$enabled_fsck" -eq 1 ] && {
36 grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
37 libmount_fsck "$found_device" "$fstype" "$enabled_fsck"
38 }
39 }
40
41 [ "$is_rootfs" -eq 1 ] && [ "$find_rootfs" -eq 1 ] && {
42 target=/overlay
43 }
44 config_create_mount_fstab_entry "$found_device" "$target" "$fstype" "$options" "$enabled"
45 grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
46 [ "$enabled" -eq 1 ] && mkdir -p "$target" && mount "$target" 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'
47 }
48
49 fi
50 fi
51 [ "$is_rootfs" -eq 1 ] && [ "$find_rootfs" -eq 1 ] && {
52 rootfs_found=1
53 }
54 return 0
55 }
56 config_get_mount "$cfg"
57 reset_block_cb
58 }
59
60 config_swapon_by_section() {
61 local cfg="$1"
62
63 swap_cb() {
64 local cfg="$1"
65 local device="$2"
66 local cfgdevice="$3"
67 local enabled="$4"
68 local uuid="$5"
69 local label="$6"
70 local uuid
71 local label
72
73 local found_device=""
74
75 found_device="$(libmount_find_device_by_id "$uuid" "$label" "$device" "$cfgdevice")"
76
77 if [ -n "$found_device" ]; then
78 config_create_swap_fstab_entry "$found_device" "$enabled"
79 grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
80 [ "$enabled" -eq 1 ] && swapon "$found_device" | tee /proc/self/fd/2 | logger -t 'fstab'
81 }
82 fi
83 return 0
84 }
85 config_get_swap "$cfg"
86 reset_block_cb
87 }
This page took 0.052763 seconds and 5 git commands to generate.