All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] cgroup allow subsys to set default mode of its own file
@ 2009-02-25  7:35 KAMEZAWA Hiroyuki
  2009-02-25  7:37 ` [PATCH 2/2] cgroup/memcg show correct file mode KAMEZAWA Hiroyuki
                   ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: KAMEZAWA Hiroyuki @ 2009-02-25  7:35 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org
  Cc: containers@lists.linux-foundation.org, menage@google.com,
	lizf@cn.fujitsu.com, akpm@linux-foundation.org,
	balbir@linux.vnet.ibm.com

From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

cgroup's subsys has "readonly" files, but default permission is always
rw-r--r--. This allows to create r--r--r-- file to subsys.
(The user can do chmod on this read-only file. But this behavior is not
 different from current pseudo file systems as /proc.)

Reason:
 When I wrote tools for maintain cgroup, I can't find which file is
 writable intarfece or not via cgroup file systems. (finally, I did
 dirty approach.)
 IMHO, showing "this file is read-only" in explicit way is useful
 for user-land (tools). In other story, a file whose name sounds read-only
 may have "trigger" operation and support reseting. In this case,
 "writable" is informative.
 

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---
 include/linux/cgroup.h |    2 ++
 kernel/cgroup.c        |    5 ++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

Index: mmotm-2.6.29-Feb24/include/linux/cgroup.h
===================================================================
--- mmotm-2.6.29-Feb24.orig/include/linux/cgroup.h
+++ mmotm-2.6.29-Feb24/include/linux/cgroup.h
@@ -258,6 +258,8 @@ struct cftype {
 	 */
 	char name[MAX_CFTYPE_NAME];
 	int private;
+	/* if not 0, mode is set to mode, otherwise 0644 */
+	int mode;
 
 	/*
 	 * If non-zero, defines the maximum length of string that can
Index: mmotm-2.6.29-Feb24/kernel/cgroup.c
===================================================================
--- mmotm-2.6.29-Feb24.orig/kernel/cgroup.c
+++ mmotm-2.6.29-Feb24/kernel/cgroup.c
@@ -1767,7 +1767,10 @@ int cgroup_add_file(struct cgroup *cgrp,
 	BUG_ON(!mutex_is_locked(&dir->d_inode->i_mutex));
 	dentry = lookup_one_len(name, dir, strlen(name));
 	if (!IS_ERR(dentry)) {
-		error = cgroup_create_file(dentry, 0644 | S_IFREG,
+		int mode = 0644;
+		if (cft->mode)
+			mode = cft->mode;
+		error = cgroup_create_file(dentry, mode | S_IFREG,
 						cgrp->root->sb);
 		if (!error)
 			dentry->d_fsdata = (void *)cft;


^ permalink raw reply	[flat|nested] 26+ messages in thread
* [PATCH 1/2] cgroup allow subsys to set default mode of its own file
@ 2009-02-25  7:35 KAMEZAWA Hiroyuki
  0 siblings, 0 replies; 26+ messages in thread
From: KAMEZAWA Hiroyuki @ 2009-02-25  7:35 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
  Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	menage-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org,
	balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org

From: KAMEZAWA Hiroyuki <kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>

cgroup's subsys has "readonly" files, but default permission is always
rw-r--r--. This allows to create r--r--r-- file to subsys.
(The user can do chmod on this read-only file. But this behavior is not
 different from current pseudo file systems as /proc.)

Reason:
 When I wrote tools for maintain cgroup, I can't find which file is
 writable intarfece or not via cgroup file systems. (finally, I did
 dirty approach.)
 IMHO, showing "this file is read-only" in explicit way is useful
 for user-land (tools). In other story, a file whose name sounds read-only
 may have "trigger" operation and support reseting. In this case,
 "writable" is informative.
 

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
---
 include/linux/cgroup.h |    2 ++
 kernel/cgroup.c        |    5 ++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

Index: mmotm-2.6.29-Feb24/include/linux/cgroup.h
===================================================================
--- mmotm-2.6.29-Feb24.orig/include/linux/cgroup.h
+++ mmotm-2.6.29-Feb24/include/linux/cgroup.h
@@ -258,6 +258,8 @@ struct cftype {
 	 */
 	char name[MAX_CFTYPE_NAME];
 	int private;
+	/* if not 0, mode is set to mode, otherwise 0644 */
+	int mode;
 
 	/*
 	 * If non-zero, defines the maximum length of string that can
Index: mmotm-2.6.29-Feb24/kernel/cgroup.c
===================================================================
--- mmotm-2.6.29-Feb24.orig/kernel/cgroup.c
+++ mmotm-2.6.29-Feb24/kernel/cgroup.c
@@ -1767,7 +1767,10 @@ int cgroup_add_file(struct cgroup *cgrp,
 	BUG_ON(!mutex_is_locked(&dir->d_inode->i_mutex));
 	dentry = lookup_one_len(name, dir, strlen(name));
 	if (!IS_ERR(dentry)) {
-		error = cgroup_create_file(dentry, 0644 | S_IFREG,
+		int mode = 0644;
+		if (cft->mode)
+			mode = cft->mode;
+		error = cgroup_create_file(dentry, mode | S_IFREG,
 						cgrp->root->sb);
 		if (!error)
 			dentry->d_fsdata = (void *)cft;

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2009-02-27  5:12 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-25  7:35 [PATCH 1/2] cgroup allow subsys to set default mode of its own file KAMEZAWA Hiroyuki
2009-02-25  7:37 ` [PATCH 2/2] cgroup/memcg show correct file mode KAMEZAWA Hiroyuki
     [not found]   ` <20090225163729.cc43bd5c.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2009-02-25  8:03     ` Balbir Singh
2009-02-25  8:03       ` Balbir Singh
2009-02-25  8:09       ` Dhaval Giani
     [not found]       ` <20090225080329.GE11421-SINUvgVNF2CyUtPGxGje5AC/G2K4zDHf@public.gmane.org>
2009-02-25  8:09         ` Dhaval Giani
2009-02-25  8:01 ` [PATCH 1/2] cgroup allow subsys to set default mode of its own file Li Zefan
     [not found] ` <20090225163555.d2a0b24c.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2009-02-25  7:37   ` [PATCH 2/2] cgroup/memcg show correct file mode KAMEZAWA Hiroyuki
2009-02-25  8:01   ` [PATCH 1/2] cgroup allow subsys to set default mode of its own file Li Zefan
2009-02-25  8:03   ` Balbir Singh
2009-02-25  8:03     ` Balbir Singh
2009-02-26 21:00   ` Andrew Morton
2009-02-26 21:00     ` Andrew Morton
2009-02-27  0:20     ` KAMEZAWA Hiroyuki
2009-02-27  5:08       ` Dhaval Giani
     [not found]       ` <20090227092031.f42cbbbe.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2009-02-27  5:08         ` Dhaval Giani
2009-02-27  5:12         ` Balbir Singh
2009-02-27  5:12       ` Balbir Singh
     [not found]     ` <20090226130005.3282cb02.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2009-02-27  0:20       ` KAMEZAWA Hiroyuki
2009-02-27  0:28       ` Paul Menage
2009-02-27  0:28     ` Paul Menage
     [not found]       ` <6599ad830902261628k4ce8e1aflb7981672562801fb-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-02-27  0:38         ` KAMEZAWA Hiroyuki
2009-02-27  0:40         ` Li Zefan
2009-02-27  0:38       ` KAMEZAWA Hiroyuki
2009-02-27  0:40       ` Li Zefan
  -- strict thread matches above, loose matches on Subject: below --
2009-02-25  7:35 KAMEZAWA Hiroyuki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.