aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRostislav Skudnov <rostislav@tuxera.com>2019-02-06 11:57:15 +0000
committerDenys Vlasenko <vda.linux@googlemail.com>2019-02-14 13:01:46 +0100
commitd712edc6d8f904a4e9d2e26fc9e8a4c45a2cf0b0 (patch)
tree63742d158c4591be44d895fb862659d40021369b
parentf81e0120f4478c58e126bcadb19b9954ed184e8f (diff)
downloadbusybox-w32-d712edc6d8f904a4e9d2e26fc9e8a4c45a2cf0b0.tar.gz
busybox-w32-d712edc6d8f904a4e9d2e26fc9e8a4c45a2cf0b0.tar.bz2
busybox-w32-d712edc6d8f904a4e9d2e26fc9e8a4c45a2cf0b0.zip
dd: add 'oflag=append'
Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/dd.c16
-rw-r--r--docs/posix_conformance.txt1
2 files changed, 11 insertions, 6 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 4b31e9a7b..2fb9da77c 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -59,7 +59,7 @@
59//usage: "[if=FILE] [of=FILE] [" IF_FEATURE_DD_IBS_OBS("ibs=N obs=N/") "bs=N] [count=N] [skip=N] [seek=N]\n" 59//usage: "[if=FILE] [of=FILE] [" IF_FEATURE_DD_IBS_OBS("ibs=N obs=N/") "bs=N] [count=N] [skip=N] [seek=N]\n"
60//usage: IF_FEATURE_DD_IBS_OBS( 60//usage: IF_FEATURE_DD_IBS_OBS(
61//usage: " [conv=notrunc|noerror|sync|fsync]\n" 61//usage: " [conv=notrunc|noerror|sync|fsync]\n"
62//usage: " [iflag=skip_bytes|fullblock] [oflag=seek_bytes]" 62//usage: " [iflag=skip_bytes|fullblock] [oflag=seek_bytes|append]"
63//usage: ) 63//usage: )
64//usage:#define dd_full_usage "\n\n" 64//usage:#define dd_full_usage "\n\n"
65//usage: "Copy a file with converting and formatting\n" 65//usage: "Copy a file with converting and formatting\n"
@@ -84,6 +84,7 @@
84//usage: "\n iflag=skip_bytes skip=N is in bytes" 84//usage: "\n iflag=skip_bytes skip=N is in bytes"
85//usage: "\n iflag=fullblock Read full blocks" 85//usage: "\n iflag=fullblock Read full blocks"
86//usage: "\n oflag=seek_bytes seek=N is in bytes" 86//usage: "\n oflag=seek_bytes seek=N is in bytes"
87//usage: "\n oflag=append Open output file in append mode"
87//usage: ) 88//usage: )
88//usage: IF_FEATURE_DD_STATUS( 89//usage: IF_FEATURE_DD_STATUS(
89//usage: "\n status=noxfer Suppress rate output" 90//usage: "\n status=noxfer Suppress rate output"
@@ -140,11 +141,12 @@ enum {
140 /* start of output flags */ 141 /* start of output flags */
141 FLAG_OFLAG_SHIFT = 7, 142 FLAG_OFLAG_SHIFT = 7,
142 FLAG_SEEK_BYTES = (1 << 7) * ENABLE_FEATURE_DD_IBS_OBS, 143 FLAG_SEEK_BYTES = (1 << 7) * ENABLE_FEATURE_DD_IBS_OBS,
144 FLAG_APPEND = (1 << 8) * ENABLE_FEATURE_DD_IBS_OBS,
143 /* end of output flags */ 145 /* end of output flags */
144 FLAG_TWOBUFS = (1 << 8) * ENABLE_FEATURE_DD_IBS_OBS, 146 FLAG_TWOBUFS = (1 << 9) * ENABLE_FEATURE_DD_IBS_OBS,
145 FLAG_COUNT = 1 << 9, 147 FLAG_COUNT = 1 << 10,
146 FLAG_STATUS_NONE = 1 << 10, 148 FLAG_STATUS_NONE = 1 << 11,
147 FLAG_STATUS_NOXFER = 1 << 11, 149 FLAG_STATUS_NOXFER = 1 << 12,
148}; 150};
149 151
150static void dd_output_status(int UNUSED_PARAM cur_signal) 152static void dd_output_status(int UNUSED_PARAM cur_signal)
@@ -267,7 +269,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
267 static const char iflag_words[] ALIGN1 = 269 static const char iflag_words[] ALIGN1 =
268 "skip_bytes\0""fullblock\0"; 270 "skip_bytes\0""fullblock\0";
269 static const char oflag_words[] ALIGN1 = 271 static const char oflag_words[] ALIGN1 =
270 "seek_bytes\0"; 272 "seek_bytes\0append\0";
271#endif 273#endif
272#if ENABLE_FEATURE_DD_STATUS 274#if ENABLE_FEATURE_DD_STATUS
273 static const char status_words[] ALIGN1 = 275 static const char status_words[] ALIGN1 =
@@ -451,6 +453,8 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
451 453
452 if (!seek && !(G.flags & FLAG_NOTRUNC)) 454 if (!seek && !(G.flags & FLAG_NOTRUNC))
453 oflag |= O_TRUNC; 455 oflag |= O_TRUNC;
456 if (G.flags & FLAG_APPEND)
457 oflag |= O_APPEND;
454 458
455 xmove_fd(xopen(outfile, oflag), ofd); 459 xmove_fd(xopen(outfile, oflag), ofd);
456 460
diff --git a/docs/posix_conformance.txt b/docs/posix_conformance.txt
index 0e6f4a317..f6e8858cc 100644
--- a/docs/posix_conformance.txt
+++ b/docs/posix_conformance.txt
@@ -183,6 +183,7 @@ dd compatibility options:
183 iflag=skip_bytes| yes | | 183 iflag=skip_bytes| yes | |
184 iflag=fullblock | yes | | 184 iflag=fullblock | yes | |
185 oflag=seek_bytes| yes | | 185 oflag=seek_bytes| yes | |
186 oflag=append | yes | |
186 187
187df POSIX options 188df POSIX options
188 option | exists | compliant | remarks 189 option | exists | compliant | remarks