aboutsummaryrefslogtreecommitdiff
path: root/include/libbb.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/libbb.h')
-rw-r--r--include/libbb.h43
1 files changed, 29 insertions, 14 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 0836b684e..26656de2e 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -419,6 +419,7 @@ void xchdir(const char *path) FAST_FUNC;
419void xchroot(const char *path) FAST_FUNC; 419void xchroot(const char *path) FAST_FUNC;
420void xsetenv(const char *key, const char *value) FAST_FUNC; 420void xsetenv(const char *key, const char *value) FAST_FUNC;
421void bb_unsetenv(const char *key) FAST_FUNC; 421void bb_unsetenv(const char *key) FAST_FUNC;
422void bb_unsetenv_and_free(char *key) FAST_FUNC;
422void xunlink(const char *pathname) FAST_FUNC; 423void xunlink(const char *pathname) FAST_FUNC;
423void xstat(const char *pathname, struct stat *buf) FAST_FUNC; 424void xstat(const char *pathname, struct stat *buf) FAST_FUNC;
424int xopen(const char *pathname, int flags) FAST_FUNC; 425int xopen(const char *pathname, int flags) FAST_FUNC;
@@ -854,6 +855,20 @@ int bb_execvp(const char *file, char *const argv[]) FAST_FUNC;
854#define BB_EXECVP(prog,cmd) execvp(prog,cmd) 855#define BB_EXECVP(prog,cmd) execvp(prog,cmd)
855#define BB_EXECLP(prog,cmd,...) execlp(prog,cmd, __VA_ARGS__) 856#define BB_EXECLP(prog,cmd,...) execlp(prog,cmd, __VA_ARGS__)
856#endif 857#endif
858int BB_EXECVP_or_die(char **argv) NORETURN FAST_FUNC;
859
860/* xvfork() can't be a _function_, return after vfork mangles stack
861 * in the parent. It must be a macro. */
862#define xvfork() \
863({ \
864 pid_t bb__xvfork_pid = vfork(); \
865 if (bb__xvfork_pid < 0) \
866 bb_perror_msg_and_die("vfork"); \
867 bb__xvfork_pid; \
868})
869#if BB_MMU
870pid_t xfork(void) FAST_FUNC;
871#endif
857 872
858/* NOMMU friendy fork+exec: */ 873/* NOMMU friendy fork+exec: */
859pid_t spawn(char **argv) FAST_FUNC; 874pid_t spawn(char **argv) FAST_FUNC;
@@ -900,7 +915,7 @@ int run_nofork_applet_prime(struct nofork_save_area *old, int applet_no, char **
900 * Both of the above will redirect fd 0,1,2 to /dev/null and drop ctty 915 * Both of the above will redirect fd 0,1,2 to /dev/null and drop ctty
901 * (will do setsid()). 916 * (will do setsid()).
902 * 917 *
903 * fork_or_rexec(argv) = bare-bones "fork" on MMU, 918 * fork_or_rexec(argv) = bare-bones fork on MMU,
904 * "vfork + re-exec ourself" on NOMMU. No fd redirection, no setsid(). 919 * "vfork + re-exec ourself" on NOMMU. No fd redirection, no setsid().
905 * On MMU ignores argv. 920 * On MMU ignores argv.
906 * 921 *
@@ -916,19 +931,19 @@ enum {
916 DAEMON_ONLY_SANITIZE = 8, /* internal use */ 931 DAEMON_ONLY_SANITIZE = 8, /* internal use */
917}; 932};
918#if BB_MMU 933#if BB_MMU
919 pid_t fork_or_rexec(void) FAST_FUNC;
920 enum { re_execed = 0 }; 934 enum { re_execed = 0 };
921# define fork_or_rexec(argv) fork_or_rexec() 935# define fork_or_rexec(argv) xfork()
922# define bb_daemonize_or_rexec(flags, argv) bb_daemonize_or_rexec(flags) 936# define bb_daemonize_or_rexec(flags, argv) bb_daemonize_or_rexec(flags)
923# define bb_daemonize(flags) bb_daemonize_or_rexec(flags, bogus) 937# define bb_daemonize(flags) bb_daemonize_or_rexec(flags, bogus)
924#else 938#else
939 extern bool re_execed;
925 void re_exec(char **argv) NORETURN FAST_FUNC; 940 void re_exec(char **argv) NORETURN FAST_FUNC;
926 pid_t fork_or_rexec(char **argv) FAST_FUNC; 941 pid_t fork_or_rexec(char **argv) FAST_FUNC;
927 extern bool re_execed;
928 int BUG_fork_is_unavailable_on_nommu(void) FAST_FUNC; 942 int BUG_fork_is_unavailable_on_nommu(void) FAST_FUNC;
929 int BUG_daemon_is_unavailable_on_nommu(void) FAST_FUNC; 943 int BUG_daemon_is_unavailable_on_nommu(void) FAST_FUNC;
930 void BUG_bb_daemonize_is_unavailable_on_nommu(void) FAST_FUNC; 944 void BUG_bb_daemonize_is_unavailable_on_nommu(void) FAST_FUNC;
931# define fork() BUG_fork_is_unavailable_on_nommu() 945# define fork() BUG_fork_is_unavailable_on_nommu()
946# define xfork() BUG_fork_is_unavailable_on_nommu()
932# define daemon(a,b) BUG_daemon_is_unavailable_on_nommu() 947# define daemon(a,b) BUG_daemon_is_unavailable_on_nommu()
933# define bb_daemonize(a) BUG_bb_daemonize_is_unavailable_on_nommu() 948# define bb_daemonize(a) BUG_bb_daemonize_is_unavailable_on_nommu()
934#endif 949#endif
@@ -1141,6 +1156,7 @@ typedef struct parser_t {
1141} parser_t; 1156} parser_t;
1142parser_t* config_open(const char *filename) FAST_FUNC; 1157parser_t* config_open(const char *filename) FAST_FUNC;
1143parser_t* config_open2(const char *filename, FILE* FAST_FUNC (*fopen_func)(const char *path)) FAST_FUNC; 1158parser_t* config_open2(const char *filename, FILE* FAST_FUNC (*fopen_func)(const char *path)) FAST_FUNC;
1159/* delims[0] is a comment char (use '\0' to disable), the rest are token delimiters */
1144int config_read(parser_t *parser, char **tokens, unsigned flags, const char *delims) FAST_FUNC; 1160int config_read(parser_t *parser, char **tokens, unsigned flags, const char *delims) FAST_FUNC;
1145#define config_read(parser, tokens, max, min, str, flags) \ 1161#define config_read(parser, tokens, max, min, str, flags) \
1146 config_read(parser, tokens, ((flags) | (((min) & 0xFF) << 8) | ((max) & 0xFF)), str) 1162 config_read(parser, tokens, ((flags) | (((min) & 0xFF) << 8) | ((max) & 0xFF)), str)
@@ -1171,7 +1187,6 @@ char *bb_simplify_abs_path_inplace(char *path) FAST_FUNC;
1171extern void bb_do_delay(int seconds) FAST_FUNC; 1187extern void bb_do_delay(int seconds) FAST_FUNC;
1172extern void change_identity(const struct passwd *pw) FAST_FUNC; 1188extern void change_identity(const struct passwd *pw) FAST_FUNC;
1173extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args) NORETURN FAST_FUNC; 1189extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args) NORETURN FAST_FUNC;
1174extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args) FAST_FUNC;
1175#if ENABLE_SELINUX 1190#if ENABLE_SELINUX
1176extern void renew_current_security_context(void) FAST_FUNC; 1191extern void renew_current_security_context(void) FAST_FUNC;
1177extern void set_current_security_context(security_context_t sid) FAST_FUNC; 1192extern void set_current_security_context(security_context_t sid) FAST_FUNC;
@@ -1611,12 +1626,12 @@ extern struct globals *const ptr_to_globals;
1611 * use bb_default_login_shell and following defines. 1626 * use bb_default_login_shell and following defines.
1612 * If you change LIBBB_DEFAULT_LOGIN_SHELL, 1627 * If you change LIBBB_DEFAULT_LOGIN_SHELL,
1613 * don't forget to change increment constant. */ 1628 * don't forget to change increment constant. */
1614#define LIBBB_DEFAULT_LOGIN_SHELL "-/bin/sh" 1629#define LIBBB_DEFAULT_LOGIN_SHELL "-/bin/sh"
1615extern const char bb_default_login_shell[]; 1630extern const char bb_default_login_shell[];
1616/* "/bin/sh" */ 1631/* "/bin/sh" */
1617#define DEFAULT_SHELL (bb_default_login_shell+1) 1632#define DEFAULT_SHELL (bb_default_login_shell+1)
1618/* "sh" */ 1633/* "sh" */
1619#define DEFAULT_SHELL_SHORT_NAME (bb_default_login_shell+6) 1634#define DEFAULT_SHELL_SHORT_NAME (bb_default_login_shell+6)
1620 1635
1621#if ENABLE_FEATURE_DEVFS 1636#if ENABLE_FEATURE_DEVFS
1622# define CURRENT_VC "/dev/vc/0" 1637# define CURRENT_VC "/dev/vc/0"
@@ -1625,18 +1640,18 @@ extern const char bb_default_login_shell[];
1625# define VC_3 "/dev/vc/3" 1640# define VC_3 "/dev/vc/3"
1626# define VC_4 "/dev/vc/4" 1641# define VC_4 "/dev/vc/4"
1627# define VC_5 "/dev/vc/5" 1642# define VC_5 "/dev/vc/5"
1628#if defined(__sh__) || defined(__H8300H__) || defined(__H8300S__) 1643# if defined(__sh__) || defined(__H8300H__) || defined(__H8300S__)
1629/* Yes, this sucks, but both SH (including sh64) and H8 have a SCI(F) for their 1644/* Yes, this sucks, but both SH (including sh64) and H8 have a SCI(F) for their
1630 respective serial ports .. as such, we can't use the common device paths for 1645 respective serial ports .. as such, we can't use the common device paths for
1631 these. -- PFM */ 1646 these. -- PFM */
1632# define SC_0 "/dev/ttsc/0" 1647# define SC_0 "/dev/ttsc/0"
1633# define SC_1 "/dev/ttsc/1" 1648# define SC_1 "/dev/ttsc/1"
1634# define SC_FORMAT "/dev/ttsc/%d" 1649# define SC_FORMAT "/dev/ttsc/%d"
1635#else 1650# else
1636# define SC_0 "/dev/tts/0" 1651# define SC_0 "/dev/tts/0"
1637# define SC_1 "/dev/tts/1" 1652# define SC_1 "/dev/tts/1"
1638# define SC_FORMAT "/dev/tts/%d" 1653# define SC_FORMAT "/dev/tts/%d"
1639#endif 1654# endif
1640# define VC_FORMAT "/dev/vc/%d" 1655# define VC_FORMAT "/dev/vc/%d"
1641# define LOOP_FORMAT "/dev/loop/%d" 1656# define LOOP_FORMAT "/dev/loop/%d"
1642# define LOOP_NAMESIZE (sizeof("/dev/loop/") + sizeof(int)*3 + 1) 1657# define LOOP_NAMESIZE (sizeof("/dev/loop/") + sizeof(int)*3 + 1)
@@ -1649,15 +1664,15 @@ extern const char bb_default_login_shell[];
1649# define VC_3 "/dev/tty3" 1664# define VC_3 "/dev/tty3"
1650# define VC_4 "/dev/tty4" 1665# define VC_4 "/dev/tty4"
1651# define VC_5 "/dev/tty5" 1666# define VC_5 "/dev/tty5"
1652#if defined(__sh__) || defined(__H8300H__) || defined(__H8300S__) 1667# if defined(__sh__) || defined(__H8300H__) || defined(__H8300S__)
1653# define SC_0 "/dev/ttySC0" 1668# define SC_0 "/dev/ttySC0"
1654# define SC_1 "/dev/ttySC1" 1669# define SC_1 "/dev/ttySC1"
1655# define SC_FORMAT "/dev/ttySC%d" 1670# define SC_FORMAT "/dev/ttySC%d"
1656#else 1671# else
1657# define SC_0 "/dev/ttyS0" 1672# define SC_0 "/dev/ttyS0"
1658# define SC_1 "/dev/ttyS1" 1673# define SC_1 "/dev/ttyS1"
1659# define SC_FORMAT "/dev/ttyS%d" 1674# define SC_FORMAT "/dev/ttyS%d"
1660#endif 1675# endif
1661# define VC_FORMAT "/dev/tty%d" 1676# define VC_FORMAT "/dev/tty%d"
1662# define LOOP_FORMAT "/dev/loop%d" 1677# define LOOP_FORMAT "/dev/loop%d"
1663# define LOOP_NAMESIZE (sizeof("/dev/loop") + sizeof(int)*3 + 1) 1678# define LOOP_NAMESIZE (sizeof("/dev/loop") + sizeof(int)*3 + 1)