[hackers] [ubase] Fallback to pagesize transfers in dd(1) || sin

From: <git_AT_suckless.org>
Date: Wed, 04 Jun 2014 14:39:12 +0200

commit 9c7d08773fcd398b50b484c5965438116cdb85e7
Author: sin <sin_AT_2f30.org>
Date: Wed Jun 4 13:34:13 2014 +0100

    Fallback to pagesize transfers in dd(1)

diff --git a/dd.c b/dd.c
index 994f712..79a3d08 100644
--- a/dd.c
+++ b/dd.c
_AT_@ -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;
_AT_@ -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 */
Received on Wed Jun 04 2014 - 14:39:12 CEST

This archive was generated by hypermail 2.3.0 : Wed Jun 04 2014 - 14:48:08 CEST