make getpeername() return the original socket address which before it was intercepted
[hband-tools.git] / user-tools / diu
blobde43c23c77d83fb2a1522c81049ee4fd52fcff3f
1 #!/bin/bash
3 true <<EOF
4 =pod
6 =head1 NAME
8 diu - Display Inode usage, similar to du(1) for space usage
10 =cut
12 EOF
15 shopt -s dotglob
16 shopt -s nullglob
17 CROSSDEV=allow
19 show_num_of_entries()
21 local prefix name entries recursive_num pwd mynum parent_dev dev
22 prefix=${1:+$1/}
23 shift
24 parent_dev=$1
25 shift
26 mynum=0
28 for name in "$@"
30 if [ ! -L "$name" ]
31 then
32 if [ -d "$name" ]
33 then
34 if [ $CROSSDEV = deny ]
35 then
36 dev=`stat -c %D "$name"`
38 if [ $CROSSDEV = allow -o -z "$parent_dev" -o "$dev" = "$parent_dev" ]
39 then
40 pwd=$PWD
41 if cd -- "$name"
42 then
43 entries=(*)
44 show_num_of_entries "$prefix$name" "$dev" "${entries[@]}"
45 recursive_num=$[${#entries[@]} + $NUM]
46 echo "$recursive_num $prefix$name"
47 mynum=$[$mynum + $recursive_num]
48 cd "$pwd"
51 elif [ ! -e "$name" ]
52 then
53 echo "$0: $name: not found" >&2
56 done
57 NUM=$mynum
60 while [ $# -gt 0 ]
62 case "$1" in
63 -h|--help)
64 echo "$0: [options] [<directory> [...]]
65 options:
66 -x, --one-file-system"
67 exit 0
69 -x|--one-file-system)
70 CROSSDEV=deny
72 --)
73 shift
74 break
76 -*)
77 echo "$0: unknown option: $1" >&2
78 exit -1
81 break
83 esac
84 shift
85 done
87 if [ $# = 0 ]
88 then
89 set .
92 show_num_of_entries '' '' "$@"