Btrfs-prog/send: fix wrong dump_fd check in cmd_send_start()
authorChen Yang <chenyang.fnst@cn.fujitsu.com>
Thu, 31 Jan 2013 08:21:24 +0000 (16:21 +0800)
committerDavid Sterba <dsterba@suse.cz>
Thu, 31 Jan 2013 18:17:06 +0000 (19:17 +0100)
In cmd_send_start(), there is a check to make sure dump_fd is not a tty
before parsing command options. So if we use the option "-f file",
it doesn't work for the dump_fd has not been created. So fix it.

Signed-off-by: Cheng Yang <chenyang.fnst@cn.fujitsu.com>
cmds-send.c

index 4a8478d..b314c40 100644 (file)
@@ -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];