vmsplice-touser: -z requires -m
authorJens Axboe <jens.axboe@oracle.com>
Wed, 13 Jun 2007 13:13:17 +0000 (15:13 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 13 Jun 2007 13:13:17 +0000 (15:13 +0200)
And fix buffer assignment.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
vmsplice-touser.c

index b5cc9bc3feab7a139abce9a21b19b8cc176fc5e3..75e789dd4d9ccafda70f9fae3f4ccb06153a980f 100644 (file)
@@ -49,6 +49,7 @@ static int do_vmsplice(int fd, unsigned char **buf, int len)
                        return error("poll");
 
                written = svmsplice(fd, &iov, 1, splice_flags);
+               *buf = iov.iov_base;
 
                if (written < 0)
                        return error("vmsplice");
@@ -63,8 +64,6 @@ static int do_vmsplice(int fd, unsigned char **buf, int len)
                }
        }
 
-       if (!*buf)
-               *buf = iov.iov_base;
        return ret;
 }
 
@@ -131,6 +130,11 @@ int main(int argc, char *argv[])
        if (check_input_pipe())
                return usage(argv[0]);
 
+       if (do_zeromap && !(splice_flags & SPLICE_F_MOVE)) {
+               fprintf(stderr, "zero map only valid for -m(ove)\n");
+               return usage(argv[0]);
+       }
+
        if (!do_zeromap) {
                buf = malloc(4096);
                memset(buf, 0, 4096);