[base system & package/block-extroot] Merged 23110-23112 which allows block-extroot...
[openwrt-10.03/.git] / package / block-mount / files / fsck.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 libmount_fsck() {
8         local device="$1"
9         local fsck_fstype="$2"
10         local fsck_enabled="$3"
11         local known_type
12         local found_fsck=0
13         
14
15         [ -n "$fsck_type" ] && [ "$fsck_type" != "swap" ] && {
16                 grep -q "$device" /proc/swaps || grep -q "$device" /proc/mounts || {
17                         [ -e "$device" ] && [ "$fsck_enabled" -eq 1 ] && {
18                                 for known_type in $libmount_known_fsck; do
19                                         if [ "$known_type" = "$fsck_fstype" ]; then
20                                                 fsck_${known_type} "$device"
21                                                 found_fsck=1
22                                                 break
23                                         fi
24                                 done
25                                 if [ "$found_fsck" -ne 1 ]; then
26                                         logger -t 'fstab' "Unable to check/repair $device; no known fsck for filesystem type $fstype"
27                                 fi
28                         }
29                 }
30         }
31 }
32
33 libmount_known_fsck=""
34
35 pi_include /lib/functions/fsck
36