btrfs-progs: Beautify owner when printing leaf/nodes
[platform/upstream/btrfs-progs.git] / btrfs-crc.c
index 1ef00eb..c3e4774 100644 (file)
 #include "crc32c.h"
 #include "utils.h"
 
-void usage(void)
+void print_usage(int status)
 {
        printf("usage: btrfs-crc filename\n");
        printf("    print out the btrfs crc for \"filename\"\n");
-       printf("usage: btrfs-crc filename -c crc [-s seed] [-l length]\n");
+       printf("usage: btrfs-crc -c crc [-s seed] [-l length]\n");
        printf("    brute force search for file names with the given crc\n");
        printf("      -s seed    the random seed (default: random)\n");
        printf("      -l length  the length of the file names (default: 10)\n");
-       exit(1);
+       printf("usage: btrfs-crc -h\n");
+       printf("    print this message\n");
+       exit(status);
 }
 
 int main(int argc, char **argv)
@@ -57,9 +59,9 @@ int main(int argc, char **argv)
                        seed = atoll(optarg);
                        break;
                case 'h':
-                       usage();
+                       print_usage(1);
                case '?':
-                       return 255;
+                       print_usage(255);
                }
        }
 
@@ -67,12 +69,14 @@ int main(int argc, char **argv)
        str = argv[optind];
 
        if (!loop) {
-               if (check_argc_min(argc - optind, 1))
-                       return 255;
+               if (check_argc_exact(argc - optind, 1))
+                       print_usage(255);
 
                printf("%12u - %s\n", crc32c(~1, str, strlen(str)), str);
                return 0;
        }
+       if (check_argc_exact(argc - optind, 0))
+               print_usage(255);
 
        buf = malloc(length);
        if (!buf)