]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - bcachefs.c
fix fsck service location
[bcachefs-tools-debian] / bcachefs.c
index 1876823cd2c9ee6f9ab0a201057e9e14c60da7fe..7b8d4d648a4bc2ed2ee6b8bf7245304bf7cec24e 100644 (file)
@@ -34,7 +34,13 @@ static void usage(void)
             "  format                   Format a new filesystem\n"
             "  show-super               Dump superblock information to stdout\n"
             "  set-option               Set a filesystem option\n"
+            "  reset-counters           Reset all counters on an unmounted device\n"
             "\n"
+#ifndef BCACHEFS_NO_RUST
+            "Mount:\n"
+            "  mount                    Mount a filesystem\n"
+            "\n"
+#endif
             "Repair:\n"
             "  fsck                     Check an existing filesystem for errors\n"
             "\n"
@@ -79,13 +85,22 @@ static void usage(void)
             "\n"
             "Commands for operating on files in a bcachefs filesystem:\n"
             "  setattr                  Set various per file attributes\n"
+            "\n"
             "Debug:\n"
             "These commands work on offline, unmounted filesystems\n"
             "  dump                     Dump filesystem metadata to a qcow2 image\n"
+#ifndef BCACHEFS_NO_RUST
             "  list                     List filesystem metadata in textual form\n"
+#endif
             "  list_journal             List contents of journal\n"
             "\n"
+            "FUSE:\n"
+            "  fusemount                Mount a filesystem via FUSE\n"
+            "\n"
             "Miscellaneous:\n"
+#ifndef BCACHEFS_NO_RUST
+         "  completions              Generate shell completions\n"
+#endif
             "  version                  Display the version of the invoked bcachefs tool\n");
 }
 
@@ -106,8 +121,10 @@ static int fs_cmds(int argc, char *argv[])
 {
        char *cmd = pop_cmd(&argc, argv);
 
-       if (argc < 1)
-               return fs_usage();
+       if (argc < 1) {
+               usage();
+               exit(EXIT_FAILURE);
+       }
        if (!strcmp(cmd, "usage"))
                return cmd_fs_usage(argc, argv);
 
@@ -175,22 +192,27 @@ int main(int argc, char *argv[])
 
        full_cmd = argv[0];
 
-       setvbuf(stdout, NULL, _IOLBF, 0);
+       /* Are we being called via a symlink? */
 
-       if (argc < 2) {
-               puts("missing command\n");
-               goto usage;
-       }
+       if (strstr(full_cmd, "mkfs"))
+               return cmd_format(argc, argv);
 
-       /* Rust commands first - rust can't handle us mutating argv */
-       char *cmd = argv[1];
+       if (strstr(full_cmd, "fsck"))
+               return cmd_fsck(argc, argv);
 
-       if (!strcmp(cmd, "mount")) {
-               cmd_mount();
-               return 0;
-       }
+#ifdef BCACHEFS_FUSE
+       if (strstr(full_cmd, "mount.fuse"))
+               return cmd_fusemount(argc, argv);
+#endif
+
+#ifndef BCACHEFS_NO_RUST
+       if (strstr(full_cmd, "mount"))
+               return rust_main(argc, argv, "mount");
+#endif
 
-       cmd = pop_cmd(&argc, argv);
+       setvbuf(stdout, NULL, _IOLBF, 0);
+
+       char *cmd = pop_cmd(&argc, argv);
        if (!cmd) {
                puts("missing command\n");
                goto usage;
@@ -215,12 +237,8 @@ int main(int argc, char *argv[])
                return cmd_show_super(argc, argv);
        if (!strcmp(cmd, "set-option"))
                return cmd_set_option(argc, argv);
-
-       if (argc < 2) {
-               printf("%s: missing command\n", argv[0]);
-               usage();
-               exit(EXIT_FAILURE);
-       }
+       if (!strcmp(cmd, "reset-counters"))
+               return cmd_reset_counters(argc, argv);
 
 #if 0
        if (!strcmp(cmd, "assemble"))
@@ -247,8 +265,6 @@ int main(int argc, char *argv[])
 
        if (!strcmp(cmd, "dump"))
                return cmd_dump(argc, argv);
-       if (!strcmp(cmd, "list"))
-               return cmd_list(argc, argv);
        if (!strcmp(cmd, "list_journal"))
                return cmd_list_journal(argc, argv);
        if (!strcmp(cmd, "kill_btree_node"))
@@ -256,6 +272,12 @@ int main(int argc, char *argv[])
 
        if (!strcmp(cmd, "setattr"))
                return cmd_setattr(argc, argv);
+#ifndef BCACHEFS_NO_RUST
+       if (!strcmp(cmd, "list") ||
+           !strcmp(cmd, "mount") ||
+           !strcmp(cmd, "completions"))
+               return rust_main(argc, argv, cmd);
+#endif
 
 #ifdef BCACHEFS_FUSE
        if (!strcmp(cmd, "fusemount"))