All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] staging: lustre: libcfs: use octal permissions
@ 2017-01-24 17:40 Ernestas Kulik
  2017-01-24 17:40 ` [PATCH 2/2] staging: lustre: llite: " Ernestas Kulik
  2017-01-24 22:22   ` [lustre-devel] " Dilger, Andreas
  0 siblings, 2 replies; 6+ messages in thread
From: Ernestas Kulik @ 2017-01-24 17:40 UTC (permalink / raw)
  To: oleg.drokin
  Cc: andreas.dilger, jsimmons, gregkh, lustre-devel, devel, linux-kernel

Using octal permissions instead of symbolic ones is preferred.

Signed-off-by: Ernestas Kulik <ernestas.kulik@gmail.com>
---
 drivers/staging/lustre/lnet/libcfs/module.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c
index 161e04226521..c388550c2d10 100644
--- a/drivers/staging/lustre/lnet/libcfs/module.c
+++ b/drivers/staging/lustre/lnet/libcfs/module.c
@@ -488,10 +488,10 @@ static const struct file_operations lnet_debugfs_file_operations_wo = {
 
 static const struct file_operations *lnet_debugfs_fops_select(umode_t mode)
 {
-	if (!(mode & S_IWUGO))
+	if (!(mode & 0222))
 		return &lnet_debugfs_file_operations_ro;
 
-	if (!(mode & S_IRUGO))
+	if (!(mode & 0444))
 		return &lnet_debugfs_file_operations_wo;
 
 	return &lnet_debugfs_file_operations_rw;
-- 
2.11.0

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

* [PATCH 2/2] staging: lustre: llite: use octal permissions
  2017-01-24 17:40 [PATCH 1/2] staging: lustre: libcfs: use octal permissions Ernestas Kulik
@ 2017-01-24 17:40 ` Ernestas Kulik
  2017-01-24 22:22   ` [lustre-devel] " Dilger, Andreas
  1 sibling, 0 replies; 6+ messages in thread
From: Ernestas Kulik @ 2017-01-24 17:40 UTC (permalink / raw)
  To: oleg.drokin
  Cc: andreas.dilger, jsimmons, gregkh, lustre-devel, devel, linux-kernel

Using octal permissions instead of symbolic ones is preferred.

Signed-off-by: Ernestas Kulik <ernestas.kulik@gmail.com>
---
 drivers/staging/lustre/lustre/llite/dir.c       | 2 +-
 drivers/staging/lustre/lustre/llite/file.c      | 2 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c | 4 ++--
 drivers/staging/lustre/lustre/llite/namei.c     | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c
index ea5d247a3f70..526fea266926 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -432,7 +432,7 @@ static int ll_dir_setdirstripe(struct inode *parent, struct lmv_user_md *lump,
 
 	if (!IS_POSIXACL(parent) || !exp_connect_umask(ll_i2mdexp(parent)))
 		mode &= ~current_umask();
-	mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR;
+	mode = (mode & (0777 | S_ISVTX)) | S_IFDIR;
 	op_data = ll_prep_md_op_data(NULL, parent, NULL, dirname,
 				     strlen(dirname), mode, LUSTRE_OPC_MKDIR,
 				     lump);
diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
index d93f06abd13c..a17118876555 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -1883,7 +1883,7 @@ static int ll_hsm_import(struct inode *inode, struct file *file,
 		goto free_hss;
 	}
 
-	attr->ia_mode = hui->hui_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
+	attr->ia_mode = hui->hui_mode & 0777;
 	attr->ia_mode |= S_IFREG;
 	attr->ia_uid = make_kuid(&init_user_ns, hui->hui_uid);
 	attr->ia_gid = make_kgid(&init_user_ns, hui->hui_gid);
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 25f5aed97f63..9cb4909e3b86 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -1599,7 +1599,7 @@ int ll_setattr(struct dentry *de, struct iattr *attr)
 	if (((attr->ia_valid & (ATTR_MODE | ATTR_FORCE | ATTR_SIZE)) ==
 			       (ATTR_SIZE | ATTR_MODE)) &&
 	    (((mode & S_ISUID) && !(attr->ia_mode & S_ISUID)) ||
-	     (((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) &&
+	     (((mode & (S_ISGID | 0010)) == (S_ISGID | 0010)) &&
 	      !(attr->ia_mode & S_ISGID))))
 		attr->ia_valid |= ATTR_FORCE;
 
@@ -1610,7 +1610,7 @@ int ll_setattr(struct dentry *de, struct iattr *attr)
 		attr->ia_valid |= ATTR_KILL_SUID;
 
 	if ((attr->ia_valid & ATTR_MODE) &&
-	    ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) &&
+	    ((mode & (S_ISGID | 0010)) == (S_ISGID | 0010)) &&
 	    !(attr->ia_mode & S_ISGID) &&
 	    !(attr->ia_valid & ATTR_KILL_SGID))
 		attr->ia_valid |= ATTR_KILL_SGID;
diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index a8f4e7fb0a46..f925656f11c9 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -1041,7 +1041,7 @@ static int ll_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 
 	if (!IS_POSIXACL(dir) || !exp_connect_umask(ll_i2mdexp(dir)))
 		mode &= ~current_umask();
-	mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR;
+	mode = (mode & (0777 | S_ISVTX)) | S_IFDIR;
 
 	err = ll_new_node(dir, dentry, NULL, mode, 0, LUSTRE_OPC_MKDIR);
 	if (!err)
@@ -1089,7 +1089,7 @@ static int ll_symlink(struct inode *dir, struct dentry *dentry,
 	CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, dir="DFID"(%p),target=%.*s\n",
 	       dentry, PFID(ll_inode2fid(dir)), dir, 3000, oldname);
 
-	err = ll_new_node(dir, dentry, oldname, S_IFLNK | S_IRWXUGO,
+	err = ll_new_node(dir, dentry, oldname, S_IFLNK | 0777,
 			  0, LUSTRE_OPC_SYMLINK);
 
 	if (!err)
-- 
2.11.0

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

* Re: [PATCH 1/2] staging: lustre: libcfs: use octal permissions
  2017-01-24 17:40 [PATCH 1/2] staging: lustre: libcfs: use octal permissions Ernestas Kulik
@ 2017-01-24 22:22   ` Dilger, Andreas
  2017-01-24 22:22   ` [lustre-devel] " Dilger, Andreas
  1 sibling, 0 replies; 6+ messages in thread
From: Dilger, Andreas @ 2017-01-24 22:22 UTC (permalink / raw)
  To: Ernestas Kulik
  Cc: Drokin, Oleg, James Simmons, Greg Kroah-Hartman, lustre-devel,
	devel, linux-kernel

On Jan 24, 2017, at 09:40, Ernestas Kulik <ernestas.kulik@gmail.com> wrote:
> 
> Using octal permissions instead of symbolic ones is preferred.

Typically the reverse is true - using symbolic constants is preferred over numeric ones.
Where does this recommendation come from?

Cheers, Andreas

> Signed-off-by: Ernestas Kulik <ernestas.kulik@gmail.com>
> ---
> drivers/staging/lustre/lnet/libcfs/module.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c
> index 161e04226521..c388550c2d10 100644
> --- a/drivers/staging/lustre/lnet/libcfs/module.c
> +++ b/drivers/staging/lustre/lnet/libcfs/module.c
> @@ -488,10 +488,10 @@ static const struct file_operations lnet_debugfs_file_operations_wo = {
> 
> static const struct file_operations *lnet_debugfs_fops_select(umode_t mode)
> {
> -	if (!(mode & S_IWUGO))
> +	if (!(mode & 0222))
> 		return &lnet_debugfs_file_operations_ro;
> 
> -	if (!(mode & S_IRUGO))
> +	if (!(mode & 0444))
> 		return &lnet_debugfs_file_operations_wo;
> 
> 	return &lnet_debugfs_file_operations_rw;
> -- 
> 2.11.0
> 

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

* [lustre-devel] [PATCH 1/2] staging: lustre: libcfs: use octal permissions
@ 2017-01-24 22:22   ` Dilger, Andreas
  0 siblings, 0 replies; 6+ messages in thread
From: Dilger, Andreas @ 2017-01-24 22:22 UTC (permalink / raw)
  To: Ernestas Kulik
  Cc: Drokin, Oleg, James Simmons, Greg Kroah-Hartman, lustre-devel,
	devel, linux-kernel

On Jan 24, 2017, at 09:40, Ernestas Kulik <ernestas.kulik@gmail.com> wrote:
> 
> Using octal permissions instead of symbolic ones is preferred.

Typically the reverse is true - using symbolic constants is preferred over numeric ones.
Where does this recommendation come from?

Cheers, Andreas

> Signed-off-by: Ernestas Kulik <ernestas.kulik@gmail.com>
> ---
> drivers/staging/lustre/lnet/libcfs/module.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c
> index 161e04226521..c388550c2d10 100644
> --- a/drivers/staging/lustre/lnet/libcfs/module.c
> +++ b/drivers/staging/lustre/lnet/libcfs/module.c
> @@ -488,10 +488,10 @@ static const struct file_operations lnet_debugfs_file_operations_wo = {
> 
> static const struct file_operations *lnet_debugfs_fops_select(umode_t mode)
> {
> -	if (!(mode & S_IWUGO))
> +	if (!(mode & 0222))
> 		return &lnet_debugfs_file_operations_ro;
> 
> -	if (!(mode & S_IRUGO))
> +	if (!(mode & 0444))
> 		return &lnet_debugfs_file_operations_wo;
> 
> 	return &lnet_debugfs_file_operations_rw;
> -- 
> 2.11.0
> 

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

* Re: [PATCH 1/2] staging: lustre: libcfs: use octal permissions
  2017-01-24 22:22   ` [lustre-devel] " Dilger, Andreas
@ 2017-01-25  2:23     ` Joe Perches
  -1 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2017-01-25  2:23 UTC (permalink / raw)
  To: Dilger, Andreas, Ernestas Kulik
  Cc: Drokin, Oleg, James Simmons, Greg Kroah-Hartman, lustre-devel,
	devel, linux-kernel

On Tue, 2017-01-24 at 22:22 +0000, Dilger, Andreas wrote:
> On Jan 24, 2017, at 09:40, Ernestas Kulik <ernestas.kulik@gmail.com> wrote:
> > 
> > Using octal permissions instead of symbolic ones is preferred.
> 
> Typically the reverse is true - using symbolic constants is preferred over numeric ones.
> Where does this recommendation come from?

http://lkml.kernel.org/r/CA+55aFw5v23T-zvDZp-MmD_EYxF8WbafwwB59934FV7g21uMGQ@mail.gmail.com

which is:

https://marc.info/?l=linux-arm-kernel&m=147017161402213&w=2

Subject:    Please don't replace numeric parameter like 0444 with macro
From:       Linus Torvalds <torvalds () linux-foundation ! org>
Date:       2016-08-02 20:58:29

[ So I answered similarly to another patch, but I'll just re-iterate
and change the subject line so that it stands out a bit from the
millions of actual patches ]

On Tue, Aug 2, 2016 at 1:42 PM, Pavel Machek <pavel@ucw.cz> wrote:
>
> Everyone knows what 0644 is, but noone can read S_IRUSR | S_IWUSR |
> S_IRCRP | S_IROTH (*). Please don't do this.

Absolutely. It's *much* easier to parse and understand the octal
numbers, while the symbolic macro names are just random line noise and
hard as hell to understand. You really have to think about it.

So we should rather go the other way: convert existing bad symbolic
permission bit macro use to just use the octal numbers.

The symbolic names are good for the *other* bits (ie sticky bit, and
the inode mode _type_ numbers etc), but for the permission bits, the
symbolic names are just insane crap. Nobody sane should ever use them.
Not in the kernel, not in user space.

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

* [lustre-devel] [PATCH 1/2] staging: lustre: libcfs: use octal permissions
@ 2017-01-25  2:23     ` Joe Perches
  0 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2017-01-25  2:23 UTC (permalink / raw)
  To: Dilger, Andreas, Ernestas Kulik
  Cc: Drokin, Oleg, James Simmons, Greg Kroah-Hartman, lustre-devel,
	devel, linux-kernel

On Tue, 2017-01-24 at 22:22 +0000, Dilger, Andreas wrote:
> On Jan 24, 2017, at 09:40, Ernestas Kulik <ernestas.kulik@gmail.com> wrote:
> > 
> > Using octal permissions instead of symbolic ones is preferred.
> 
> Typically the reverse is true - using symbolic constants is preferred over numeric ones.
> Where does this recommendation come from?

http://lkml.kernel.org/r/CA+55aFw5v23T-zvDZp-MmD_EYxF8WbafwwB59934FV7g21uMGQ at mail.gmail.com

which is:

https://marc.info/?l=linux-arm-kernel&m=147017161402213&w=2

Subject:    Please don't replace numeric parameter like 0444 with macro
From:       Linus Torvalds <torvalds () linux-foundation ! org>
Date:       2016-08-02 20:58:29

[ So I answered similarly to another patch, but I'll just re-iterate
and change the subject line so that it stands out a bit from the
millions of actual patches ]

On Tue, Aug 2, 2016 at 1:42 PM, Pavel Machek <pavel@ucw.cz> wrote:
>
> Everyone knows what 0644 is, but noone can read S_IRUSR | S_IWUSR |
> S_IRCRP | S_IROTH (*). Please don't do this.

Absolutely. It's *much* easier to parse and understand the octal
numbers, while the symbolic macro names are just random line noise and
hard as hell to understand. You really have to think about it.

So we should rather go the other way: convert existing bad symbolic
permission bit macro use to just use the octal numbers.

The symbolic names are good for the *other* bits (ie sticky bit, and
the inode mode _type_ numbers etc), but for the permission bits, the
symbolic names are just insane crap. Nobody sane should ever use them.
Not in the kernel, not in user space.

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

end of thread, other threads:[~2017-01-25  2:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-24 17:40 [PATCH 1/2] staging: lustre: libcfs: use octal permissions Ernestas Kulik
2017-01-24 17:40 ` [PATCH 2/2] staging: lustre: llite: " Ernestas Kulik
2017-01-24 22:22 ` [PATCH 1/2] staging: lustre: libcfs: " Dilger, Andreas
2017-01-24 22:22   ` [lustre-devel] " Dilger, Andreas
2017-01-25  2:23   ` Joe Perches
2017-01-25  2:23     ` [lustre-devel] " Joe Perches

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.