~ubuntu-branches/ubuntu/vivid/aufs/vivid

« back to all changes in this revision

Viewing changes to util/auplink

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-08-21 14:58:54 UTC
  • mfrom: (1.2.1 upstream) (11 intrepid)
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: james.westby@ubuntu.com-20080821145854-6erljbzg007r476y
01_vserver_apparmor.dpatch: [UPDATE] Disable vserver patches on kernel 
2.6.26, because they are not needed anymore. (Closes: #495921)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh
2
2
 
3
 
# Copyright (C) 2006, 2007 Junjiro Okajima
 
3
# Copyright (C) 2005-2008 Junjiro Okajima
4
4
#
5
5
# This program, aufs is free software; you can redistribute it and/or modify
6
6
# it under the terms of the GNU General Public License as published by
16
16
# along with this program; if not, write to the Free Software
17
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 
19
 
# $Id: auplink,v 1.6 2007/04/16 01:19:49 sfjro Exp $
 
19
# $Id: auplink,v 1.12 2008/07/14 00:18:23 sfjro Exp $
20
20
 
21
 
#set -x
 
21
#set -x; echo $0 $@
22
22
tmp=/tmp/$$
23
23
set -e
24
24
 
35
35
        exit 1
36
36
}
37
37
 
 
38
eecho() { echo "$@" 1>&2; }
 
39
 
 
40
conv() # [escape]
 
41
{
 
42
        sed -r -e '
 
43
        s/\\/\\134/g
 
44
        s/$/\\012/
 
45
        ' |
 
46
        tr -d '\n' |
 
47
        sed -r -e '
 
48
        s/ /\\040/g
 
49
        s/\t/\\011/g
 
50
        s/\r/\\015/g
 
51
        s/\\012$//
 
52
        ' |
 
53
        { test "$1" = "escape" && sed -r -e 's/\\/\\\\/g' || cat; }
 
54
        echo
 
55
}
 
56
 
38
57
Find() # dir [ find_args ]
39
58
{
40
 
        local dir="$1"
 
59
        dir="$1"
41
60
        shift
42
61
        find "$dir" -xdev -noleaf $@
43
62
}
45
64
List()
46
65
{
47
66
        sed -e 's/^\([0-9]*\) .*$/-o -inum \1/' |
48
 
        xargs > $tmp.args
49
 
        Find "$mntpnt" \( `cut -c3- $tmp.args` \) $@
 
67
        cut -c3- |
 
68
        xargs -n 200 |
 
69
        while read args
 
70
        do Find "$mntpnt" \( $args \) $@
 
71
        done
50
72
}
51
73
 
52
74
Cpup()
54
76
        List \( \( -type l -fprint $tmp.slink \) \
55
77
                -o ! -type l -fprint $tmp.other  \)
56
78
 
57
 
        # do nothing but update something. it causes copyup.
 
79
        # do nothing but update something harmless
 
80
        # in order to make it copyup
58
81
        xargs -r touch -ac -r $tmp.other < $tmp.other
59
82
        xargs -r aulchown < $tmp.slink
60
83
}
62
85
test $# -eq 2 || Usage
63
86
cd "$1"
64
87
mntpnt=`readlink -f "$PWD"`
 
88
e_mntpnt=`echo "$mntpnt" | conv escape`
65
89
cd "$OLDPWD"
66
90
 
67
91
do_flush=0
80
104
cpup|flush) test $do_flush -eq 0 && exit 0;;
81
105
esac
82
106
 
83
 
brs=/sys/fs/aufs/brs
84
 
if [ -r $brs ]
 
107
ent=`grep " $e_mntpnt aufs .*,si=" /proc/mounts | tail -n 1`
 
108
test ! "$ent" && exit 0
 
109
eval `echo "$ent" | tr ',' '\n' | grep '^si='`
 
110
test ! "$si" && eecho no such mount-point $e_mntpnt && exit 1
 
111
 
 
112
si_dir=/sys/fs/aufs/si_$si
 
113
if [ -r $si_dir/br0 ]
85
114
then
86
 
        grep " $mntpnt " $brs |
87
 
        tail -n 1 |
88
 
        tr '[, ]' '\n'
 
115
        cd $si_dir
 
116
        ls -1 br* |
 
117
        cut -c3- |
 
118
        sort -n |
 
119
        sed -e 's/^/br/' |
 
120
        xargs -rn 200 cat
 
121
        cd $OLDPWD
89
122
else
90
 
        grep " $mntpnt " /proc/mounts |
91
 
        tail -n 1 |
92
 
        tr ',' '\n'
 
123
        echo "$ent" |
 
124
        tr ',' '\n' |
 
125
        sed -e 's/\\/\\\\/g' |
 
126
        egrep '^(dirs=|br:)' |
 
127
        tr ':' '\n'
93
128
fi |
94
 
sed -e 's/\\/\\\\/g' |
95
 
egrep '^(dirs=|br:)' |
96
 
tr ':' '\n' |
97
129
grep '=rw$' |
98
130
sed -e 's/=rw$//' |
99
131
while read wbr
107
139
        inum=`basename "$pname" | cut -f1 -d.`
108
140
        echo $inum $nlink "$pname"
109
141
done > $tmp
110
 
test -w $brs && >> $brs
111
142
test -s $tmp || { rm -f $tmp $tmp.*; exit 0; }
112
143
 
113
144
# debug