This repository has been archived by the owner on Mar 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
auchk
executable file
·130 lines (113 loc) · 2.56 KB
/
auchk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/sh -
# Copyright (C) 2005-2011 Junjiro R. Okajima
#
# This program, aufs is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
set -eu
#set -x
EEcho() # str
{
echo $0: $@ 1>&2
}
f=/etc/default/aufs
. $f
Usage()
{
echo $0 writable_branch '[...]'
}
Pass() # title
{
pass=$(($pass + 1))
EEcho \[Pass $pass\] $@
}
Remove() # file
{
if [ -d "$1" ]
then
rm -ir "$1" || :
else
rm -v "$1" || :
fi
}
for i
do
EEcho Checking "$i" for aufs
cd "$i"
case $(stat -f -c %T .) in
aufs|UNKNOWN*${AUFS_SUPER_MAGIC_HEX}*)
EEcho $i must not be aufs
cd $OLDPWD
continue
;;
esac
########################################
pass=0
Pass Illegal whiteout
find . -name '.wh.*' ! -name '.wh..wh.*' -printf '%h\0%f\0' |
xargs -r0n2 |
while read dir wh
do
#echo \""$dir"\" \""$wh"\"
base=$(echo "$wh" | cut -c5-)
test ! -e "$dir/$base" && continue
ls -ld "$dir/$wh" "$dir/$base"
read -p 'Which to remove [whiteout/real/skip]? ' ans \
< /dev/tty > /dev/tty 2>&1
case "$ans" in
[wW]*) Remove "$dir/$wh" || :;;
[rR]*) Remove "$dir/$base" || :;;
*) echo skipped;;
esac
done
########################################
Pass Remained pseudo-links
did=0
for plink in ${AUFS_WH_PLINKDIR}/*
do
test ! -e "$plink" && break
if [ -d "$plink" ]
then
EEcho illegal "$plink"
continue
fi
did=1
#ls -l "$plink" || :
find . -inum $(basename "$plink" | cut -f2 -d .) -ls || :
done
if [ $did -ne 0 ]
then
cat <<- EOF
They will be maintained at remount or umount time,
if you installed aufs helper scripts (See README
in detail).
If "$i" is not a writeble branch of CURRENTLY mounted
aufs, you need to maintain them by yourself.
EOF
fi
########################################
Pass Remained temp files
for tmp in ${AUFS_WH_TMPDIR}/*
do
test ! -e "$tmp" && break
if [ -d "$tmp" ]
then
EEcho illegal "$tmp"
continue
fi
ls -l "$tmp" || :
rm -i "$tmp" || :
done
# nothing to do for xinodir
cd $OLDPWD
done