Add notrunc conversion for dd tool
This commit is contained in:
parent
3e583f4c04
commit
d8b8e10ba4
2 changed files with 12 additions and 3 deletions
|
@ -82,6 +82,7 @@ int num()
|
||||||
#define NOERROR 0x0008
|
#define NOERROR 0x0008
|
||||||
#define SYNC 0x0010
|
#define SYNC 0x0010
|
||||||
#define SILENT 0x0020
|
#define SILENT 0x0020
|
||||||
|
#define NOTRUNC 0x0040
|
||||||
#define BLANK ' '
|
#define BLANK ' '
|
||||||
#define DEFAULT 512
|
#define DEFAULT 512
|
||||||
|
|
||||||
|
@ -142,7 +143,7 @@ char *argv[];
|
||||||
void (*convert) ();
|
void (*convert) ();
|
||||||
#endif
|
#endif
|
||||||
char *iptr;
|
char *iptr;
|
||||||
int i, j;
|
int i, j, oflags;
|
||||||
|
|
||||||
convert = null;
|
convert = null;
|
||||||
argc--;
|
argc--;
|
||||||
|
@ -213,6 +214,10 @@ char *argv[];
|
||||||
convflag |= NOERROR;
|
convflag |= NOERROR;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (is("notrunc")) {
|
||||||
|
convflag |= NOTRUNC;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (is("sync")) {
|
if (is("sync")) {
|
||||||
convflag |= SYNC;
|
convflag |= SYNC;
|
||||||
continue;
|
continue;
|
||||||
|
@ -241,8 +246,10 @@ char *argv[];
|
||||||
(ifilename) ? ifilename : "stdin", strerror(errno));
|
(ifilename) ? ifilename : "stdin", strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if ((ofd = ((ofilename) ? open(ofilename, seekseen ? O_WRONLY | O_CREAT
|
oflags = O_WRONLY | O_CREAT;
|
||||||
: O_WRONLY | O_CREAT | O_TRUNC, 0666)
|
if (!seekseen && (convflag & NOTRUNC) != NOTRUNC)
|
||||||
|
oflags |= O_TRUNC;
|
||||||
|
if ((ofd = ((ofilename) ? open(ofilename, oflags, 0666)
|
||||||
: dup(1))) < 0) {
|
: dup(1))) < 0) {
|
||||||
fprintf(stderr, "dd: Can't open %s: %s\n",
|
fprintf(stderr, "dd: Can't open %s: %s\n",
|
||||||
(ofilename) ? ofilename : "stdout", strerror(errno));
|
(ofilename) ? ofilename : "stdout", strerror(errno));
|
||||||
|
|
|
@ -48,6 +48,8 @@ The options are:
|
||||||
\fBconv = swab\fR \- Swap every pair of bytes
|
\fBconv = swab\fR \- Swap every pair of bytes
|
||||||
.br
|
.br
|
||||||
\fBconv = noerror\fR \- Ignore errors and just keep going
|
\fBconv = noerror\fR \- Ignore errors and just keep going
|
||||||
|
.br
|
||||||
|
\fBconv = notrunc\fR \- Do not truncate unmodified blocks
|
||||||
.br
|
.br
|
||||||
\fBconv = silent\fR \- Suppress statistics (MINIX 3 specific flag)
|
\fBconv = silent\fR \- Suppress statistics (MINIX 3 specific flag)
|
||||||
.PP
|
.PP
|
||||||
|
|
Loading…
Reference in a new issue