[PATCH 01/26] Linux: Enhance glibcsyscalls.h to support listing system calls

Florian Weimer fw@deneb.enyo.de
Mon May 11 10:10:13 GMT 2020


* Adhemerval Zanella:

> Now that this would be used as a script issued directly by the
> user, I think it is worth to add a more comprehensible description
> (one that can be used as __doc__). 

Sorry, I mised that before posting the new version:

  <https://sourceware.org/pipermail/libc-alpha/2020-May/113777.html>

> Why not follow other scripts and use argparser as well? Something like:
>
> --
> def main(argv):
>     """Entry point when called as the main program."""
>
>     import argparse
>
>     # Top-level directory of the source tree.
>     topdir = os.path.realpath(os.path.join(
>         os.path.dirname(os.path.realpath(__file__)), *('..',) * 4))
>
>     def get_parser():
>         parser = argparse.ArgumentParser(description=__doc__)
>         subparsers = parser.add_subparsers(dest='command', required=True)
>         parser_a = subparsers.add_parser('list-headers');
>         parser_b = subparsers.add_parser('query-syscall');
>         parser_b.add_argument('syscalls',
>                               help='Which syscalls to check',
>                               nargs='+')
>         return parser
>     parser = get_parser();
>     opts = parser.parse_args(argv)
>
>     if opts.command == 'list-headers':
>     [...]

I just didn't know enough about the argparse module to come up with this.

> I don't think double underscore is required here.

I like it because it prevents exporting.


More information about the Libc-alpha mailing list