Kernel Newbies archive on lore.kernel.org
 help / Atom feed
* why are some stat.h "S_*" perm macros not exported via uapi?
@ 2018-12-31 19:53 Robert P. J. Day
  2019-01-01  0:44 ` valdis.kletnieks
  0 siblings, 1 reply; 3+ messages in thread
From: Robert P. J. Day @ 2018-12-31 19:53 UTC (permalink / raw)
  To: Kernel Newbies


  more pedantry ... just noticed this snippet in include/linux/stat.h:

...
  #include <uapi/linux/stat.h>

  #define S_IRWXUGO       (S_IRWXU|S_IRWXG|S_IRWXO)
  #define S_IALLUGO       (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)
  #define S_IRUGO         (S_IRUSR|S_IRGRP|S_IROTH)
  #define S_IWUGO         (S_IWUSR|S_IWGRP|S_IWOTH)
  #define S_IXUGO         (S_IXUSR|S_IXGRP|S_IXOTH)
...

given that all of the other S_ perm macros are exported in
include/uapi/linux/stat.h, as in:

  #define S_IRWXU 00700
  #define S_IRUSR 00400
  #define S_IWUSR 00200
  #define S_IXUSR 00100

  #define S_IRWXG 00070
  #define S_IRGRP 00040
  #define S_IWGRP 00020
  #define S_IXGRP 00010

and so on, is there a reason those few combination perm macros are not
exported as well? or is the userspace stat.h so well-defined at this
point that cosmetic changes like this are frowned upon?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                  http://crashcourse.ca/dokuwiki

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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

* Re: why are some stat.h "S_*" perm macros not exported via uapi?
  2018-12-31 19:53 why are some stat.h "S_*" perm macros not exported via uapi? Robert P. J. Day
@ 2019-01-01  0:44 ` valdis.kletnieks
  2019-01-01  9:41   ` Robert P. J. Day
  0 siblings, 1 reply; 3+ messages in thread
From: valdis.kletnieks @ 2019-01-01  0:44 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: Kernel Newbies

On Mon, 31 Dec 2018 14:53:30 -0500, "Robert P. J. Day" said:

>   #define S_IRWXUGO       (S_IRWXU|S_IRWXG|S_IRWXO)
>   #define S_IALLUGO       (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)
>   #define S_IRUGO         (S_IRUSR|S_IRGRP|S_IROTH)
>   #define S_IWUGO         (S_IWUSR|S_IWGRP|S_IWOTH)
>   #define S_IXUGO         (S_IXUSR|S_IXGRP|S_IXOTH)

Can you give an actual non-contrived example of code where one of these would
be preferable to inline coding the mask? And do you plan to include all the
various combos? And why should that be done in the uapi headers, rather than
glibc/musl/other_c_lib providing it?

I'll go out on a limb and say that most programmers would have an easier time
mentally parsing the octal constant 0660 than

((S_IRUGO | S_IWUGO) & ~(S_IXUSR | S_IXGRP | S_IRWXO ))

(Damn, that's ugly.  The sort of thing where I've been hacking C code since
1984, and I'm *still* looking at it and going "Did I get that right, or did I
just screw the pooch?"....

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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

* Re: why are some stat.h "S_*" perm macros not exported via uapi?
  2019-01-01  0:44 ` valdis.kletnieks
@ 2019-01-01  9:41   ` Robert P. J. Day
  0 siblings, 0 replies; 3+ messages in thread
From: Robert P. J. Day @ 2019-01-01  9:41 UTC (permalink / raw)
  To: valdis.kletnieks; +Cc: Kernel Newbies

On Mon, 31 Dec 2018, valdis.kletnieks@vt.edu wrote:

> On Mon, 31 Dec 2018 14:53:30 -0500, "Robert P. J. Day" said:
>
> >   #define S_IRWXUGO       (S_IRWXU|S_IRWXG|S_IRWXO)
> >   #define S_IALLUGO       (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)
> >   #define S_IRUGO         (S_IRUSR|S_IRGRP|S_IROTH)
> >   #define S_IWUGO         (S_IWUSR|S_IWGRP|S_IWOTH)
> >   #define S_IXUGO         (S_IXUSR|S_IXGRP|S_IXOTH)
>
> Can you give an actual non-contrived example of code where one of
> these would be preferable to inline coding the mask? And do you plan
> to include all the various combos? And why should that be done in
> the uapi headers, rather than glibc/musl/other_c_lib providing it?

... snip ...

  i am not *defending* the above macros, simply pointing out that,
unlike all the other simpler macros that *are* exported via uapi,
these are left all by their lonesome in kernel space. i'm just
wondering if there's a reason for that.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                  http://crashcourse.ca/dokuwiki

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-31 19:53 why are some stat.h "S_*" perm macros not exported via uapi? Robert P. J. Day
2019-01-01  0:44 ` valdis.kletnieks
2019-01-01  9:41   ` Robert P. J. Day

Kernel Newbies archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kernelnewbies/0 kernelnewbies/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernelnewbies kernelnewbies/ https://lore.kernel.org/kernelnewbies \
		kernelnewbies@kernelnewbies.org kernelnewbies@archiver.kernel.org
	public-inbox-index kernelnewbies


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernelnewbies.kernelnewbies


AGPL code for this site: git clone https://public-inbox.org/ public-inbox