aboutsummaryrefslogtreecommitdiff
path: root/libbb/git.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2009-05-10 20:10:13 +1000
committerNguyễn Thái Ngọc Duy <pclouds@gmail.com>2009-05-10 20:10:13 +1000
commitd2a9ddeb6cc58284996fbc5367877c99fee8914e (patch)
tree187cadb382d0336bbc529cc7ca9e3d1ccd680213 /libbb/git.c
parent1fa419fb3c7ef91e878398bb0388854d27d7bd8f (diff)
downloadbusybox-w32-old.tar.gz
busybox-w32-old.tar.bz2
busybox-w32-old.zip
general warning cleanupold
Diffstat (limited to 'libbb/git.c')
-rw-r--r--libbb/git.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/libbb/git.c b/libbb/git.c
index 3ca8a9424..668f8c118 100644
--- a/libbb/git.c
+++ b/libbb/git.c
@@ -1,13 +1,42 @@
1#include "libbb.h" 1#include "libbb.h"
2#include "git.h" 2#include "git.h"
3 3
4#define die bb_error_msg_and_die
5
6/*
7 * xwrite() is the same a write(), but it automatically restarts write()
8 * operations with a recoverable error (EAGAIN and EINTR). xwrite() DOES NOT
9 * GUARANTEE that "len" bytes is written even if the operation is successful.
10 */
11ssize_t _xwrite(int fd, const void *buf, size_t len)
12{
13 ssize_t nr;
14 while (1) {
15 nr = write(fd, buf, len);
16 if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
17 continue;
18 return nr;
19 }
20}
21
22ssize_t _xread(int fd, void *buf, size_t len)
23{
24 ssize_t nr;
25 while (1) {
26 nr = read(fd, buf, len);
27 if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
28 continue;
29 return nr;
30 }
31}
32
4ssize_t write_in_full(int fd, const void *buf, size_t count) 33ssize_t write_in_full(int fd, const void *buf, size_t count)
5{ 34{
6 const char *p = buf; 35 const char *p = buf;
7 ssize_t total = 0; 36 ssize_t total = 0;
8 37
9 while (count > 0) { 38 while (count > 0) {
10 ssize_t written = xwrite(fd, p, count); 39 ssize_t written = _xwrite(fd, p, count);
11 if (written < 0) 40 if (written < 0)
12 return -1; 41 return -1;
13 if (!written) { 42 if (!written) {