Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755747AbcDNOwY (ORCPT ); Thu, 14 Apr 2016 10:52:24 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:54055 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751436AbcDNOwV (ORCPT ); Thu, 14 Apr 2016 10:52:21 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: "Serge E. Hallyn" Cc: Tejun Heo , linux-api@vger.kernel.org, adityakali@google.com, Linux Containers , cgroups@vger.kernel.org, lkml References: <20160321234133.GA22463@mail.hallyn.com> <20160413175736.GC3676@htj.duckdns.org> <20160414040436.GA3739@mail.hallyn.com> Date: Thu, 14 Apr 2016 09:42:00 -0500 In-Reply-To: <20160414040436.GA3739@mail.hallyn.com> (Serge E. Hallyn's message of "Wed, 13 Apr 2016 23:04:36 -0500") Message-ID: <87oa9c6ymf.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-AID: U2FsdGVkX1+pF8uyCxXRPLD96OhR6IAM+nbaziiw7tc= X-SA-Exim-Connect-IP: 67.3.249.252 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa05 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa05 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;"Serge E. Hallyn" X-Spam-Relay-Country: X-Spam-Timing: total 650 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 4.6 (0.7%), b_tie_ro: 3.2 (0.5%), parse: 1.29 (0.2%), extract_message_metadata: 19 (2.9%), get_uri_detail_list: 3.7 (0.6%), tests_pri_-1000: 5 (0.8%), tests_pri_-950: 1.11 (0.2%), tests_pri_-900: 0.92 (0.1%), tests_pri_-400: 21 (3.3%), check_bayes: 20 (3.1%), b_tokenize: 7 (1.1%), b_tok_get_all: 6 (1.0%), b_comp_prob: 1.84 (0.3%), b_tok_touch_all: 3.3 (0.5%), b_finish: 0.64 (0.1%), tests_pri_0: 569 (87.5%), check_dkim_signature: 0.50 (0.1%), check_dkim_adsp: 112 (17.3%), tests_pri_500: 24 (3.7%), poll_dns_idle: 18 (2.8%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH] cgroup namespaces: add a 'nsroot=' mountinfo field X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Wed, 24 Sep 2014 11:00:52 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3267 Lines: 100 "Serge E. Hallyn" writes: > This is so that userspace can distinguish a mount made in a cgroup > namespace from a bind mount from a cgroup subdirectory. To do that do you need to print the path, or is an extra option that reveals nothing except that it was a cgroup mount sufficient? Is there any practical difference between a mount in a namespace and a bind mount? Given the way the conversation has been going I think it would be good to see the answers to these questions. Perhaps I missed it but I haven't seen the answers to those questions. Eric > > Signed-off-by: Serge Hallyn > --- > 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; > }