overlay: add filesystem check helper
authorzhangyi (F) <yi.zhang@huawei.com>
Thu, 8 Feb 2018 03:19:09 +0000 (11:19 +0800)
committerEryu Guan <eguan@redhat.com>
Thu, 8 Feb 2018 12:07:42 +0000 (20:07 +0800)
Add filesystem check helper for the upcoming fsck.overlay utility.
This helper invoke fsck.overlay to check and optionally repair
underlying directories of overlay filesystem.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
common/config
common/overlay

index 5f40413d9f5b98469677fe689cb80e50ca109090..71115bdbc78abd432fef92004f9bf98d7c085ef7 100644 (file)
@@ -236,6 +236,7 @@ case "$HOSTOS" in
         export MKFS_REISER4_PROG="`set_prog_path mkfs.reiser4`"
        export E2FSCK_PROG="`set_prog_path e2fsck`"
        export TUNE2FS_PROG="`set_prog_path tune2fs`"
+       export FSCK_OVERLAY_PROG="`set_prog_path fsck.overlay`"
         ;;
 esac
 
index ad2f3be8bd34f2921a56abfecc2e7b68513ebf4a..16f13a8fb0cb479cc6b322a25fab53e167c5aef6 100644 (file)
@@ -168,3 +168,17 @@ _require_scratch_overlay_features()
 
        _scratch_unmount
 }
+
+# Helper function to check underlying dirs of overlay filesystem
+_overlay_fsck_dirs()
+{
+       local lowerdir=$1
+       local upperdir=$2
+       local workdir=$3
+       shift 3
+
+       [[ ! -x "$FSCK_OVERLAY_PROG" ]] && return 0
+
+       $FSCK_OVERLAY_PROG -o lowerdir=$lowerdir -o upperdir=$upperdir \
+                          -o workdir=$workdir $*
+}