diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2006-04-13 12:45:04 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2006-04-13 12:45:04 +0000 |
commit | c2cb0f32b44a9918364af39c24b5643388c553f6 (patch) | |
tree | 378b5a002da81f8622913cc6a9aeac873e307ec9 /libbb | |
parent | 4f3d2deaa499af34c22a7f9be121131b0a5894b5 (diff) | |
download | busybox-c2cb0f32b44a9918364af39c24b5643388c553f6.tar.gz |
- patch from Denis Vlasenko to add and use bb_xopen3()
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/Makefile.in | 2 | ||||
-rw-r--r-- | libbb/xfuncs.c | 13 |
2 files changed, 11 insertions, 4 deletions
diff --git a/libbb/Makefile.in b/libbb/Makefile.in index eac14c60c..102047d73 100644 --- a/libbb/Makefile.in +++ b/libbb/Makefile.in @@ -68,7 +68,7 @@ $(LIBBB_MOBJ0):$(LIBBB_MSRC0) LIBBB_MSRC1:=$(srcdir)/xfuncs.c LIBBB_MOBJ1:=xmalloc.o xrealloc.o xcalloc.o xstrdup.o xstrndup.o \ - xfopen.o xopen.o xread.o xread_all.o xread_char.o \ + xfopen.o xopen.o xopen3.o xread.o xread_all.o xread_char.o \ xferror.o xferror_stdout.o xfflush_stdout.o strlen.o LIBBB_MOBJ1:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ1)) $(LIBBB_MOBJ1):$(LIBBB_MSRC1) 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) #ifdef L_xopen int bb_xopen(const char *pathname, int flags) { + return bb_xopen3(pathname, flags, 0777); +} +#endif + +#ifdef L_xopen3 +int bb_xopen3(const char *pathname, int flags, int mode) +{ int ret; - ret = open(pathname, flags, 0777); - if (ret == -1) { + ret = open(pathname, flags, mode); + if (ret < 0) { bb_perror_msg_and_die("%s", pathname); } return ret; @@ -116,7 +123,7 @@ ssize_t bb_xread(int fd, void *buf, size_t count) ssize_t size; size = read(fd, buf, count); - if (size == -1) { + if (size < 0) { bb_perror_msg_and_die(bb_msg_read_error); } return(size); |