diff --git a/commands/memcmp.c b/commands/memcmp.c index d1c4f52..76fbe07 100644 --- a/commands/memcmp.c +++ b/commands/memcmp.c @@ -42,7 +42,8 @@ int ret = 1; int offset = 0; - if (memcpy_parse_options(argc, argv, &sourcefd, &destfd, &count) < 0) + if (memcpy_parse_options(argc, argv, &sourcefd, &destfd, &count, + O_RWSIZE_1, O_RDONLY) < 0) return 1; buf = xmalloc(RW_BUF_SIZE + RW_BUF_SIZE); diff --git a/commands/memcpy.c b/commands/memcpy.c index 5f0047f..b2cea8c 100644 --- a/commands/memcpy.c +++ b/commands/memcpy.c @@ -41,7 +41,8 @@ int ret = 0; char *buf; - if (memcpy_parse_options(argc, argv, &sourcefd, &destfd, &count) < 0) + if (memcpy_parse_options(argc, argv, &sourcefd, &destfd, &count, + 0, O_WRONLY | O_CREAT) < 0) return 1; buf = xmalloc(RW_BUF_SIZE); diff --git a/include/common.h b/include/common.h index b129497..a947406 100644 --- a/include/common.h +++ b/include/common.h @@ -117,7 +117,8 @@ int mem_parse_options(int argc, char *argv[], char *optstr, int *mode, char **sourcefile, char **destfile, int *swab); int memcpy_parse_options(int argc, char *argv[], int *sourcefd, - int *destfd, loff_t *count); + int *destfd, loff_t *count, + int rwsize, int destmode); #define RW_BUF_SIZE (unsigned)4096 extern const char version_string[]; diff --git a/lib/misc.c b/lib/misc.c index 18153bb..7add1fe 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -173,10 +173,11 @@ } int memcpy_parse_options(int argc, char *argv[], int *sourcefd, - int *destfd, loff_t *count) + int *destfd, loff_t *count, + int rwsize, int destmode) { loff_t dest, src; - int mode = 0; + int mode = rwsize; char *sourcefile = NULL; char *destfile = NULL; struct stat statbuf; @@ -212,7 +213,7 @@ if (*sourcefd < 0) return -1; - *destfd = open_and_lseek(destfile, O_WRONLY | O_CREAT | mode, dest); + *destfd = open_and_lseek(destfile, mode | destmode, dest); if (*destfd < 0) { close(*sourcefd); return -1;