Re: why are some stat.h "S_*" perm macros not exported via uapi?

2018-12-31 Thread valdis . kletnieks
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


why are some stat.h "S_*" perm macros not exported via uapi?

2018-12-31 Thread Robert P. J. Day


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

...
  #include 

  #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


stylistically, IS_ERR() versus IS_ERR_VALUE()?

2018-12-31 Thread Robert P. J. Day


  poking around error handling in the kernel, and noticed the
following ... in include/linux/err.h, we have IS_ERR() unsurprisingly
defined in terms of IS_ERR_VALUE():

  #define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= \
(unsigned long)-MAX_ERRNO)

  ... snip ...

  static inline bool __must_check IS_ERR(__force const void *ptr)
  {
return IS_ERR_VALUE((unsigned long)ptr);
  }

fair enough, and the above suggests that it's technically equivalent
to use either one, but if i search under drivers/ for each:

  $ git grep -w IS_ERR -- drivers | wc -l
  14048
  $

  $ git grep -w IS_ERR_VALUE -- drivers | wc -l
  48
  $

so IS_ERR() is pretty clearly the call of choice, and the invocations
of IS_ERR_VALUE() are concentrated in a small number of files -- heck,
15 of those calls are in the single file
drivers/net/ethernet/freescale/ucc_geth.c.

  is there any non-obvious reason for driver code to use the latter?
superficially, they *seem* to be equivalent, but i've been surprised
before.

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


Re: Listing Supported Kernel Parameters?

2018-12-31 Thread Henry C
Thanks for your direction!

Found what I want!

Appreicate!

On Tue, Jan 1, 2019 at 1:01 AM Valentin Vidic 
wrote:

> On Tue, Jan 01, 2019 at 12:48:58AM +0800, Henry C wrote:
> > I just downloaded the source here:
> >
> http://vault.centos.org/7.5.1804/os/Source/SPackages/kernel-3.10.0-862.el7.src.rpm
> >
> > And to my surprise, I don't even see mce as a kernel parameter based on
> the
> > command you suggested:
> > $ grep -r "early_param" . | grep mce
> > $
> >
> > So it seems like "early_param" only covers some kernel parameters but
> not all.
>
> Indeed, mce param seems to be defined using __setup:
>
> __setup("mce", mcheck_enable);
> __setup("nomce", mcheck_disable);
>
> --
> Valentin
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Listing Supported Kernel Parameters?

2018-12-31 Thread Valentin Vidic
On Tue, Jan 01, 2019 at 12:48:58AM +0800, Henry C wrote:
> I just downloaded the source here:
> http://vault.centos.org/7.5.1804/os/Source/SPackages/kernel-3.10.0-862.el7.src.rpm
> 
> And to my surprise, I don't even see mce as a kernel parameter based on the
> command you suggested:
> $ grep -r "early_param" . | grep mce
> $
> 
> So it seems like "early_param" only covers some kernel parameters but not all.

Indeed, mce param seems to be defined using __setup:

__setup("mce", mcheck_enable);
__setup("nomce", mcheck_disable);

-- 
Valentin

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


Re: Listing Supported Kernel Parameters?

2018-12-31 Thread Henry C
Thanks.

I just downloaded the source here:
http://vault.centos.org/7.5.1804/os/Source/SPackages/kernel-3.10.0-862.el7.src.rpm

And to my surprise, I don't even see mce as a kernel parameter based on the
command you suggested:
$ grep -r "early_param" . | grep mce
$

So it seems like "early_param" only covers some kernel parameters but not
all.

Thanks for your suggestion tho!


On Mon, Dec 31, 2018 at 10:37 PM Valentin Vidic 
wrote:

> On Mon, Dec 31, 2018 at 02:27:35PM +0800, Henry C wrote:
> > I am looking for a command (or alike) to list all the supported kernel
> > parameters based on my current kernel.
> >
> > If such command doesn't exist, it would still be great to see a complete
> > list like this one:
> > https://www.kernel.org/doc/html/v4.15/admin-guide/kernel-parameters.html
> >
> > But I can't find anything (reliable) for v3.10.
>
> Not sure if there is a command for that but you can always grep for
> ^early_param in that version and get something like this:
>
> early_param("debug", debug_kernel);
> early_param("quiet", quiet_kernel);
> early_param("loglevel", loglevel);
> ...
>
> --
> Valentin
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Listing Supported Kernel Parameters?

2018-12-31 Thread Valentin Vidic
On Mon, Dec 31, 2018 at 02:27:35PM +0800, Henry C wrote:
> I am looking for a command (or alike) to list all the supported kernel
> parameters based on my current kernel.
> 
> If such command doesn't exist, it would still be great to see a complete
> list like this one:
> https://www.kernel.org/doc/html/v4.15/admin-guide/kernel-parameters.html
> 
> But I can't find anything (reliable) for v3.10.

Not sure if there is a command for that but you can always grep for
^early_param in that version and get something like this:

early_param("debug", debug_kernel);
early_param("quiet", quiet_kernel);
early_param("loglevel", loglevel);
...

-- 
Valentin

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