}
+#ifdef __GLIBC__
+/* Make it reside in R/W memory: */
+int *const bb_errno __attribute__ ((section (".data")));
+#endif
+
int main(int argc, char **argv)
{
const char *s;
+#ifdef __GLIBC__
+ (*(int **)&bb_errno) = __errno_location();
+#endif
+
#if !BB_MMU
/* NOMMU re-exec trick sets high-order bit in first byte of name */
if (argv[0][0] & 0x80) {
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-#include <sys/types.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include "unarchive.h"
#include "libbb.h"
+#include "unarchive.h"
void data_skip(archive_handle_t *archive_handle)
{
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-#include <sys/types.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-
#include "libbb.h"
#include "unarchive.h"
#include <sys/types.h>
#include <sys/stat.h>
-#include <unistd.h>
#include <dirent.h>
-#include <errno.h>
-#include <stdlib.h>
#include <getopt.h> /* struct option */
#include "libbb.h"
#include "libcoreutils/coreutils.h"
*/
#include "libbb.h"
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
int mktemp_main(int argc, char **argv);
int mktemp_main(int argc, char **argv)
#endif
+#if defined(__GLIBC__)
+/* glibc uses __errno_location() to get a ptr to errno */
+/* We can just memorize it once - no multithreading in busybox :) */
+extern int *const bb_errno;
+#undef errno
+#define errno (*bb_errno)
+#endif
+
#if defined(__GLIBC__) && __GLIBC__ < 2
int vdprintf(int d, const char *format, va_list ap);
#endif
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
#include "libbb.h"
void bb_error_msg(const char *s, ...)
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
#include "libbb.h"
void bb_perror_msg(const char *s, ...)
* SUCH DAMAGE.
*/
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <syslog.h>
-#include <ctype.h>
#include "libbb.h"
-#ifdef CONFIG_SELINUX
+#if ENABLE_SELINUX
#include <selinux/selinux.h> /* for setexeccon */
#endif
-#ifdef CONFIG_SELINUX
+#if ENABLE_SELINUX
static security_context_t current_sid;
void
args[argno++] = *additional_args;
}
args[argno] = NULL;
-#ifdef CONFIG_SELINUX
+#if ENABLE_SELINUX
if (current_sid && !setexeccon(current_sid)) {
freecon(current_sid);
execve(shell, (char **) args, environ);
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
#include "libbb.h"
-
-
ssize_t safe_write(int fd, const void *buf, size_t count)
{
ssize_t n;
#include <selinux/selinux.h> /* for is_selinux_enabled() */
#include <selinux/get_context_list.h> /* for get_default_context() */
#include <selinux/flask.h> /* for security class definitions */
-#include <errno.h>
#endif
enum {
#include "libbb.h"
#include "xregex.h"
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/stat.h>
-#include <sys/types.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <dirent.h>
-#include <fcntl.h>
#include <syslog.h>
-#include <signal.h>
-#include <errno.h>
#include <sys/sysmacros.h>
*
*/
-#include "libbb.h"
#include <sys/socket.h>
-
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-
#include <sys/uio.h>
+#include "libbb.h"
#include "libnetlink.h"
void rtnl_close(struct rtnl_handle *rth)
/* ============ Misc data */
-#ifdef __GLIBC__
-/* glibc sucks */
-static int *dash_errno;
-#undef errno
-#define errno (*dash_errno)
-#endif
-
static char nullstr[1]; /* zero length string */
static const char homestr[] = "HOME";
static const char snlfmt[] = "%s\n";
struct jmploc jmploc;
struct stackmark smark;
-#ifdef __GLIBC__
- dash_errno = __errno_location();
-#endif
-
#if PROFILE
monitor(4, etext, profile_buf, sizeof(profile_buf), 50);
#endif
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-#include "libbb.h"
-#include <errno.h>
-#include <time.h>
-#include <pwd.h>
-#include <grp.h>
-
/* X/OPEN tells us to use <sys/{types,ipc,sem}.h> for semctl() */
/* X/OPEN tells us to use <sys/{types,ipc,msg}.h> for msgctl() */
/* X/OPEN tells us to use <sys/{types,ipc,shm}.h> for shmctl() */
#include <sys/msg.h>
#include <sys/shm.h>
-
+#include "libbb.h"
/*-------------------------------------------------------------------*/
/* SHM_DEST and SHM_LOCKED are defined in kernel headers,
* Licensed under GPL v2 or later, see file License for details.
*/
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <stdio.h>
#include <sys/personality.h>
#include "libbb.h"