blob: 3967654cf47c3e16633f1af0d2d25d40578822eb (
plain)
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
|
#!/bin/sh
# Each entry in the array below is a regular expression to match stale keys
xs=("trusted.glusterfs.createtime"
"trusted.glusterfs.version"
"trusted.glusterfs.afr.data-pending"
"trusted.glusterfs.afr.metadata-pending"
"trusted.glusterfs.afr.entry-pending")
absolute_path()
{
local dir=$(dirname "$1");
local base=$(basename "$1");
cd "$dir";
echo $(pwd)/"$base";
cd - >/dev/null;
}
cleanup()
{
sanitizee=$(absolute_path "$1");
stale_keys=$(
for pattern in ${xs[@]}; do
getfattr -d -m "$pattern" "$sanitizee" 2>/dev/null |
grep = | cut -f1 -d=;
done
)
if [ -z "$stale_keys" ]; then
return;
fi
for key in $stale_keys; do
echo "REMOVEXATTR ($key) $sanitizee";
setfattr -x "$key" "$sanitizee";
done
}
crawl()
{
this_script=$(absolute_path "$0");
export sanitize=yes;
find "$1" -exec "$this_script" {} \;
}
main()
{
if [ -z "$1" ]; then
echo "Usage: $0 <export-dir>"
return 1
fi
if [ "$sanitize" = "yes" ]; then
cleanup "$@";
else
crawl "$@";
fi
}
main "$@"
|