From 968975283c6fe5ed8d03b94dd1126f33a2449e71 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Sun, 30 Apr 2006 14:29:00 +0200 Subject: [PATCH] [PATCH] vmsplice: allow for setting of SPLICE_F_GIFT flag. --- splice.h | 1 + vmsplice.c | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/splice.h b/splice.h index e9c2f2a..2b92066 100644 --- a/splice.h +++ b/splice.h @@ -29,6 +29,7 @@ /* we may still block on the fd we splice */ /* from/to, of course */ #define SPLICE_F_MORE (0x04) /* expect more data */ +#define SPLICE_F_GIFT (0x08) /* pages passed in are a gift */ static inline int splice(int fdin, loff_t *off_in, int fdout, loff_t *off_out, size_t len, unsigned long flags) diff --git a/vmsplice.c b/vmsplice.c index 5c0b1ed..0382f46 100644 --- a/vmsplice.c +++ b/vmsplice.c @@ -17,6 +17,8 @@ static int do_clear; static int align_mask = 65535; +static int force_unalign; +static int splice_flags; int do_vmsplice(int fd, void *b1, void *b2, int len) { @@ -42,7 +44,7 @@ int do_vmsplice(int fd, void *b1, void *b2, int len) if (poll(&pfd, 1, -1) < 0) return error("poll"); - written = vmsplice(fd, &iov[idx], 2 - idx, 0); + written = vmsplice(fd, &iov[idx], 2 - idx, splice_flags); if (written <= 0) return error("vmsplice"); @@ -65,7 +67,7 @@ int do_vmsplice(int fd, void *b1, void *b2, int len) static int usage(char *name) { - fprintf(stderr, "%s: [-c(lear)] [-u(nalign)] | ...\n", name); + fprintf(stderr, "%s: [-c(lear)] [-u(nalign)] [-g(ift)]| ...\n", name); return 1; } @@ -73,14 +75,18 @@ static int parse_options(int argc, char *argv[]) { int c, index = 1; - while ((c = getopt(argc, argv, "cu")) != -1) { + while ((c = getopt(argc, argv, "cug")) != -1) { switch (c) { case 'c': do_clear = 1; index++; break; case 'u': - align_mask = 0; + force_unalign = 1; + index++; + break; + case 'g': + splice_flags = SPLICE_F_GIFT; index++; break; default: @@ -104,6 +110,11 @@ int main(int argc, char *argv[]) b1 = ALIGN(malloc(SPLICE_SIZE + align_mask)); b2 = ALIGN(malloc(SPLICE_SIZE + align_mask)); + if (force_unalign) { + b1 += 1024; + b2 += 1024; + } + memset(b1, 0xaa, SPLICE_SIZE); memset(b2, 0xbb, SPLICE_SIZE); -- 2.25.1