linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] #define rwxr_xr_x 0755
@ 2006-07-27 20:59 Alexey Dobriyan
  2006-07-27 22:23 ` Björn Steinbrink
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Alexey Dobriyan @ 2006-07-27 20:59 UTC (permalink / raw)
  To: linux-kernel

Every time I try to decipher S_I* combos I cry in pain. Often I just
refer to include/linux/stat.h defines to find out what mode it is
because numbers are actually quickier to understand.

Compare and contrast:

	0644 vs S_IRUGO|S_IWUSR vs rw_r__r__

I'd say #2 really sucks.

Another rationale: "ls -l" is used pretty often and people are used to
its output so new defines would be very easy to understand.

Target usage sysfs attributes modes and similar stuff. Driver authors
would just write

	.attr = {.name = "state", .mode = r__r__r__ },

and be done with it.

I'm not sure you want to see

	if (mode & _w__w__w_)

somewhere in generic code, this is debatable, so I'll go with attribute
stuff first.

What people think? Should folks at Moscow call 03 ASAP?

--- a/fs/smbfs/inode.c
+++ b/fs/smbfs/inode.c
@@ -575,10 +575,8 @@ static int smb_fill_super(struct super_b
 		mnt->flags = (oldmnt->file_mode >> 9) | SMB_MOUNT_UID |
 			SMB_MOUNT_GID | SMB_MOUNT_FMODE | SMB_MOUNT_DMODE;
 	} else {
-		mnt->file_mode = S_IRWXU | S_IRGRP | S_IXGRP |
-				S_IROTH | S_IXOTH | S_IFREG;
-		mnt->dir_mode = S_IRWXU | S_IRGRP | S_IXGRP |
-				S_IROTH | S_IXOTH | S_IFDIR;
+		mnt->file_mode = rwxr_xr_x | S_IFREG;
+		mnt->dir_mode = rwxr_xr_x | S_IFDIR;
 		if (parse_options(mnt, raw_data))
 			goto out_bad_option;
 	}
--- a/include/linux/stat.h
+++ b/include/linux/stat.h
@@ -29,6 +29,8 @@ #define S_ISBLK(m)	(((m) & S_IFMT) == S_
 #define S_ISFIFO(m)	(((m) & S_IFMT) == S_IFIFO)
 #define S_ISSOCK(m)	(((m) & S_IFMT) == S_IFSOCK)
 
+#define rwxr_xr_x 0755
+
 #define S_IRWXU 00700
 #define S_IRUSR 00400
 #define S_IWUSR 00200


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

* Re: [RFC] #define rwxr_xr_x 0755
  2006-07-27 20:59 [RFC] #define rwxr_xr_x 0755 Alexey Dobriyan
@ 2006-07-27 22:23 ` Björn Steinbrink
  2006-07-28 16:34   ` Handle X
  2006-07-28  3:22 ` Josef Sipek
  2006-07-29 13:58 ` Johannes Weiner
  2 siblings, 1 reply; 9+ messages in thread
From: Björn Steinbrink @ 2006-07-27 22:23 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: linux-kernel

On 2006.07.28 00:59:11 +0400, Alexey Dobriyan wrote:
> Every time I try to decipher S_I* combos I cry in pain. Often I just
> refer to include/linux/stat.h defines to find out what mode it is
> because numbers are actually quickier to understand.
> 
> Compare and contrast:
> 
> 	0644 vs S_IRUGO|S_IWUSR vs rw_r__r__
> 
> I'd say #2 really sucks.

IMHO #3 sucks more, it's not as easy to spot when glossing over the
code, the underscores make it quite ugly (think _r________) and it's
less "greppable". If I know that there's something that sets S_ISUID, I
can easily search for that, compare that to [_cpdbl]{1}[r_]{1}[w_]{1}s...

And those S_I* things aren't that hard to parse actually. It starts with
the affected modes and then the "target user". So your example reads
like:

S_IRUGO | S_IWUSR:
Read - User Group Other | Write - User

It took me some time to realize that, but once you got it, it's easy.

Björn

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

* Re: [RFC] #define rwxr_xr_x 0755
  2006-07-27 20:59 [RFC] #define rwxr_xr_x 0755 Alexey Dobriyan
  2006-07-27 22:23 ` Björn Steinbrink
@ 2006-07-28  3:22 ` Josef Sipek
  2006-07-29 13:58 ` Johannes Weiner
  2 siblings, 0 replies; 9+ messages in thread
From: Josef Sipek @ 2006-07-28  3:22 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: linux-kernel

On Fri, Jul 28, 2006 at 12:59:11AM +0400, Alexey Dobriyan wrote:
> Every time I try to decipher S_I* combos I cry in pain. Often I just
> refer to include/linux/stat.h defines to find out what mode it is
> because numbers are actually quickier to understand.
> 
> Compare and contrast:
> 
> 	0644 vs S_IRUGO|S_IWUSR vs rw_r__r__
> 
> I'd say #2 really sucks.
 
Yep. I like the idea, but I think some kind of prefix is in order.

Josef Sipek.

