aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 5e2d98d10c5d..a83160acd748 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -107,6 +107,8 @@
107 * any extra contention... 107 * any extra contention...
108 */ 108 */
109 109
110static int fastcall link_path_walk(const char *name, struct nameidata *nd);
111
110/* In order to reduce some races, while at the same time doing additional 112/* In order to reduce some races, while at the same time doing additional
111 * checking and hopefully speeding things up, we copy filenames to the 113 * checking and hopefully speeding things up, we copy filenames to the
112 * kernel data space before using them.. 114 * kernel data space before using them..
@@ -998,7 +1000,7 @@ return_err:
998 * Retry the whole path once, forcing real lookup requests 1000 * Retry the whole path once, forcing real lookup requests
999 * instead of relying on the dcache. 1001 * instead of relying on the dcache.
1000 */ 1002 */
1001int fastcall link_path_walk(const char *name, struct nameidata *nd) 1003static int fastcall link_path_walk(const char *name, struct nameidata *nd)
1002{ 1004{
1003 struct nameidata save = *nd; 1005 struct nameidata save = *nd;
1004 int result; 1006 int result;
@@ -1022,7 +1024,7 @@ int fastcall link_path_walk(const char *name, struct nameidata *nd)
1022 return result; 1024 return result;
1023} 1025}
1024 1026
1025int fastcall path_walk(const char * name, struct nameidata *nd) 1027static int fastcall path_walk(const char * name, struct nameidata *nd)
1026{ 1028{
1027 current->total_link_count = 0; 1029 current->total_link_count = 0;
1028 return link_path_walk(name, nd); 1030 return link_path_walk(name, nd);
@@ -1172,6 +1174,37 @@ int fastcall path_lookup(const char *name, unsigned int flags,
1172 return do_path_lookup(AT_FDCWD, name, flags, nd); 1174 return do_path_lookup(AT_FDCWD, name, flags, nd);
1173} 1175}
1174 1176
1177/**
1178 * vfs_path_lookup - lookup a file path relative to a dentry-vfsmount pair
1179 * @dentry: pointer to dentry of the base directory
1180 * @mnt: pointer to vfs mount of the base directory
1181 * @name: pointer to file name
1182 * @flags: lookup flags
1183 * @nd: pointer to nameidata
1184 */
1185int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
1186 const char *name, unsigned int flags,
1187 struct nameidata *nd)
1188{
1189 int retval;
1190
1191 /* same as do_path_lookup */
1192 nd->last_type = LAST_ROOT;
1193 nd->flags = flags;
1194 nd->depth = 0;
1195
1196 nd->mnt = mntget(mnt);
1197 nd->dentry = dget(dentry);
1198
1199 retval = path_walk(name, nd);
1200 if (unlikely(!retval && !audit_dummy_context() && nd->dentry &&
1201 nd->dentry->d_inode))
1202 audit_inode(name, nd->dentry->d_inode);
1203
1204 return retval;
1205
1206}
1207
1175static int __path_lookup_intent_open(int dfd, const char *name, 1208static int __path_lookup_intent_open(int dfd, const char *name,
1176 unsigned int lookup_flags, struct nameidata *nd, 1209 unsigned int lookup_flags, struct nameidata *nd,
1177 int open_flags, int create_mode) 1210 int open_flags, int create_mode)
@@ -1576,7 +1609,7 @@ int may_open(struct nameidata *nd, int acc_mode, int flag)
1576 1609
1577 /* O_NOATIME can only be set by the owner or superuser */ 1610 /* O_NOATIME can only be set by the owner or superuser */
1578 if (flag & O_NOATIME) 1611 if (flag & O_NOATIME)
1579 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) 1612 if (!is_owner_or_cap(inode))
1580 return -EPERM; 1613 return -EPERM;
1581 1614
1582 /* 1615 /*
@@ -2774,8 +2807,8 @@ EXPORT_SYMBOL(__page_symlink);
2774EXPORT_SYMBOL(page_symlink); 2807EXPORT_SYMBOL(page_symlink);
2775EXPORT_SYMBOL(page_symlink_inode_operations); 2808EXPORT_SYMBOL(page_symlink_inode_operations);
2776EXPORT_SYMBOL(path_lookup); 2809EXPORT_SYMBOL(path_lookup);
2810EXPORT_SYMBOL(vfs_path_lookup);
2777EXPORT_SYMBOL(path_release); 2811EXPORT_SYMBOL(path_release);
2778EXPORT_SYMBOL(path_walk);
2779EXPORT_SYMBOL(permission); 2812EXPORT_SYMBOL(permission);
2780EXPORT_SYMBOL(vfs_permission); 2813EXPORT_SYMBOL(vfs_permission);
2781EXPORT_SYMBOL(file_permission); 2814EXPORT_SYMBOL(file_permission);