2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-09-05 16:55:32 +00:00
Files
apparmor/kernel-patches/for-mainline/d_namespace_path.diff

73 lines
2.4 KiB
Diff
Raw Normal View History

2007-02-15 11:03:05 +00:00
Index: b/include/linux/dcache.h
2007-02-06 18:57:06 +00:00
===================================================================
2007-02-15 11:03:05 +00:00
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
2007-02-06 18:57:06 +00:00
@@ -293,6 +293,8 @@ extern struct dentry * d_hash_and_lookup
/* validate "insecure" dentry pointer */
extern int d_validate(struct dentry *, struct dentry *);
+extern char *__d_path(struct dentry *, struct vfsmount *, struct dentry *,
+ struct vfsmount *, char *, int, int);
extern char * d_path(struct dentry *, struct vfsmount *, char *, int);
/* Allocation counts.. */
2007-02-15 11:03:05 +00:00
Index: b/fs/dcache.c
2007-02-06 18:57:06 +00:00
===================================================================
2007-02-15 11:03:05 +00:00
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1750,9 +1750,9 @@ shouldnt_be_hashed:
2007-02-06 18:57:06 +00:00
*
* Returns the buffer or an error code.
*/
-static char *__d_path(struct dentry *dentry, struct vfsmount *vfsmnt,
- struct dentry *root, struct vfsmount *rootmnt,
- char *buffer, int buflen, int fail_deleted)
+char *__d_path(struct dentry *dentry, struct vfsmount *vfsmnt,
+ struct dentry *root, struct vfsmount *rootmnt,
+ char *buffer, int buflen, int fail_deleted)
{
2007-02-15 11:03:05 +00:00
int namelen, is_slash;
Index: b/fs/namespace.c
2007-02-06 18:57:06 +00:00
===================================================================
2007-02-15 11:03:05 +00:00
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1894,3 +1894,25 @@ void __put_mnt_ns(struct mnt_namespace *
2007-02-06 18:57:06 +00:00
release_mounts(&umount_list);
kfree(ns);
}
+
+char *d_namespace_path(struct dentry *dentry, struct vfsmount *vfsmnt,
+ char *buf, int buflen)
2007-02-06 18:57:06 +00:00
+{
+ char *res;
+ struct vfsmount *rootmnt, *nsrootmnt;
+ struct dentry *root;
+
+ read_lock(&current->fs->lock);
+ rootmnt = mntget(current->fs->rootmnt);
+ read_unlock(&current->fs->lock);
+ spin_lock(&vfsmount_lock);
+ nsrootmnt = mntget(rootmnt->mnt_ns->root);
+ root = dget(nsrootmnt->mnt_root);
+ spin_unlock(&vfsmount_lock);
+ mntput(rootmnt);
+ res = __d_path(dentry, vfsmnt, root, nsrootmnt, buf, buflen, 1);
2007-02-06 18:57:06 +00:00
+ dput(root);
+ mntput(nsrootmnt);
+ return res;
+}
+EXPORT_SYMBOL(d_namespace_path);
2007-02-15 11:03:05 +00:00
Index: b/include/linux/mount.h
2007-02-06 18:57:06 +00:00
===================================================================
2007-02-15 11:03:05 +00:00
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -103,5 +103,7 @@ extern void shrink_submounts(struct vfsm
2007-02-06 18:57:06 +00:00
extern spinlock_t vfsmount_lock;
extern dev_t name_to_dev_t(char *name);
+extern char *d_namespace_path(struct dentry *, struct vfsmount *, char *, int);
2007-02-06 18:57:06 +00:00
+
#endif
#endif /* _LINUX_MOUNT_H */