runit_lib: remove/inline a few more things
authorDenys Vlasenko <dvlasenk@redhat.com>
Sun, 5 Sep 2010 17:28:29 +0000 (19:28 +0200)
committerDenys Vlasenko <dvlasenk@redhat.com>
Sun, 5 Sep 2010 17:28:29 +0000 (19:28 +0200)
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
runit/chpst.c
runit/runit_lib.c
runit/runit_lib.h
runit/runsv.c

index ad08112..b08d423 100644 (file)
@@ -29,7 +29,6 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /* Dependencies on runit_lib.c removed */
 
 #include "libbb.h"
-#include <dirent.h>
 
 /*
 Five applets here: chpst, envdir, envuidgid, setuidgid, softlimit.
index ec18b5e..8182a90 100644 (file)
@@ -198,27 +198,29 @@ void iopause(iopause_fd *x, unsigned len, struct taia *deadline, struct taia *st
 
 int lock_ex(int fd)
 {
-       return flock(fd,LOCK_EX);
+       return flock(fd, LOCK_EX);
 }
 
 int lock_exnb(int fd)
 {
-       return flock(fd,LOCK_EX | LOCK_NB);
+       return flock(fd, LOCK_EX | LOCK_NB);
 }
 
+#ifdef UNUSED
 int open_append(const char *fn)
 {
-       return open(fn, O_WRONLY|O_NDELAY|O_APPEND|O_CREAT, 0600);
+       return open(fn, O_WRONLY | O_NDELAY | O_APPEND | O_CREAT, 0600);
 }
 
-int open_read(const char *fn)
+int open_trunc(const char *fn)
 {
-       return open(fn, O_RDONLY|O_NDELAY);
+       return open(fn, O_WRONLY | O_NDELAY | O_TRUNC | O_CREAT, 0644);
 }
+#endif
 
-int open_trunc(const char *fn)
+int open_read(const char *fn)
 {
-       return open(fn,O_WRONLY | O_NDELAY | O_TRUNC | O_CREAT,0644);
+       return open(fn, O_RDONLY|O_NDELAY);
 }
 
 int open_write(const char *fn)
@@ -226,7 +228,7 @@ int open_write(const char *fn)
        return open(fn, O_WRONLY|O_NDELAY);
 }
 
-unsigned pmatch(const char *p, const char *s, unsigned len)
+unsigned FAST_FUNC pmatch(const char *p, const char *s, unsigned len)
 {
        for (;;) {
                char c = *p++;
index 88d1c9f..d8304ac 100644 (file)
@@ -66,18 +66,18 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
 //extern void iopause(iopause_fd *,unsigned,struct taia *,struct taia *);
 
 extern int lock_ex(int);
-extern int lock_un(int);
+//extern int lock_un(int);
 extern int lock_exnb(int);
 
 extern int open_read(const char *);
-extern int open_excl(const char *);
-extern int open_append(const char *);
-extern int open_trunc(const char *);
 extern int open_write(const char *);
+//extern int open_excl(const char *);
+//extern int open_append(const char *);
+//extern int open_trunc(const char *);
 
-extern unsigned pmatch(const char *, const char *, unsigned);
+extern unsigned FAST_FUNC pmatch(const char *, const char *, unsigned);
 
-#define str_diff(s,t) strcmp((s), (t))
+//#define str_diff(s,t) strcmp((s), (t))
 #define str_equal(s,t) (!strcmp((s), (t)))
 
 /*
index 5b221e9..6bb6ec8 100644 (file)
@@ -151,7 +151,8 @@ static char *bb_stpcpy(char *p, const char *to_add)
 
 static int open_trunc_or_warn(const char *name)
 {
-       int fd = open_trunc(name);
+       /* Why O_NDELAY? */
+       int fd = open(name, O_WRONLY | O_NDELAY | O_TRUNC | O_CREAT, 0644);
        if (fd < 0)
                bb_perror_msg("%s: warning: cannot open %s",
                                dir, name);