]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fadvise: implement --advice argument
authorThomas Weißschuh <thomas@t-8ch.de>
Sun, 16 Apr 2023 08:30:47 +0000 (10:30 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Sun, 16 Apr 2023 16:43:09 +0000 (18:43 +0200)
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
misc-utils/fadvise.c

index 54f23f63eca235701cd11aa074e7900fa89bd346..c6c8eaf1fd0fffbc0b7c22d97d82306be859cdcd 100644 (file)
@@ -96,6 +96,15 @@ int main(int argc, char ** argv)
        while ((c = getopt_long (argc, argv, "a:d:hl:o:V", longopts, NULL)) != -1) {
                switch (c) {
                case 'a':
+                       advice = -1;
+                       for (size_t i = 0; i < ARRAY_SIZE(advices); i++) {
+                               if (strcmp(optarg, advices[i].name) == 0) {
+                                       advice = advices[i].num;
+                                       break;
+                               }
+                       }
+                       if (advice == -1)
+                               errx(EXIT_FAILURE, "invalid advice argument: '%s'", optarg);
                        break;
                case 'd':
                        fd = strtos32_or_err(optarg,