-- 
"Memory is like gasoline. You use it up when you are running. Of course you
get it all back when you reboot..."; Actual explanation obtained from the
Micro$oft help desk. 

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

* Re: [RFC] #define rwxr_xr_x 0755
  2006-07-27 22:23 ` Björn Steinbrink
@ 2006-07-28 16:34   ` Handle X
  2006-07-28 16:48     ` Josef Sipek
  0 siblings, 1 reply; 9+ messages in thread
From: Handle X @ 2006-07-28 16:34 UTC (permalink / raw)
  To: Björn Steinbrink, Alexey Dobriyan, linux-kernel

On 7/27/06, Björn Steinbrink <B.Steinbrink@gmx.de> wrote:
> On 2006.07.28 00:59:11 +0400, Alexey Dobriyan wrote:
> > Every time I try to decipher S_I* combos I cry in pain. Often I just
> > refer to include/linux/stat.h defines to find out what mode it is
> > because numbers are actually quickier to understand.
> >
> > Compare and contrast:
> >
> >       0644 vs S_IRUGO|S_IWUSR vs rw_r__r__
> >
> > I'd say #2 really sucks.
>
> IMHO #3 sucks more, it's not as easy to spot when glossing over the
> code, the underscores make it quite ugly (think _r________) and it's
> less "greppable". If I know that there's something that sets S_ISUID, I
> can easily search for that, compare that to [_cpdbl]{1}[r_]{1}[w_]{1}s...
I agree with Steinbink. But how about having macros like,
S_I0700, S_I0070, S_I6444 ..etc. They combine visual appeal of octals,
easy to grep, easy to decipher ...etc.

Regards,
Om.

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

* Re: [RFC] #define rwxr_xr_x 0755
  2006-07-28 16:34   ` Handle X
@ 2006-07-28 16:48     ` Josef Sipek
  2006-07-29  1:43       ` Dmitry Torokhov
  0 siblings, 1 reply; 9+ messages in thread
From: Josef Sipek @ 2006-07-28 16:48 UTC (permalink / raw)
  To: Handle X; +Cc: Björn Steinbrink, Alexey Dobriyan, linux-kernel

On Fri, Jul 28, 2006 at 09:34:11AM -0700, Handle X wrote:
> On 7/27/06, Björn Steinbrink <B.Steinbrink@gmx.de> wrote:
> >On 2006.07.28 00:59:11 +0400, Alexey Dobriyan wrote:
> >> Every time I try to decipher S_I* combos I cry in pain. Often I just
> >> refer to include/linux/stat.h defines to find out what mode it is
> >> because numbers are actually quickier to understand.
> >>
> >> Compare and contrast:
> >>
> >>       0644 vs S_IRUGO|S_IWUSR vs rw_r__r__
> >>
> >> I'd say #2 really sucks.
> >
> >IMHO #3 sucks more, it's not as easy to spot when glossing over the
> >code, the underscores make it quite ugly (think _r________) and it's
> >less "greppable". If I know that there's something that sets S_ISUID, I
> >can easily search for that, compare that to [_cpdbl]{1}[r_]{1}[w_]{1}s...
> I agree with Steinbink. But how about having macros like,
> S_I0700, S_I0070, S_I6444 ..etc. They combine visual appeal of octals,
> easy to grep, easy to decipher ...etc.

Even better!

Josef "Jeff" Sipek.

-- 
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like
that.
		- Linus Torvalds

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

* Re: [RFC] #define rwxr_xr_x 0755
  2006-07-28 16:48     ` Josef Sipek
@ 2006-07-29  1:43       ` Dmitry Torokhov
  2006-07-29  7:59         ` Jan Engelhardt
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Torokhov @ 2006-07-29  1:43 UTC (permalink / raw)
  To: Josef Sipek
  Cc: Handle X, Björn Steinbrink, Alexey Dobriyan, linux-kernel

On Friday 28 July 2006 12:48, Josef Sipek wrote:
> On Fri, Jul 28, 2006 at 09:34:11AM -0700, Handle X wrote:
> > On 7/27/06, Björn Steinbrink <B.Steinbrink@gmx.de> wrote:
> > >On 2006.07.28 00:59:11 +0400, Alexey Dobriyan wrote:
> > >> Every time I try to decipher S_I* combos I cry in pain. Often I just
> > >> refer to include/linux/stat.h defines to find out what mode it is
> > >> because numbers are actually quickier to understand.
> > >>
> > >> Compare and contrast:
> > >>
> > >>       0644 vs S_IRUGO|S_IWUSR vs rw_r__r__
> > >>
> > >> I'd say #2 really sucks.
> > >
> > >IMHO #3 sucks more, it's not as easy to spot when glossing over the
> > >code, the underscores make it quite ugly (think _r________) and it's
> > >less "greppable". If I know that there's something that sets S_ISUID, I
> > >can easily search for that, compare that to [_cpdbl]{1}[r_]{1}[w_]{1}s...
> > I agree with Steinbink. But how about having macros like,
> > S_I0700, S_I0070, S_I6444 ..etc. They combine visual appeal of octals,
> > easy to grep, easy to decipher ...etc.
> 
> Even better!
> 

So now tell me how is S_I0644 better than 0644? S_IRUGO et al at least hide
implementation details.

-- 
Dmitry

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

* Re: [RFC] #define rwxr_xr_x 0755
  2006-07-29  1:43       ` Dmitry Torokhov
