ubase

suckless linux base utils
git clone git://git.2f30.org/ubase.git
Log | Files | Refs | README | LICENSE

commit c116687c1d6d033009165371b7215e6b50ecdb40
parent 55ab6a8a69c5fd7f41bc867053b53e2c12734186
Author: Eivind Uggedal <eivind@uggedal.com>
Date:   Tue Mar 15 21:06:28 +0000

dd: truncate file when using seek=

Diffstat:
dd.c | 9+++++++++
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/dd.c b/dd.c @@ -108,6 +108,15 @@ prepare_copy(struct dd_config *ddc, int *ifd, int *ofd) return -1; } + if (ddc->seek) { + if (fstat(*ofd, &st) < 0) + return -1; + if (!S_ISREG(st.st_mode)) + ; + else if (ftruncate(*ofd, ddc->seek) < 0) + return -1; + } + if (lseek(*ifd, ddc->skip, SEEK_CUR) < 0) { char buffer[ddc->bs]; for (uint64_t i = 0; i < ddc->skip; i += ddc->bs) {