1616ca7a139cc90393bb6c50d72467e359ded17e
[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 local fsck_type=""
32
33 found_device="$(libmount_find_device_by_id "$uuid" "$label" "$device" "$cfgdevice")"
34 if [ -n "$found_device" ]; then
35 if [ -z "$find_rootfs" ] || [ "$find_rootfs" -eq 0 ] || [ "$is_rootfs" -eq 1 ]; then
36 [ "$enabled_fsck" -eq 1 ] && {
37 grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
38 libmount_fsck "$found_device" "$fsck_type" "$enabled_fsck"
39 }
40 }
41
42 [ "$is_rootfs" -eq 1 ] && [ "$find_rootfs" -eq 1 ] && {
43 target=/overlay
44 }
45 config_create_mount_fstab_entry "$found_device" "$target" "$fstype" "$options" "$enabled"
46 grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
47 [ "$enabled" -eq 1 ] && mkdir -p "$target" && mount "$target" 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'
48 }
49
50 fi
51 fi
52 [ "$is_rootfs" -eq 1 ] && [ "$find_rootfs" -eq 1 ] && {
53 rootfs_found=1
54 }
55 return 0
56 }
57 config_get_mount "$cfg"
58 reset_block_cb
59 }
60
61 config_swapon_by_section() {
62 local cfg="$1"
63
64 swap_cb() {
65 local cfg="$1"
66 local device="$2"
67 local cfgdevice="$3"
68 local enabled="$4"
69 local uuid="$5"
70 local label="$6"
71 local uuid
72 local label
73
74 local found_device=""
75 local fsck_type=""
76
77 found_device="$(libmount_find_device_by_id "$uuid" "$label" "$device" "$cfgdevice")"
78
79 if [ -n "$found_device" ]; then
80 config_create_swap_fstab_entry "$found_device" "$enabled"
81 grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
82 [ "$enabled" -eq 1 ] && swapon "$found_device" | tee /proc/self/fd/2 | logger -t 'fstab'
83 }
84 fi
85 return 0
86 }
87 config_get_swap "$cfg"
88 reset_block_cb
89 }
This page took 0.043649 seconds and 3 git commands to generate.