Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1378466
| From | "Serge E. Hallyn" <serge@hallyn.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] cgroup namespaces: add a 'nsroot=' mountinfo field |
| Date | 2016-04-14 06:10 +0200 |
| Message-ID | <rnGLn-449-5@gated-at.bofh.it> (permalink) |
| References | <rfhKa-4mP-27@gated-at.bofh.it> <rnxf5-4Yd-23@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
This is so that userspace can distinguish a mount made in a cgroup
namespace from a bind mount from a cgroup subdirectory.
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
---
Changelog: 2016-04-13: pass kernfs_node rather than dentry to show_options
---
fs/kernfs/mount.c | 2 +-
include/linux/kernfs.h | 3 ++-
kernel/cgroup.c | 28 +++++++++++++++++++++++++++-
3 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c
index f73541f..58e8a86 100644
--- a/fs/kernfs/mount.c
+++ b/fs/kernfs/mount.c
@@ -36,7 +36,7 @@ static int kernfs_sop_show_options(struct seq_file *sf, struct dentry *dentry)
struct kernfs_syscall_ops *scops = root->syscall_ops;
if (scops && scops->show_options)
- return scops->show_options(sf, root);
+ return scops->show_options(sf, dentry->d_fsdata, root);
return 0;
}
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
index c06c442..72b4081 100644
--- a/include/linux/kernfs.h
+++ b/include/linux/kernfs.h
@@ -145,7 +145,8 @@ struct kernfs_node {
*/
struct kernfs_syscall_ops {
int (*remount_fs)(struct kernfs_root *root, int *flags, char *data);
- int (*show_options)(struct seq_file *sf, struct kernfs_root *root);
+ int (*show_options)(struct seq_file *sf, struct kernfs_node *kn,
+ struct kernfs_root *root);
int (*mkdir)(struct kernfs_node *parent, const char *name,
umode_t mode);
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 671dc05..4d26d07 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1593,7 +1593,31 @@ static int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)
return 0;
}
-static int cgroup_show_options(struct seq_file *seq,
+static void cgroup_show_nsroot(struct seq_file *seq, struct kernfs_node *knode,
+ struct kernfs_root *kroot)
+{
+ char *nsroot;
+ int len, ret;
+
+ if (!kroot)
+ return;
+ len = kernfs_path_from_node(knode, kroot->kn, NULL, 0);
+ if (len <= 0)
+ return;
+ nsroot = kzalloc(len + 1, GFP_ATOMIC);
+ if (!nsroot)
+ return;
+ ret = kernfs_path_from_node(knode, kroot->kn, nsroot, len + 1);
+ if (ret <= 0 || ret > len)
+ goto out;
+
+ seq_show_option(seq, "nsroot", nsroot);
+
+out:
+ kfree(nsroot);
+}
+
+static int cgroup_show_options(struct seq_file *seq, struct kernfs_node *kn,
struct kernfs_root *kf_root)
{
struct cgroup_root *root = cgroup_root_from_kf(kf_root);
@@ -1619,6 +1643,8 @@ static int cgroup_show_options(struct seq_file *seq,
seq_puts(seq, ",clone_children");
if (strlen(root->name))
seq_show_option(seq, "name", root->name);
+ cgroup_show_nsroot(seq, kn, kf_root);
+
return 0;
}
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [RFC PATCH] cgroup namespaces: add a 'nsroot=' mountinfo field Tejun Heo <tj@kernel.org> - 2016-04-13 20:00 +0200
Re: [RFC PATCH] cgroup namespaces: add a 'nsroot=' mountinfo field "Serge E. Hallyn" <serge@hallyn.com> - 2016-04-13 20:50 +0200
Re: [RFC PATCH] cgroup namespaces: add a 'nsroot=' mountinfo field Tejun Heo <tj@kernel.org> - 2016-04-13 21:00 +0200
Re: [RFC PATCH] cgroup namespaces: add a 'nsroot=' mountinfo field "Serge E. Hallyn" <serge@hallyn.com> - 2016-04-13 21:10 +0200
Re: [RFC PATCH] cgroup namespaces: add a 'nsroot=' mountinfo field Tejun Heo <tj@kernel.org> - 2016-04-13 21:20 +0200
Re: [RFC PATCH] cgroup namespaces: add a 'nsroot=' mountinfo field Aditya Kali <adityakali@google.com> - 2016-04-14 01:40 +0200
Re: [RFC PATCH] cgroup namespaces: add a 'nsroot=' mountinfo field "Serge E. Hallyn" <serge@hallyn.com> - 2016-04-14 02:00 +0200
[PATCH] cgroup namespaces: add a 'nsroot=' mountinfo field "Serge E. Hallyn" <serge@hallyn.com> - 2016-04-14 06:10 +0200
Re: [PATCH] cgroup namespaces: add a 'nsroot=' mountinfo field ebiederm@xmission.com (Eric W. Biederman) - 2016-04-14 17:00 +0200
Re: [PATCH] cgroup namespaces: add a 'nsroot=' mountinfo field "Serge E. Hallyn" <serge@hallyn.com> - 2016-04-14 17:30 +0200
Re: [PATCH] cgroup namespaces: add a 'nsroot=' mountinfo field ebiederm@xmission.com (Eric W. Biederman) - 2016-04-14 18:30 +0200
Re: [PATCH] cgroup namespaces: add a 'nsroot=' mountinfo field "Serge E. Hallyn" <serge@hallyn.com> - 2016-04-14 18:40 +0200
Re: [PATCH] cgroup namespaces: add a 'nsroot=' mountinfo field ebiederm@xmission.com (Eric W. Biederman) - 2016-04-14 19:00 +0200
Re: [PATCH] cgroup namespaces: add a 'nsroot=' mountinfo field Aditya Kali <adityakali@google.com> - 2016-04-15 18:00 +0200
Re: [PATCH] cgroup namespaces: add a 'nsroot=' mountinfo field "Serge E. Hallyn" <serge@hallyn.com> - 2016-04-15 18:10 +0200
csiph-web