diff options
Diffstat (limited to 'fs/stat.c')
-rw-r--r-- | fs/stat.c | 31 |
1 files changed, 25 insertions, 6 deletions
@@ -37,14 +37,21 @@ void generic_fillattr(struct inode *inode, struct kstat *stat) | |||
37 | 37 | ||
38 | EXPORT_SYMBOL(generic_fillattr); | 38 | EXPORT_SYMBOL(generic_fillattr); |
39 | 39 | ||
40 | int vfs_getattr(struct path *path, struct kstat *stat) | 40 | /** |
41 | * vfs_getattr_nosec - getattr without security checks | ||
42 | * @path: file to get attributes from | ||
43 | * @stat: structure to return attributes in | ||
44 | * | ||
45 | * Get attributes without calling security_inode_getattr. | ||
46 | * | ||
47 | * Currently the only caller other than vfs_getattr is internal to the | ||
48 | * filehandle lookup code, which uses only the inode number and returns | ||
49 | * no attributes to any user. Any other code probably wants | ||
50 | * vfs_getattr. | ||
51 | */ | ||
52 | int vfs_getattr_nosec(struct path *path, struct kstat *stat) | ||
41 | { | 53 | { |
42 | struct inode *inode = path->dentry->d_inode; | 54 | struct inode *inode = path->dentry->d_inode; |
43 | int retval; | ||
44 | |||
45 | retval = security_inode_getattr(path->mnt, path->dentry); | ||
46 | if (retval) | ||
47 | return retval; | ||
48 | 55 | ||
49 | if (inode->i_op->getattr) | 56 | if (inode->i_op->getattr) |
50 | return inode->i_op->getattr(path->mnt, path->dentry, stat); | 57 | return inode->i_op->getattr(path->mnt, path->dentry, stat); |
@@ -53,6 +60,18 @@ int vfs_getattr(struct path *path, struct kstat *stat) | |||
53 | return 0; | 60 | return 0; |
54 | } | 61 | } |
55 | 62 | ||
63 | EXPORT_SYMBOL(vfs_getattr_nosec); | ||
64 | |||
65 | int vfs_getattr(struct path *path, struct kstat *stat) | ||
66 | { | ||
67 | int retval; | ||
68 | |||
69 | retval = security_inode_getattr(path->mnt, path->dentry); | ||
70 | if (retval) | ||
71 | return retval; | ||
72 | return vfs_getattr_nosec(path, stat); | ||
73 | } | ||
74 | |||
56 | EXPORT_SYMBOL(vfs_getattr); | 75 | EXPORT_SYMBOL(vfs_getattr); |
57 | 76 | ||
58 | int vfs_fstat(unsigned int fd, struct kstat *stat) | 77 | int vfs_fstat(unsigned int fd, struct kstat *stat) |