From: Thomas Weißschuh Date: Fri, 28 Apr 2023 11:42:11 +0000 (+0200) Subject: enosys: add --list X-Git-Tag: v2.40-rc1~466^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7f104027e2a0929e71fa1307dcfe94f5217799a5;p=thirdparty%2Futil-linux.git enosys: add --list --- diff --git a/bash-completion/enosys b/bash-completion/enosys index 4f63e6640a..61aff46c84 100644 --- a/bash-completion/enosys +++ b/bash-completion/enosys @@ -8,6 +8,9 @@ _waitpid_module() '-s'|'--syscall') return 0 ;; + '-l'|'--list') + return 0 + ;; '-h'|'--help'|'-V'|'--version') return 0 ;; @@ -15,6 +18,7 @@ _waitpid_module() case $cur in -*) OPTS="--syscall + --list --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) diff --git a/misc-utils/enosys.1.adoc b/misc-utils/enosys.1.adoc index 189f1488af..9ce272860b 100644 --- a/misc-utils/enosys.1.adoc +++ b/misc-utils/enosys.1.adoc @@ -27,6 +27,9 @@ syscalls as would happen when running on old kernels. *-s*, *--syscall*:: Syscall to block. Can be specified multiple times. +*-l*, *--list*:: +List syscalls known to *enosys*. + include::man-common/help-version.adoc[] == EXIT STATUS diff --git a/misc-utils/enosys.c b/misc-utils/enosys.c index 4aedda4b39..83e1847ff5 100644 --- a/misc-utils/enosys.c +++ b/misc-utils/enosys.c @@ -84,6 +84,7 @@ static void __attribute__((__noreturn__)) usage(void) fputs(USAGE_OPTIONS, out); fputs(_(" -s, --syscall syscall to block\n"), out); + fputs(_(" -l, --list list known syscalls\n"), out); fputs(USAGE_SEPARATOR, out); fprintf(out, USAGE_HELP_OPTIONS(25)); @@ -100,6 +101,7 @@ int main(int argc, char **argv) bool found; static const struct option longopts[] = { { "syscall", required_argument, NULL, 's' }, + { "list", no_argument, NULL, 'l' }, { "version", no_argument, NULL, 'V' }, { "help", no_argument, NULL, 'h' }, { 0 } @@ -107,7 +109,7 @@ int main(int argc, char **argv) bool blocked_syscalls[ARRAY_SIZE(syscalls)] = {}; - while ((c = getopt_long (argc, argv, "Vhs:", longopts, NULL)) != -1) { + while ((c = getopt_long (argc, argv, "Vhs:l", longopts, NULL)) != -1) { switch (c) { case 's': found = 0; @@ -121,6 +123,10 @@ int main(int argc, char **argv) if (!found) errx(EXIT_FAILURE, _("Unknown syscall '%s'"), optarg); break; + case 'l': + for (i = 0; i < ARRAY_SIZE(syscalls); i++) + printf("%s\n", syscalls[i].name); + return EXIT_SUCCESS; case 'V': print_version(EXIT_SUCCESS); case 'h':