]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
enosys: add --list
authorThomas Weißschuh <thomas@t-8ch.de>
Fri, 28 Apr 2023 11:42:11 +0000 (13:42 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Tue, 16 May 2023 20:44:50 +0000 (22:44 +0200)
bash-completion/enosys
misc-utils/enosys.1.adoc
misc-utils/enosys.c

index 4f63e6640acff5eccb95c8fad2ea4ab394d84123..61aff46c844ab4c8b4833788aa5b8e7afe42e3cb 100644 (file)
@@ -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) )
index 189f1488af2d74435445afbf71f64e8e6bc81602..9ce272860be162c8b71c52e54e6dadc6c219c4cb 100644 (file)
@@ -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
index 4aedda4b39360bcb075da393ecebcde22428a948..83e1847ff50c6469d4a8652b97ee1a56fc1b273f 100644 (file)
@@ -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':