diff options
author | aldot <aldot@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-04-13 12:45:04 +0000 |
---|---|---|
committer | aldot <aldot@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-04-13 12:45:04 +0000 |
commit | f0bf1ade78b709229cab0801347032478b02ef96 (patch) | |
tree | 378b5a002da81f8622913cc6a9aeac873e307ec9 /libbb/xfuncs.c | |
parent | a39965951155a179f9e8afed70dd5f45ea70f280 (diff) | |
download | busybox-w32-f0bf1ade78b709229cab0801347032478b02ef96.tar.gz busybox-w32-f0bf1ade78b709229cab0801347032478b02ef96.tar.bz2 busybox-w32-f0bf1ade78b709229cab0801347032478b02ef96.zip |
- patch from Denis Vlasenko to add and use bb_xopen3()
git-svn-id: svn://busybox.net/trunk/busybox@14847 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb/xfuncs.c')
-rw-r--r-- | libbb/xfuncs.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 9ee4fcd65..3db526b85 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -100,10 +100,17 @@ FILE *bb_xfopen(const char *path, const char *mode) | |||
100 | #ifdef L_xopen | 100 | #ifdef L_xopen |
101 | int bb_xopen(const char *pathname, int flags) | 101 | int bb_xopen(const char *pathname, int flags) |
102 | { | 102 | { |
103 | return bb_xopen3(pathname, flags, 0777); | ||
104 | } | ||
105 | #endif | ||
106 | |||
107 | #ifdef L_xopen3 | ||
108 | int bb_xopen3(const char *pathname, int flags, int mode) | ||
109 | { | ||
103 | int ret; | 110 | int ret; |
104 | 111 | ||
105 | ret = open(pathname, flags, 0777); | 112 | ret = open(pathname, flags, mode); |
106 | if (ret == -1) { | 113 | if (ret < 0) { |
107 | bb_perror_msg_and_die("%s", pathname); | 114 | bb_perror_msg_and_die("%s", pathname); |
108 | } | 115 | } |
109 | return ret; | 116 | return ret; |
@@ -116,7 +123,7 @@ ssize_t bb_xread(int fd, void *buf, size_t count) | |||
116 | ssize_t size; | 123 | ssize_t size; |
117 | 124 | ||
118 | size = read(fd, buf, count); | 125 | size = read(fd, buf, count); |
119 | if (size == -1) { | 126 | if (size < 0) { |
120 | bb_perror_msg_and_die(bb_msg_read_error); | 127 | bb_perror_msg_and_die(bb_msg_read_error); |
121 | } | 128 | } |
122 | return(size); | 129 | return(size); |