]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/suse-2.6.27.31/patches.apparmor/d_namespace_path.diff
Add a patch to fix Intel E100 wake-on-lan problems.
[people/pmueller/ipfire-2.x.git] / src / patches / suse-2.6.27.31 / patches.apparmor / d_namespace_path.diff
1 From: Andreas Gruenbacher <agruen@suse.de>
2 Subject: Add d_namespace_path() to compute namespace relative pathnames
3
4 In AppArmor, we are interested in pathnames relative to the namespace root.
5 This is the same as d_path() except for the root where the search ends. Add
6 a function for computing the namespace-relative path.
7
8 Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
9 Signed-off-by: John Johansen <jjohansen@suse.de>
10
11 ---
12 fs/namespace.c | 30 ++++++++++++++++++++++++++++++
13 include/linux/mount.h | 2 ++
14 2 files changed, 32 insertions(+)
15
16 --- a/fs/namespace.c
17 +++ b/fs/namespace.c
18 @@ -2357,3 +2357,33 @@ void put_mnt_ns(struct mnt_namespace *ns
19 kfree(ns);
20 }
21 EXPORT_SYMBOL(put_mnt_ns);
22 +
23 +char *d_namespace_path(struct dentry *dentry, struct vfsmount *vfsmnt,
24 + char *buf, int buflen)
25 +{
26 + struct path root, tmp, ns_root = { };
27 + struct path path = { .mnt = vfsmnt, .dentry = dentry };
28 + char *res;
29 +
30 + read_lock(&current->fs->lock);
31 + root = current->fs->root;
32 + path_get(&current->fs->root);
33 + read_unlock(&current->fs->lock);
34 + spin_lock(&vfsmount_lock);
35 + if (root.mnt)
36 + ns_root.mnt = mntget(root.mnt->mnt_ns->root);
37 + if (ns_root.mnt)
38 + ns_root.dentry = dget(ns_root.mnt->mnt_root);
39 + spin_unlock(&vfsmount_lock);
40 + tmp = ns_root;
41 + res = __d_path(&path, &tmp, buf, buflen,
42 + D_PATH_FAIL_DELETED | D_PATH_DISCONNECT);
43 + path_put(&root);
44 + path_put(&ns_root);
45 +
46 + /* Prevent empty path for lazily unmounted filesystems. */
47 + if (!IS_ERR(res) && *res == '\0')
48 + *--res = '.';
49 + return res;
50 +}
51 +EXPORT_SYMBOL(d_namespace_path);
52 --- a/include/linux/mount.h
53 +++ b/include/linux/mount.h
54 @@ -137,4 +137,6 @@ extern void mark_mounts_for_expiry(struc
55 extern spinlock_t vfsmount_lock;
56 extern dev_t name_to_dev_t(char *name);
57
58 +extern char *d_namespace_path(struct dentry *, struct vfsmount *, char *, int);
59 +
60 #endif /* _LINUX_MOUNT_H */