Btrfs-progs: List all subvolumes by default
[platform/upstream/btrfs-progs.git] / cmds-send.c
index d2f7691..43355db 100644 (file)
@@ -152,7 +152,7 @@ static int find_good_parent(struct btrfs_send *s, u64 root_id, u64 *found)
                if (tmp < 0)
                        tmp *= -1;
                if (tmp < best_diff) {
-                       best_parent = parent;
+                       best_parent = parent2;
                        best_diff = tmp;
                }
        }
@@ -431,11 +431,6 @@ int cmd_send_start(int argc, char **argv)
        memset(&send, 0, sizeof(send));
        send.dump_fd = fileno(stdout);
 
-       if (isatty(send.dump_fd)) {
-               fprintf(stderr, "ERROR: not dumping send stream into a terminal, redirect it into a file\n");
-               return 1;
-       }
-
        while ((c = getopt(argc, argv, "vc:f:i:p:")) != -1) {
                switch (c) {
                case 'v':
@@ -508,6 +503,13 @@ int cmd_send_start(int argc, char **argv)
                }
        }
 
+       if (isatty(send.dump_fd)) {
+               fprintf(stderr, 
+                       "ERROR: not dumping send stream into a terminal, "
+                       "redirect it into a file\n");
+               return 1;
+       }
+
        /* use first send subvol to determine mount_root */
        subvol = argv[optind];
 
@@ -635,7 +637,7 @@ static const char * const send_cmd_group_usage[] = {
        NULL
 };
 
-static const char * const cmd_send_usage[] = {
+const char * const cmd_send_usage[] = {
        "btrfs send [-v] [-p <parent>] [-c <clone-src>] <subvol>",
        "Send the subvolume to stdout.",
        "Sends the subvolume specified by <subvol> to stdout.",
@@ -649,7 +651,7 @@ static const char * const cmd_send_usage[] = {
        "which case 'btrfs send' will determine a suitable parent among the",
        "clone sources itself.",
        "\n",
-       "-v               Enable verbose debug output. Each occurrency of",
+       "-v               Enable verbose debug output. Each occurrence of",
        "                 this option increases the verbose level more.",
        "-p <parent>      Send an incremental stream from <parent> to",
        "                 <subvol>.",
@@ -661,13 +663,6 @@ static const char * const cmd_send_usage[] = {
        NULL
 };
 
-const struct cmd_group send_cmd_group = {
-       send_cmd_group_usage, NULL, {
-               { "send", cmd_send_start, cmd_send_usage, NULL, 0 },
-               { 0, 0, 0, 0, 0 },
-        },
-};
-
 int cmd_send(int argc, char **argv)
 {
        return cmd_send_start(argc, argv);