]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - bcachefs.c
fix list_journal for nochanges
[bcachefs-tools-debian] / bcachefs.c
index f6148e2903ff5ea099023a560a05556a40fc0c04..4efe29edaad25c0b3fb96865e0a5f4907b3f1d55 100644 (file)
@@ -35,9 +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"
@@ -82,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");
 }
 
@@ -109,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);
 
@@ -178,6 +191,24 @@ int main(int argc, char *argv[])
 
        full_cmd = argv[0];
 
+       /* Are we being called via a symlink? */
+
+       if (strstr(full_cmd, "mkfs"))
+               return cmd_format(argc, argv);
+
+       if (strstr(full_cmd, "fsck"))
+               return cmd_fsck(argc, argv);
+
+#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);
 
        char *cmd = pop_cmd(&argc, argv);
@@ -231,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"))
@@ -240,11 +273,12 @@ int main(int argc, char *argv[])
 
        if (!strcmp(cmd, "setattr"))
                return cmd_setattr(argc, argv);
-
-       if (!strcmp(cmd, "mount")) {
-               cmd_mount(argc, argv);
-               return 0;
-       }
+#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"))