@ 2006-07-29  7:59         ` Jan Engelhardt
  0 siblings, 0 replies; 9+ messages in thread
From: Jan Engelhardt @ 2006-07-29  7:59 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Josef Sipek, Handle X, Björn Steinbrink, Alexey Dobriyan,
	linux-kernel

>> > >>       0644 vs S_IRUGO|S_IWUSR vs rw_r__r__
>> > >>
>> > >> I'd say #2 really sucks.
>> > >
>> > >IMHO #3 sucks more, it's not as easy to spot when glossing over the
>> > >code, the underscores make it quite ugly (think _r________) and it's
>> 
>> Even better!
>
>So now tell me how is S_I0644 better than 0644? S_IRUGO et al at least hide
>implementation details.

+1. 


Jan Engelhardt
-- 

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

* Re: [RFC] #define rwxr_xr_x 0755
  2006-07-27 20:59 [RFC] #define rwxr_xr_x 0755 Alexey Dobriyan
  2006-07-27 22:23 ` Björn Steinbrink
  2006-07-28  3:22 ` Josef Sipek
@ 2006-07-29 13:58 ` Johannes Weiner
  2 siblings, 0 replies; 9+ messages in thread
From: Johannes Weiner @ 2006-07-29 13:58 UTC (permalink / raw)
  To: linux-kernel

Hi,

On Fri, Jul 28, 2006 at 12:59:11AM +0400, Alexey Dobriyan wrote:
> Every time I try to decipher S_I* combos I cry in pain. Often I just
> refer to include/linux/stat.h defines to find out what mode it is
> because numbers are actually quickier to understand.
> 
> Compare and contrast:
> 
> 	0644 vs S_IRUGO|S_IWUSR vs rw_r__r__
> 
> I'd say #2 really sucks.

I understood the octal notation at once. #2 took a second, I'd prefer
writing it  S_IRUGO | S_IWUSR  which makes it slightly more obvious.
#3 is even better than #2 but still sucks. What against octals?

> What people think? Should folks at Moscow call 03 ASAP?
> 
> --- a/fs/smbfs/inode.c
> +++ b/fs/smbfs/inode.c
> @@ -575,10 +575,8 @@ static int smb_fill_super(struct super_b
>  		mnt->flags = (oldmnt->file_mode >> 9) | SMB_MOUNT_UID |
>  			SMB_MOUNT_GID | SMB_MOUNT_FMODE | SMB_MOUNT_DMODE;
>  	} else {
> -		mnt->file_mode = S_IRWXU | S_IRGRP | S_IXGRP |
> -				S_IROTH | S_IXOTH | S_IFREG;
> -		mnt->dir_mode = S_IRWXU | S_IRGRP | S_IXGRP |
> -				S_IROTH | S_IXOTH | S_IFDIR;
> +		mnt->file_mode = rwxr_xr_x | S_IFREG;

0755 | S_IFREG is more readable I think.

> +		mnt->dir_mode = rwxr_xr_x | S_IFDIR;

0755 | S_IFDIR ; same here

Hannes

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

* Re: [RFC] #define rwxr_xr_x 0755
@ 2006-07-28  4:54 Albert Cahalan
  0 siblings, 0 replies; 9+ messages in thread
From: Albert Cahalan @ 2006-07-28  4:54 UTC (permalink / raw)
  To: adobriyan, linux-kernel, jsipek, B.Steinbrink

Alexey Dobriyan writes:

> Every time I try to decipher S_I* combos I cry in pain. Often I just
> refer to include/linux/stat.h defines to find out what mode it is
> because numbers are actually quickier to understand.
>
> Compare and contrast:
>
>       0644 vs S_IRUGO|S_IWUSR vs rw_r__r__
> I'd say #2 really sucks.

Damn right.

I'd be very happy to remove (or #ifndef __KERNEL__ as needed) the
dreadful S_FOO macros. I'd be much happier with plain old octal,
as is normally used for both syscalls and the chmod command.

(the non-octal nonsense was probably invented for porting
software to non-UNIX systems)

If you like the ls way though, you might as well add the file
type notation:  drwxr_xr_x, _r__r__r__, _rw_r__r__, etc.
That's not too bad. Plain octal is best though.

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

end of thread, other threads:[~2006-07-29 13:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-27 20:59 [RFC] #define rwxr_xr_x 0755 Alexey Dobriyan
2006-07-27 22:23 ` Björn Steinbrink
2006-07-28 16:34   ` Handle X
2006-07-28 16:48     ` Josef Sipek
2006-07-29  1:43       ` Dmitry Torokhov
2006-07-29  7:59         ` Jan Engelhardt
2006-07-28  3:22 ` Josef Sipek
2006-07-29 13:58 ` Johannes Weiner
2006-07-28  4:54 Albert Cahalan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).