VFS: introduce vfs_path_lookup() from newer kernels
authorErez Zadok <ezk@cs.sunysb.edu>
Mon, 28 Jul 2008 07:33:49 +0000 (03:33 -0400)
committerErez Zadok <ezk@cs.sunysb.edu>
Mon, 28 Jul 2008 07:33:49 +0000 (03:33 -0400)
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/namei.c
include/linux/namei.h

index 0a7647e41d9e6060fefd1876c59eac417135355c..53fd065b287cecec8fc129f2d2827ff3e95d65ee 100644 (file)
@@ -960,6 +960,39 @@ int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata
        return retval;
 }
 
+/**
+ * vfs_path_lookup - lookup a file path relative to a dentry-vfsmount pair
+ * @dentry:  pointer to dentry of the base directory
+ * @mnt: pointer to vfs mount of the base directory
+ * @name: pointer to file name
+ * @flags: lookup flags
+ * @nd: pointer to nameidata
+ */
+int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
+                   const char *name, unsigned int flags,
+                   struct nameidata *nd)
+{
+       int retval;
+
+       /* same as do_path_lookup */
+       nd->last_type = LAST_ROOT;
+       nd->flags = flags;
+       nd->depth = 0;
+
+       nd->mnt = mntget(mnt);
+       nd->dentry = dget(dentry);
+
+       retval = path_walk(name, nd);
+       if (unlikely(!retval && current->audit_context && nd->dentry &&
+                               nd->dentry->d_inode))
+               audit_inode(name,
+                           nd->dentry->d_inode->i_ino,
+                           nd->dentry->d_inode->i_rdev);
+
+       return retval;
+
+}
+
 /*
  * Restricted form of lookup. Doesn't follow links, single-component only,
  * needs parent already locked. Doesn't follow mounts.
@@ -2395,6 +2428,7 @@ EXPORT_SYMBOL(page_readlink);
 EXPORT_SYMBOL(page_symlink);
 EXPORT_SYMBOL(page_symlink_inode_operations);
 EXPORT_SYMBOL(path_lookup);
+EXPORT_SYMBOL(vfs_path_lookup);
 EXPORT_SYMBOL(path_release);
 EXPORT_SYMBOL(path_walk);
 EXPORT_SYMBOL(permission);
index 1bbfa296e11f18645c1a861b236ddc5406654724..dcb7f41f1927302a1cd7dfa3ab208cbefac73d37 100644 (file)
@@ -60,6 +60,8 @@ extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata
 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
 extern int FASTCALL(path_walk(const char *, struct nameidata *));
 extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
+extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
+                          const char *, unsigned int, struct nameidata *);
 extern void path_release(struct nameidata *);
 extern void path_release_on_umount(struct nameidata *);