commit 9c7d08773fcd398b50b484c5965438116cdb85e7
parent ee5c4e45212bf8d3642be066a7495965f23616f4
Author: sin <sin@2f30.org>
Date: Wed, 4 Jun 2014 13:34:13 +0100
Fallback to pagesize transfers in dd(1)
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/dd.c b/dd.c
@@ -41,6 +41,7 @@ prepare_copy(struct dd_config *ddc, int *ifd, int *ofd)
struct stat st;
int fli = O_RDONLY|O_LARGEFILE|O_NOCTTY, flo = O_WRONLY|O_LARGEFILE|O_NOATIME|O_NOCTTY;
uid_t euid = 0;
+ long pagesize;
if (ddc->direct) {
fli |= O_DIRECT;
@@ -68,14 +69,17 @@ prepare_copy(struct dd_config *ddc, int *ifd, int *ofd)
if (!ddc->bs) {
struct statfs fst;
memset(&fst, 0, sizeof(fst));
+ pagesize = sysconf(_SC_PAGESIZE);
+ if (pagesize <= 0)
+ pagesize = 0x1000;
if (statfs(ddc->out, &fst) < 0 || fst.f_bsize == 0)
- fst.f_bsize = 0x1000;
+ fst.f_bsize = pagesize;
if ((unsigned long)fst.f_bsize > (unsigned long)st.st_blksize)
ddc->bs = fst.f_bsize;
else
ddc->bs = st.st_blksize;
if (ddc->bs == 0)
- ddc->bs = 0x1000;
+ ddc->bs = pagesize;
}
/* check if device or regular file */