cgroups: show correct file mode
PATCH 1/1 cgroups: show correct file mode
Andrew, please drop these 2 patches:
cgroup-allow-subsys-to-set-default-mode-of-its-own-file.patch cgroup-memcg-show-correct-file-mode.patch
Here is a patch to replace them.
=============
From: Li Zefan <[email protected]>
Date: Tue, 3 Mar 2009 08:55:58 +0800
Subject: [PATCH] cgroups: show correct file mode
We have some read-only files and write-only files, but currently they are all set to 0644, which is counter-intuitive and cause trouble for some cgroup tools like libcgroup.
This patch adds 'mode' to struct cftype to allow cgroup subsys to set it's own files' file mode, and for the most cases cft->mode can be default to 0 and cgroup will figure out proper mode.
--- include/linux/cgroup.h | 5 +++++ kernel/cgroup.c | 32 +++++++++++++++++++++++++++++++- kernel/cpuset.c | 1 + 3 files changed, 37 insertions(+), 1 deletions(-)
include/linux/cgroup.h +5 -0
@@ -258,6 +258,11 @@ struct cftype {*/ char name[MAX_CFTYPE_NAME ];int private; +/* +* If not 0, file mode is set to this value, otherwise it will +* be figured out automatically +*/ +int mode;/* * If non-zero, defines the maximum length of string that can
kernel/cgroup.c +31 -1
@@ -1750,6 +1750,33 @@ static int cgroup_create_dir(struct cgroup *cgrp, struct dentry *dentry,return error; } +/** +* cgroup_file_mode - deduce file mode of a control file +* @cft: the control file in question +* +* returns cft->mode if ->mode is not 0 +* returns 0644 if it has both a read and a write handler +* returns 0444 if it has only a read handler +* returns 0200 if it has only a write hander +*/ +static int cgroup_file_mode (const struct cftype *cft) +{ +int mode =0 ; + +if (cft->mode) +return cft->mode; + +if (cft->read || cft->read_u64 || cft->read_s64 || + cft->read_map || cft->read_seq_string) + mode |=0444 ; + +if (cft->write || cft->write_u64 || cft->write_s64 || + cft->write_string || cft->trigger) + mode |=0200 ; + +return mode; +} +int cgroup_add_file (struct cgroup *cgrp,struct cgroup_subsys *subsys,const struct cftype *cft)
@@ -1757,6 +1784,7 @@ int cgroup_add_file(struct cgroup *cgrp,struct dentry *dir = cgrp->dentry;struct dentry *dentry;int error; +int mode;char name[MAX_CGROUP_TYPE_NAMELEN +MAX_CFTYPE_NAME +2 ] = {0 };if (subsys && !test_bit (ROOT_NOPREFIX , &cgrp->root->flags)) {
@@ -1767,7 +1795,8 @@ 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 , + mode =cgroup_file_mode (cft); + error =cgroup_create_file (dentry, mode |S_IFREG , cgrp->root->sb);if (!error) dentry->d_fsdata = (void *)cft;
@@ -2349,6 +2378,7 @@ static struct cftype files[] = { .write_u64 = cgroup_tasks_write, .release = cgroup_tasks_release, .private = FILE_TASKLIST, + .mode = 0644, }, {
kernel/cpuset.c +1 -0
@@ -1678,6 +1678,7 @@ static struct cftype files[] = { .read_u64 = cpuset_read_u64, .write_u64 = cpuset_write_u64, .private = FILE_MEMORY_PRESSURE, + .mode = 0444, }, {
Signature · 1 line
1.5.4.rc3
Quoted 23 lines · On Tue, 03 Mar 2009 13:29:27 +0800 Li Zefan…
We have some read-only files and write-only files, but currently they are all set to 0644, which is counter-intuitive and cause trouble for some cgroup tools like libcgroup.
This patch adds 'mode' to struct cftype to allow cgroup subsys to set it's own files' file mode, and for the most cases
cft->modecan be default to 0 and cgroup will figure out proper mode.Acked-by Paul Menage <[email protected]>Reviewed-by KAMEZAWA Hiroyuki <[email protected]>Signed-off-by Li Zefan <[email protected]>--- include/linux/cgroup.h | 5 +++++ kernel/cgroup.c | 32 +++++++++++++++++++++++++++++++- kernel/cpuset.c | 1 + 3 files changed, 37 insertions(+), 1 deletions(-)include/linux/cgroup.h +0
-0
include/linux/cgroup.h struct cftype { · line 265
Quoted 8 lines
include/linux/cgroup.h +5
-0@@ -258,6 +258,11 @@ struct cftype {*/ char name[MAX_CFTYPE_NAME ];int private; +/* +* If not 0, file mode is set to this value, otherwise it will +* be figured out automatically +*/ +int mode;
Could/should this (and everything else) have type mode_t?
Quoted 19 lines
include/linux/cgroup.h +0
-0/* * If non-zero, defines the maximum length of string that can kernel/cgroup.c +9
-0@@ -1750,6 +1750,33 @@ static int cgroup_create_dir(struct cgroup *cgrp, struct dentry *dentry,return error; } +/** +* cgroup_file_mode - deduce file mode of a control file +* @cft: the control file in question +* +* returns cft->mode if ->mode is not 0 +* returns 0644 if it has both a read and a write handler +* returns 0444 if it has only a read handler +* returns 0200 if it has only a write hander +*/
kernel/cgroup.c static int cgroup_create_dir(struct cgroup *cgrp, struct dentry *dentry, · line 1771
Quoted 10 lines
kernel/cgroup.c +10
-0+static int cgroup_file_mode (const struct cftype *cft) +{ +int mode =0 ; + +if (cft->mode) +return cft->mode; + +if (cft->read || cft->read_u64 || cft->read_s64 || + cft->read_map || cft->read_seq_string) + mode |=0444 ;
S_IRUGO?
kernel/cgroup.c static int cgroup_create_dir(struct cgroup *cgrp, struct dentry *dentry, · line 1775
Quoted 3 lines
kernel/cgroup.c +3
-0+if (cft->write || cft->write_u64 || cft->write_s64 || + cft->write_string || cft->trigger) + mode |=0200 ;
S_IWUSR?
kernel/cgroup.c int cgroup_add_file(struct cgroup *cgrp, · line 1787
Quoted 11 lines
kernel/cgroup.c +4
-0+return mode; +} +int cgroup_add_file (struct cgroup *cgrp,struct cgroup_subsys *subsys,const struct cftype *cft)@@ -1757,6 +1784,7 @@ int cgroup_add_file(struct cgroup *cgrp,struct dentry *dir = cgrp->dentry;struct dentry *dentry;int error; +int mode;
mode_t.
Quoted 13 lines
kernel/cgroup.c +2
-1char name[MAX_CGROUP_TYPE_NAMELEN +MAX_CFTYPE_NAME +2 ] = {0 };if (subsys && !test_bit (ROOT_NOPREFIX , &cgrp->root->flags)) {@@ -1767,7 +1795,8 @@ 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 , + mode =cgroup_file_mode (cft); + error =cgroup_create_file (dentry, mode |S_IFREG , cgrp->root->sb);if (!error) dentry->d_fsdata = (void *)cft;
kernel/cgroup.c static struct cftype files[] = { · line 2381
Quoted 4 lines
kernel/cgroup.c +1
-0@@ -2349,6 +2378,7 @@ static struct cftype files[] = { .write_u64 = cgroup_tasks_write, .release = cgroup_tasks_release, .private = FILE_TASKLIST, + .mode = 0644,
S_IRUGO|S_IWUSR ?
kernel/cpuset.c static struct cftype files[] = { · line 1681
Quoted 12 lines
kernel/cgroup.c +0
-0}, {kernel/cpuset.c +1
-0@@ -1678,6 +1678,7 @@ static struct cftype files[] = { .read_u64 = cpuset_read_u64, .write_u64 = cpuset_write_u64, .private = FILE_MEMORY_PRESSURE, + .mode = 0444,
S_IRUGO?
Quoted 6 lines
kernel/cpuset.c +0
-0}, {Signature · 1 line
1.5.4.rc3
PATCH 1/1 cgroups: show correct file mode, fix
- 'mode' should have type mode_t
- use S_IRUGO/S_IWUSR instead of 0444/0200
---
against cgroups-show-correct-file-mode.patch
--- include/linux/cgroup.h | 2 +- kernel/cgroup.c | 24 ++++++++++++------------ kernel/cpuset.c | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-)
include/linux/cgroup.h +1 -1
@@ -262,7 +262,7 @@ struct cftype {* If not 0, file mode is set to this value, otherwise it will * be figured out automatically */ -int mode; +mode_t mode;/* * If non-zero, defines the maximum length of string that can
kernel/cgroup.c +12 -12
@@ -1686,7 +1686,7 @@ static struct inode_operations cgroup_dir_inode_operations = { .rename = cgroup_rename, }; -static int cgroup_create_file (struct dentry *dentry,int mode, +static int cgroup_create_file (struct dentry *dentry,mode_t mode,struct super_block *sb) {static struct dentry_operations cgroup_dops = {
@@ -1732,7 +1732,7 @@ static int cgroup_create_file(struct dentry *dentry, int mode,* @mode: mode to set on new directory. */ static int cgroup_create_dir (struct cgroup *cgrp,struct dentry *dentry, -int mode) +mode_t mode) {struct dentry *parent;int error =0 ;
@@ -1755,24 +1755,24 @@ static int cgroup_create_dir(struct cgroup *cgrp, struct dentry *dentry,* @cft: the control file in question * * returns cft->mode if ->mode is not 0 -* returns 0644 if it has both a read and a write handler -* returns 0444 if it has only a read handler -* returns 0200 if it has only a write hander +* returns S_IRUGO|S_IWUSR if it has both a read and a write handler +* returns S_IRUGO if it has only a read handler +* returns S_IWUSR if it has only a write hander */ -static int cgroup_file_mode (const struct cftype *cft) +static mode_t cgroup_file_mode (const struct cftype *cft) { -int mode =0 ; +mode_t mode =0 ;if (cft->mode)return cft->mode;if (cft->read || cft->read_u64 || cft->read_s64 || cft->read_map || cft->read_seq_string) - mode |=0444 ; + mode |=S_IRUGO ;if (cft->write || cft->write_u64 || cft->write_s64 || cft->write_string || cft->trigger) - mode |=0200 ; + mode |=S_IWUSR ;return mode; }
@@ -1784,7 +1784,7 @@ int cgroup_add_file(struct cgroup *cgrp,struct dentry *dir = cgrp->dentry;struct dentry *dentry;int error; -int mode; +mode_t mode;char name[MAX_CGROUP_TYPE_NAMELEN +MAX_CFTYPE_NAME +2 ] = {0 };if (subsys && !test_bit (ROOT_NOPREFIX , &cgrp->root->flags)) {
@@ -2378,7 +2378,7 @@ static struct cftype files[] = { .write_u64 = cgroup_tasks_write, .release = cgroup_tasks_release, .private = FILE_TASKLIST, - .mode = 0644, + .mode = S_IRUGO | S_IWUSR, }, {
@@ -2479,7 +2479,7 @@ static void cgroup_unlock_hierarchy(struct cgroupfs_root *root)* Must be called with the mutex on the parent inode held */ static long cgroup_create (struct cgroup *parent,struct dentry *dentry, -int mode) +mode_t mode) {struct cgroup *cgrp;struct cgroupfs_root *root = parent->root;
kernel/cpuset.c +1 -1
@@ -1678,7 +1678,7 @@ static struct cftype files[] = { .read_u64 = cpuset_read_u64, .write_u64 = cpuset_write_u64, .private = FILE_MEMORY_PRESSURE, - .mode = 0444, + .mode = S_IRUGO, }, {
Signature · 1 line
1.5.4.rc3
A message that is not in the archive (sent off-list or not yet received): [email protected]
KAMEZAWA Hiroyuki
Reviewed-byRe: [PATCH] cgroups: show correct file mode, fix
Quoted 4 lines · On Wed, 04 Mar 2009 09:52:57 +0800 Li Zefan…
- 'mode' should have type
mode_t
- use S_IRUGO/S_IWUSR instead of 0444/0200Signed-off-by Li Zefan <[email protected]>
Thank you for quick work. I'll write memcg part on this.
Quoted 120 lines
---
against cgroups-show-correct-file-mode.patch
--- include/linux/cgroup.h | 2 +- kernel/cgroup.c | 24 ++++++++++++------------ kernel/cpuset.c | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-)include/linux/cgroup.h +1
-1@@ -262,7 +262,7 @@ struct cftype {* If not 0, file mode is set to this value, otherwise it will * be figured out automatically */ -int mode; +mode_t mode;/* * If non-zero, defines the maximum length of string that can kernel/cgroup.c +12
-12@@ -1686,7 +1686,7 @@ static struct inode_operations cgroup_dir_inode_operations = { .rename = cgroup_rename, }; -static int cgroup_create_file (struct dentry *dentry,int mode, +static int cgroup_create_file (struct dentry *dentry,mode_t mode,struct super_block *sb) {static struct dentry_operations cgroup_dops = {@@ -1732,7 +1732,7 @@ static int cgroup_create_file(struct dentry *dentry, int mode,* @mode: mode to set on new directory. */ static int cgroup_create_dir (struct cgroup *cgrp,struct dentry *dentry, -int mode) +mode_t mode) {struct dentry *parent;int error =0 ;@@ -1755,24 +1755,24 @@ static int cgroup_create_dir(struct cgroup *cgrp, struct dentry *dentry,* @cft: the control file in question * * returns cft->mode if ->mode is not 0 -* returns 0644 if it has both a read and a write handler -* returns 0444 if it has only a read handler -* returns 0200 if it has only a write hander +* returns S_IRUGO|S_IWUSR if it has both a read and a write handler +* returns S_IRUGO if it has only a read handler +* returns S_IWUSR if it has only a write hander */ -static int cgroup_file_mode (const struct cftype *cft) +static mode_t cgroup_file_mode (const struct cftype *cft) { -int mode =0 ; +mode_t mode =0 ;if (cft->mode)return cft->mode;if (cft->read || cft->read_u64 || cft->read_s64 || cft->read_map || cft->read_seq_string) - mode |=0444 ; + mode |=S_IRUGO ;if (cft->write || cft->write_u64 || cft->write_s64 || cft->write_string || cft->trigger) - mode |=0200 ; + mode |=S_IWUSR ;return mode; }@@ -1784,7 +1784,7 @@ int cgroup_add_file(struct cgroup *cgrp,struct dentry *dir = cgrp->dentry;struct dentry *dentry;int error; -int mode; +mode_t mode;char name[MAX_CGROUP_TYPE_NAMELEN +MAX_CFTYPE_NAME +2 ] = {0 };if (subsys && !test_bit (ROOT_NOPREFIX , &cgrp->root->flags)) {@@ -2378,7 +2378,7 @@ static struct cftype files[] = { .write_u64 = cgroup_tasks_write, .release = cgroup_tasks_release, .private = FILE_TASKLIST, - .mode = 0644, + .mode = S_IRUGO | S_IWUSR, }, {@@ -2479,7 +2479,7 @@ static void cgroup_unlock_hierarchy(struct cgroupfs_root *root)* Must be called with the mutex on the parent inode held */ static long cgroup_create (struct cgroup *parent,struct dentry *dentry, -int mode) +mode_t mode) {struct cgroup *cgrp;struct cgroupfs_root *root = parent->root;kernel/cpuset.c +1
-1@@ -1678,7 +1678,7 @@ static struct cftype files[] = { .read_u64 = cpuset_read_u64, .write_u64 = cpuset_write_u64, .private = FILE_MEMORY_PRESSURE, - .mode = 0444, + .mode = S_IRUGO, }, {Signature · 1 line
1.5.4.rc3
Re: [PATCH] cgroups: show correct file mode, fix
In reply to Li ZefanQuoted 4 lines · On Wed, 04 Mar 2009 09:52:57 +0800 Li Zefan <[email protected]> wrote:
- 'mode' should have type
mode_t
- use S_IRUGO/S_IWUSR instead of 0444/0200Signed-off-by Li Zefan <[email protected]>
Thank you for quick work. I'll write memcg part on this.
Quoted 120 lines
---
against cgroups-show-correct-file-mode.patch
--- include/linux/cgroup.h | 2 +- kernel/cgroup.c | 24 ++++++++++++------------ kernel/cpuset.c | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-)include/linux/cgroup.h +1
-1@@ -262,7 +262,7 @@ struct cftype {* If not 0, file mode is set to this value, otherwise it will * be figured out automatically */ -int mode; +mode_t mode;/* * If non-zero, defines the maximum length of string that can kernel/cgroup.c +12
-12@@ -1686,7 +1686,7 @@ static struct inode_operations cgroup_dir_inode_operations = { .rename = cgroup_rename, }; -static int cgroup_create_file (struct dentry *dentry,int mode, +static int cgroup_create_file (struct dentry *dentry,mode_t mode,struct super_block *sb) {static struct dentry_operations cgroup_dops = {@@ -1732,7 +1732,7 @@ static int cgroup_create_file(struct dentry *dentry, int mode,* @mode: mode to set on new directory. */ static int cgroup_create_dir (struct cgroup *cgrp,struct dentry *dentry, -int mode) +mode_t mode) {struct dentry *parent;int error =0 ;@@ -1755,24 +1755,24 @@ static int cgroup_create_dir(struct cgroup *cgrp, struct dentry *dentry,* @cft: the control file in question * * returns cft->mode if ->mode is not 0 -* returns 0644 if it has both a read and a write handler -* returns 0444 if it has only a read handler -* returns 0200 if it has only a write hander +* returns S_IRUGO|S_IWUSR if it has both a read and a write handler +* returns S_IRUGO if it has only a read handler +* returns S_IWUSR if it has only a write hander */ -static int cgroup_file_mode (const struct cftype *cft) +static mode_t cgroup_file_mode (const struct cftype *cft) { -int mode =0 ; +mode_t mode =0 ;if (cft->mode)return cft->mode;if (cft->read || cft->read_u64 || cft->read_s64 || cft->read_map || cft->read_seq_string) - mode |=0444 ; + mode |=S_IRUGO ;if (cft->write || cft->write_u64 || cft->write_s64 || cft->write_string || cft->trigger) - mode |=0200 ; + mode |=S_IWUSR ;return mode; }@@ -1784,7 +1784,7 @@ int cgroup_add_file(struct cgroup *cgrp,struct dentry *dir = cgrp->dentry;struct dentry *dentry;int error; -int mode; +mode_t mode;char name[MAX_CGROUP_TYPE_NAMELEN +MAX_CFTYPE_NAME +2 ] = {0 };if (subsys && !test_bit (ROOT_NOPREFIX , &cgrp->root->flags)) {@@ -2378,7 +2378,7 @@ static struct cftype files[] = { .write_u64 = cgroup_tasks_write, .release = cgroup_tasks_release, .private = FILE_TASKLIST, - .mode = 0644, + .mode = S_IRUGO | S_IWUSR, }, {@@ -2479,7 +2479,7 @@ static void cgroup_unlock_hierarchy(struct cgroupfs_root *root)* Must be called with the mutex on the parent inode held */ static long cgroup_create (struct cgroup *parent,struct dentry *dentry, -int mode) +mode_t mode) {struct cgroup *cgrp;struct cgroupfs_root *root = parent->root;kernel/cpuset.c +1
-1@@ -1678,7 +1678,7 @@ static struct cftype files[] = { .read_u64 = cpuset_read_u64, .write_u64 = cpuset_write_u64, .private = FILE_MEMORY_PRESSURE, - .mode = 0444, + .mode = S_IRUGO, }, {Signature · 1 line
1.5.4.rc3
Re: [PATCH] cgroups: show correct file mode, fix
Quoted 10 lines · KAMEZAWA Hiroyuki
Quoted 4 lines · On Wed, 04 Mar 2009 09:52:57 +0800 Li Zefan <[email protected]> wrote:
- 'mode' should have type
mode_t
- use S_IRUGO/S_IWUSR instead of 0444/0200Signed-off-by Li Zefan <[email protected]>Thank you for quick work. I'll write memcg part on this.
Ah, you don't need to do so. All the files in memcg will show their correct file mode, which is what this patch does.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH] cgroups: show correct file mode, fix
Quoted 7 lines · On Wed, 04 Mar 2009 09:59:53 +0800 Li Zefan…
Quoted 6 lines · KAMEZAWA Hiroyuki
Quoted 3 lines · On Wed, 04 Mar 2009 09:52:57 +0800 Li Zefan…
- 'mode' should have type
mode_t
- use S_IRUGO/S_IWUSR instead of 0444/0200
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Li Zefan <[email protected]>Thank you for quick work. I'll write memcg part on this.
Ah, you don't need to do so. All the files in memcg will show their correct file mode, which is what this patch does.
I see.
Thanks,
-Kame
Re: [PATCH] cgroups: show correct file mode, fix
In reply to Li ZefanQuoted 7 lines · On Wed, 04 Mar 2009 09:59:53 +0800 Li Zefan <[email protected]> wrote:
Quoted 6 lines · KAMEZAWA Hiroyuki
Quoted 3 lines · On Wed, 04 Mar 2009 09:52:57 +0800 Li Zefan <[email protected]> wrote:
- 'mode' should have type
mode_t
- use S_IRUGO/S_IWUSR instead of 0444/0200
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Li Zefan <[email protected]>Thank you for quick work. I'll write memcg part on this.
Ah, you don't need to do so. All the files in memcg will show their correct file mode, which is what this patch does.
I see.
Thanks,
-Kame
A message that is not in the archive (sent off-list or not yet received): 20090304105403.23352011.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org
Re: [PATCH] cgroups: show correct file mode, fix
Quoted 10 lines · KAMEZAWA Hiroyuki
Quoted 4 lines · On Wed, 04 Mar 2009 09:52:57 +0800 Li Zefan…
- 'mode' should have type
mode_t
- use S_IRUGO/S_IWUSR instead of 0444/0200Signed-off-by Li Zefan <[email protected]>Thank you for quick work. I'll write memcg part on this.
Ah, you don't need to do so. All the files in memcg will show their correct file mode, which is what this patch does.
A message that is not in the archive (sent off-list or not yet received): 20090303122733.af5ceea9.akpm-de/[email protected]
PATCH 1/1 cgroups: show correct file mode, fix
- 'mode' should have type mode_t
- use S_IRUGO/S_IWUSR instead of 0444/0200
---
against cgroups-show-correct-file-mode.patch
--- include/linux/cgroup.h | 2 +- kernel/cgroup.c | 24 ++++++++++++------------ kernel/cpuset.c | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-)
include/linux/cgroup.h +1 -1
@@ -262,7 +262,7 @@ struct cftype {* If not 0, file mode is set to this value, otherwise it will * be figured out automatically */ -int mode; +mode_t mode;/* * If non-zero, defines the maximum length of string that can
kernel/cgroup.c +12 -12
@@ -1686,7 +1686,7 @@ static struct inode_operations cgroup_dir_inode_operations = { .rename = cgroup_rename, }; -static int cgroup_create_file (struct dentry *dentry,int mode, +static int cgroup_create_file (struct dentry *dentry,mode_t mode,struct super_block *sb) {static struct dentry_operations cgroup_dops = {
@@ -1732,7 +1732,7 @@ static int cgroup_create_file(struct dentry *dentry, int mode,* @mode: mode to set on new directory. */ static int cgroup_create_dir (struct cgroup *cgrp,struct dentry *dentry, -int mode) +mode_t mode) {struct dentry *parent;int error =0 ;
@@ -1755,24 +1755,24 @@ static int cgroup_create_dir(struct cgroup *cgrp, struct dentry *dentry,* @cft: the control file in question * * returns cft->mode if ->mode is not 0 -* returns 0644 if it has both a read and a write handler -* returns 0444 if it has only a read handler -* returns 0200 if it has only a write hander +* returns S_IRUGO|S_IWUSR if it has both a read and a write handler +* returns S_IRUGO if it has only a read handler +* returns S_IWUSR if it has only a write hander */ -static int cgroup_file_mode (const struct cftype *cft) +static mode_t cgroup_file_mode (const struct cftype *cft) { -int mode =0 ; +mode_t mode =0 ;if (cft->mode)return cft->mode;if (cft->read || cft->read_u64 || cft->read_s64 || cft->read_map || cft->read_seq_string) - mode |=0444 ; + mode |=S_IRUGO ;if (cft->write || cft->write_u64 || cft->write_s64 || cft->write_string || cft->trigger) - mode |=0200 ; + mode |=S_IWUSR ;return mode; }
@@ -1784,7 +1784,7 @@ int cgroup_add_file(struct cgroup *cgrp,struct dentry *dir = cgrp->dentry;struct dentry *dentry;int error; -int mode; +mode_t mode;char name[MAX_CGROUP_TYPE_NAMELEN +MAX_CFTYPE_NAME +2 ] = {0 };if (subsys && !test_bit (ROOT_NOPREFIX , &cgrp->root->flags)) {
@@ -2378,7 +2378,7 @@ static struct cftype files[] = { .write_u64 = cgroup_tasks_write, .release = cgroup_tasks_release, .private = FILE_TASKLIST, - .mode = 0644, + .mode = S_IRUGO | S_IWUSR, }, {
@@ -2479,7 +2479,7 @@ static void cgroup_unlock_hierarchy(struct cgroupfs_root *root)* Must be called with the mutex on the parent inode held */ static long cgroup_create (struct cgroup *parent,struct dentry *dentry, -int mode) +mode_t mode) {struct cgroup *cgrp;struct cgroupfs_root *root = parent->root;
kernel/cpuset.c +1 -1
@@ -1678,7 +1678,7 @@ static struct cftype files[] = { .read_u64 = cpuset_read_u64, .write_u64 = cpuset_write_u64, .private = FILE_MEMORY_PRESSURE, - .mode = 0444, + .mode = S_IRUGO, }, {
Signature · 1 line
1.5.4.rc3