diff options
author | Michael Halcrow <mhalcrow@us.ibm.com> | 2009-01-06 17:42:00 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-06 18:59:22 -0500 |
commit | addd65ad8d19a7d7982130b16f957d5d01d3f8df (patch) | |
tree | 2263b4a4b7a6269410bd161a3995d2b4af3f7bcf /fs/ecryptfs/file.c | |
parent | 51ca58dcc9f0d6b1e78954d08bd4954fb6a1421c (diff) |
eCryptfs: Filename Encryption: filldir, lookup, and readlink
Make the requisite modifications to ecryptfs_filldir(), ecryptfs_lookup(),
and ecryptfs_readlink() to call out to filename encryption functions.
Propagate filename encryption policy flags from mount-wide crypt_stat to
inode crypt_stat.
Signed-off-by: Michael Halcrow <mhalcrow@us.ibm.com>
Cc: Dustin Kirkland <dustin.kirkland@gmail.com>
Cc: Eric Sandeen <sandeen@redhat.com>
Cc: Tyler Hicks <tchicks@us.ibm.com>
Cc: David Kleikamp <shaggy@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ecryptfs/file.c')
-rw-r--r-- | fs/ecryptfs/file.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index 713834371229..567eb4bee1b6 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c | |||
@@ -77,27 +77,27 @@ struct ecryptfs_getdents_callback { | |||
77 | 77 | ||
78 | /* Inspired by generic filldir in fs/readdir.c */ | 78 | /* Inspired by generic filldir in fs/readdir.c */ |
79 | static int | 79 | static int |
80 | ecryptfs_filldir(void *dirent, const char *name, int namelen, loff_t offset, | 80 | ecryptfs_filldir(void *dirent, const char *lower_name, int lower_namelen, |
81 | u64 ino, unsigned int d_type) | 81 | loff_t offset, u64 ino, unsigned int d_type) |
82 | { | 82 | { |
83 | struct ecryptfs_crypt_stat *crypt_stat; | ||
84 | struct ecryptfs_getdents_callback *buf = | 83 | struct ecryptfs_getdents_callback *buf = |
85 | (struct ecryptfs_getdents_callback *)dirent; | 84 | (struct ecryptfs_getdents_callback *)dirent; |
85 | int name_size; | ||
86 | char *name; | ||
86 | int rc; | 87 | int rc; |
87 | int decoded_length; | ||
88 | char *decoded_name; | ||
89 | 88 | ||
90 | crypt_stat = ecryptfs_dentry_to_private(buf->dentry)->crypt_stat; | ||
91 | buf->filldir_called++; | 89 | buf->filldir_called++; |
92 | decoded_length = ecryptfs_decode_filename(crypt_stat, name, namelen, | 90 | rc = ecryptfs_decode_and_decrypt_filename(&name, &name_size, |
93 | &decoded_name); | 91 | buf->dentry, lower_name, |
94 | if (decoded_length < 0) { | 92 | lower_namelen); |
95 | rc = decoded_length; | 93 | if (rc) { |
94 | printk(KERN_ERR "%s: Error attempting to decode and decrypt " | ||
95 | "filename [%s]; rc = [%d]\n", __func__, lower_name, | ||
96 | rc); | ||
96 | goto out; | 97 | goto out; |
97 | } | 98 | } |
98 | rc = buf->filldir(buf->dirent, decoded_name, decoded_length, offset, | 99 | rc = buf->filldir(buf->dirent, name, name_size, offset, ino, d_type); |
99 | ino, d_type); | 100 | kfree(name); |
100 | kfree(decoded_name); | ||
101 | if (rc >= 0) | 101 | if (rc >= 0) |
102 | buf->entries_written++; | 102 | buf->entries_written++; |
103 | out: | 103 | out: |
@@ -106,8 +106,8 @@ out: | |||
106 | 106 | ||
107 | /** | 107 | /** |
108 | * ecryptfs_readdir | 108 | * ecryptfs_readdir |
109 | * @file: The ecryptfs file struct | 109 | * @file: The eCryptfs directory file |
110 | * @dirent: Directory entry | 110 | * @dirent: Directory entry handle |
111 | * @filldir: The filldir callback function | 111 | * @filldir: The filldir callback function |
112 | */ | 112 | */ |
113 | static int ecryptfs_readdir(struct file *file, void *dirent, filldir_t filldir) | 113 | static int ecryptfs_readdir(struct file *file, void *dirent, filldir_t filldir) |