blob: 71508f6795df635d9f8250bf39f4c5844565131e (
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
67
68
69
70
71
|
#!/bin/sh
usage ()
{
echo "stat -c FMT FILE ..."
exit 1
}
format=""
while getopts "c:h:?" opt ; do
case "$opt" in
c) format="$OPTARG" ;;
\?|h) usage ;;
esac
done
shift $((OPTIND - 1))
fake_device_id ()
{
_path="$1"
_t=$(echo "$FAKE_FILE_ID_MAP" |
awk -v path="${_path}" '$1 == path { print $2 }')
_major_minor="${_t%:*}"
_major="0x${_major_minor%:*}"
_minor="0x${_major_minor#*:}"
_device_id=$((_major * 256 + _minor))
echo "$_device_id"
}
fake_inode ()
{
_path="$1"
_t=$(echo "$FAKE_FILE_ID_MAP" |
awk -v path="${_path}" '$1 == path { print $2 }')
echo "${_t##*:}"
}
if [ -n "$format" ] ; then
for f ; do
if [ ! -e "$f" ] ; then
continue
fi
case "$f" in
/*) path="$f" ;;
*) path="${PWD}/${f}" ;;
esac
case "$format" in
"s#[0-9a-f]*:[0-9a-f]*:%i #%n #")
inode=$(fake_inode "$path")
echo "s#[0-9a-f]*:[0-9a-f]*:${inode} #${f} #"
;;
"%d:%i")
device_id=$(fake_device_id "$path")
inode=$(fake_inode "$path")
echo "${device_id}:${inode}"
;;
*)
echo "Unsupported format \"${format}\""
usage
;;
esac
done
exit
fi
usage
|