diff options
author | rwatson <rwatson@FreeBSD.org> | 2004-08-15 19:10:05 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2004-08-15 19:10:05 +0000 |
commit | 9e69bea9f10d447d337c54d6f5378346f998434f (patch) | |
tree | c508168354348245f2a483698e91245e93ecf503 /bin/dd/dd.c | |
parent | 7e0b05723702eca98bf7ece454b0be3fac59f877 (diff) | |
download | FreeBSD-src-9e69bea9f10d447d337c54d6f5378346f998434f.zip FreeBSD-src-9e69bea9f10d447d337c54d6f5378346f998434f.tar.gz |
Add a "fillchar" command line argument to dd(1) that permits the user
to specify an alternative padding character when using a conversion
mode, or when using noerror with sync and an input error occurs. This
facilities reading old and error-prone media by allowing the user to
more effectively mark error blocks in the output stream.
Diffstat (limited to 'bin/dd/dd.c')
-rw-r--r-- | bin/dd/dd.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/bin/dd/dd.c b/bin/dd/dd.c index 678f138..0bb43f7 100644 --- a/bin/dd/dd.c +++ b/bin/dd/dd.c @@ -80,6 +80,7 @@ u_int ddflags = 0; /* conversion options */ size_t cbsz; /* conversion block size */ uintmax_t files_cnt = 1; /* # of files to copy */ const u_char *ctab; /* conversion table */ +char fill_char; /* Character to fill with if defined */ int main(int argc __unused, char *argv[]) @@ -287,7 +288,9 @@ dd_in(void) * use spaces. */ if (ddflags & C_SYNC) { - if (ddflags & (C_BLOCK | C_UNBLOCK)) + if (ddflags & C_FILL) + memset(in.dbp, fill_char, in.dbsz); + else if (ddflags & (C_BLOCK | C_UNBLOCK)) memset(in.dbp, ' ', in.dbsz); else memset(in.dbp, 0, in.dbsz); @@ -382,7 +385,9 @@ dd_close(void) else if (cfunc == unblock) unblock_close(); if (ddflags & C_OSYNC && out.dbcnt && out.dbcnt < out.dbsz) { - if (ddflags & (C_BLOCK | C_UNBLOCK)) + if (ddflags & C_FILL) + memset(out.dbp, fill_char, out.dbsz - out.dbcnt); + else if (ddflags & (C_BLOCK | C_UNBLOCK)) memset(out.dbp, ' ', out.dbsz - out.dbcnt); else memset(out.dbp, 0, out.dbsz - out.dbcnt); |