~ecryptfs/ecryptfs/trunk

« back to all changes in this revision

Viewing changes to src/utils/ecryptfs-find

  • Committer: Dustin Kirkland
  • Date: 2009-02-13 15:57:24 UTC
  • Revision ID: kirkland@canonical.com-20090213155724-1q3qz2o0cbyimu9x
debian/ubuntu packaging

Initial checkin of the Debian/Ubuntu packaging

Signed-off-by: Dustin Kirkland <kirkland@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh -e
2
 
#
3
 
#    ecryptfs-find - use inode numbers to match encrypted/decrypted filenames
4
 
#    Copyright (C) 2011 Dustin Kirkland
5
 
#    Copyright (C) 2011 Sergio Mena de la Cruz
6
 
#
7
 
#    Authors: Dustin Kirkland <kirkland@ubuntu.com>
8
 
#             Sergio Mena de la Cruz
9
 
#
10
 
#    This program is free software: you can redistribute it and/or modify
11
 
#    it under the terms of the GNU General Public License as published by
12
 
#    the Free Software Foundation, version 2 of the License.
13
 
#
14
 
#    This program is distributed in the hope that it will be useful,
15
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
#    GNU General Public License for more details.
18
 
#
19
 
#    You should have received a copy of the GNU General Public License
20
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 
 
22
 
if [ ! -e "$1" ]; then
23
 
        echo "ERROR: [$1] not found" 1>&2
24
 
        exit 1
25
 
fi
26
 
 
27
 
# Use one utility for both directions; same method is used
28
 
case "$1" in
29
 
        *ECRYPTFS_FNEK_ENCRYPTED.*)
30
 
                direction="decrypt"
31
 
        ;;
32
 
        *)
33
 
                direction="encrypt"
34
 
        ;;
35
 
esac
36
 
 
37
 
# Grab the target inode number
38
 
inum=$(ls -aid "$1" | awk '{print $1}')
39
 
mounts=
40
 
 
41
 
# Process /proc/mounts
42
 
while read lower upper fstype opts dump pass; do
43
 
        [ "$fstype" = "ecryptfs" ] || continue
44
 
        if [ "$direction" = "encrypt" ]; then
45
 
                find="$lower"
46
 
        else
47
 
                find="$upper"
48
 
        fi
49
 
        # Match against filesystem or mountpoint, build list of
50
 
        # mounts to search
51
 
        if [ -r "$find" ] && [ -x "$find" ]; then
52
 
                mounts="$mounts $find"
53
 
        fi
54
 
done < /proc/mounts
55
 
 
56
 
# Do the search
57
 
for m in $mounts; do
58
 
        find "$m/" -inum "$inum"
59
 
done