]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - bcachefs.c
fix list_journal for nochanges
[bcachefs-tools-debian] / bcachefs.c
index 1876823cd2c9ee6f9ab0a201057e9e14c60da7fe..4efe29edaad25c0b3fb96865e0a5f4907b3f1d55 100644 (file)
@@ -35,6 +35,11 @@ static void usage(void)
             "  show-super               Dump superblock information to stdout\n"
             "  set-option               Set a filesystem option\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 +84,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 +120,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 +191,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 cmd_mount(argc, argv);
+#endif
+
+       setvbuf(stdout, NULL, _IOLBF, 0);
 
-       cmd = pop_cmd(&argc, argv);
+       char *cmd = pop_cmd(&argc, argv);
        if (!cmd) {
                puts("missing command\n");
                goto usage;
@@ -216,12 +237,6 @@ int main(int argc, char *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 0
        if (!strcmp(cmd, "assemble"))
                return cmd_assemble(argc, argv);
@@ -247,8 +262,10 @@ int main(int argc, char *argv[])
 
        if (!strcmp(cmd, "dump"))
                return cmd_dump(argc, argv);
+#ifndef BCACHEFS_NO_RUST
        if (!strcmp(cmd, "list"))
                return cmd_list(argc, argv);
+#endif
        if (!strcmp(cmd, "list_journal"))
                return cmd_list_journal(argc, argv);
        if (!strcmp(cmd, "kill_btree_node"))
@@ -256,6 +273,12 @@ int main(int argc, char *argv[])
 
        if (!strcmp(cmd, "setattr"))
                return cmd_setattr(argc, argv);
+#ifndef BCACHEFS_NO_RUST
+       if (!strcmp(cmd, "mount"))
+               return cmd_mount(argc, argv);
+    if (strstr(cmd, "completions"))
+        return cmd_completions(argc, argv);
+#endif
 
 #ifdef BCACHEFS_FUSE
        if (!strcmp(cmd, "fusemount"))