aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-09-05 15:20:10 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-09-05 15:20:10 +0200
commit9fd61be191caf78138a50e9d6a465b39318f91c3 (patch)
treeafb9f5f8874dda32d984496ba433b95d03b5ce18
parent76787a7e025fb4a8b83e29b2fbfdca8d5bd492b9 (diff)
downloadbusybox-w32-9fd61be191caf78138a50e9d6a465b39318f91c3.tar.gz
busybox-w32-9fd61be191caf78138a50e9d6a465b39318f91c3.tar.bz2
busybox-w32-9fd61be191caf78138a50e9d6a465b39318f91c3.zip
libbb/xwrite: print errno on "short write" errors
Lauri Kasanen: :: Over at TinyCore, we receive a huge number of questions of the type "I :: got "short write", what does it mean?". Mostly for the rpi port and when :: using bb wget. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/xfuncs_printf.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c
index e9222f690..1b11caf6b 100644
--- a/libbb/xfuncs_printf.c
+++ b/libbb/xfuncs_printf.c
@@ -235,8 +235,16 @@ void FAST_FUNC xwrite(int fd, const void *buf, size_t count)
235{ 235{
236 if (count) { 236 if (count) {
237 ssize_t size = full_write(fd, buf, count); 237 ssize_t size = full_write(fd, buf, count);
238 if ((size_t)size != count) 238 if ((size_t)size != count) {
239 bb_error_msg_and_die("short write"); 239 /*
240 * Two cases: write error immediately;
241 * or some writes succeeded, then we hit an error.
242 * In either case, errno is set.
243 */
244 bb_perror_msg_and_die(
245 size >= 0 ? "short write" : "write error"
246 );
247 }
240 } 248 }
241} 249}
242void FAST_FUNC xwrite_str(int fd, const char *str) 250void FAST_FUNC xwrite_str(int fd, const char *str)