Add notrunc conversion for dd tool

This commit is contained in:
Erik van der Kouwe 2010-01-27 07:48:06 +00:00
parent 3e583f4c04
commit d8b8e10ba4
2 changed files with 12 additions and 3 deletions

View file

@ -82,6 +82,7 @@ int num()
#define NOERROR 0x0008
#define SYNC 0x0010
#define SILENT 0x0020
#define NOTRUNC 0x0040
#define BLANK ' '
#define DEFAULT 512
@ -142,7 +143,7 @@ char *argv[];
void (*convert) ();
#endif
char *iptr;
int i, j;
int i, j, oflags;
convert = null;
argc--;
@ -213,6 +214,10 @@ char *argv[];
convflag |= NOERROR;
continue;
}
if (is("notrunc")) {
convflag |= NOTRUNC;
continue;
}
if (is("sync")) {
convflag |= SYNC;
continue;
@ -241,8 +246,10 @@ char *argv[];
(ifilename) ? ifilename : "stdin", strerror(errno));
exit(1);
}
if ((ofd = ((ofilename) ? open(ofilename, seekseen ? O_WRONLY | O_CREAT
: O_WRONLY | O_CREAT | O_TRUNC, 0666)
oflags = O_WRONLY | O_CREAT;
if (!seekseen && (convflag & NOTRUNC) != NOTRUNC)
oflags |= O_TRUNC;
if ((ofd = ((ofilename) ? open(ofilename, oflags, 0666)
: dup(1))) < 0) {
fprintf(stderr, "dd: Can't open %s: %s\n",
(ofilename) ? ofilename : "stdout", strerror(errno));

View file

@ -48,6 +48,8 @@ The options are:
\fBconv = swab\fR \- Swap every pair of bytes
.br
\fBconv = noerror\fR \- Ignore errors and just keep going
.br
\fBconv = notrunc\fR \- Do not truncate unmodified blocks
.br
\fBconv = silent\fR \- Suppress statistics (MINIX 3 specific flag)
.PP