#include "busybox.h"
#if ENABLE_BUILD_LIBBUSYBOX
-int main(int argc, char **argv)
+int main(int argc ATTRIBUTE_UNUSED, char **argv)
{
- return lbb_main(argc, argv);
+ return lbb_main(argv);
}
#endif
}
int bzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int bzip2_main(int argc, char **argv)
+int bzip2_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
unsigned opt;
}
int gzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+#if ENABLE_GUNZIP
int gzip_main(int argc, char **argv)
+#else
+int gzip_main(int argc ATTRIBUTE_UNUSED, char **argv)
+#endif
{
unsigned opt;
#if ENABLE_STTY
return stty_main(2, (char**)args);
#else
- execvp("stty", args);
+ execvp("stty", (char**)args);
#endif
}
return EXIT_SUCCESS;
#define OPT_DEREFERENCE (1 << 2)
#define OPT_SELINUX (1 << 3)
+#if ENABLE_FEATURE_STAT_FORMAT
+typedef bool (*statfunc_ptr)(const char *, const char *);
+#else
+typedef bool (*statfunc_ptr)(const char *);
+#endif
+
static const char *file_type(const struct stat *st)
{
/* See POSIX 1003.1-2001 XCU Table 4-8 lines 17093-17107
#endif
/* Stat the file system and print what we find. */
+#if !ENABLE_FEATURE_STAT_FORMAT
+#define do_statfs(filename, format) do_statfs(filename)
+#endif
static bool do_statfs(const char *filename, const char *format)
{
+#if !ENABLE_FEATURE_STAT_FORMAT
+ const char *format;
+#endif
struct statfs statfsbuf;
#if ENABLE_SELINUX
security_context_t scontext = NULL;
}
/* stat the file and print what we find */
+#if !ENABLE_FEATURE_STAT_FORMAT
+#define do_stat(filename, format) do_stat(filename)
+#endif
static bool do_stat(const char *filename, const char *format)
{
struct stat statbuf;
int stat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int stat_main(int argc, char **argv)
{
- char *format = NULL;
+ USE_FEATURE_STAT_FORMAT(char *format = NULL;)
int i;
int ok = 1;
- bool (*statfunc)(const char *, const char *) = do_stat;
+ statfunc_ptr statfunc = do_stat;
getopt32(argv, "ftL"
USE_SELINUX("Z")
}
#endif /* ENABLE_SELINUX */
for (i = optind; i < argc; ++i)
- ok &= statfunc(argv[i], format);
+ ok &= statfunc(argv[i] USE_FEATURE_STAT_FORMAT(, format));
return (ok ? EXIT_SUCCESS : EXIT_FAILURE);
}
#endif
-static int fileAction(const char *fileName, struct stat *statbuf, void *userData, int depth)
+static int fileAction(const char *fileName,
+ struct stat *statbuf,
+ void *userData SKIP_FEATURE_FIND_MAXDEPTH(ATTRIBUTE_UNUSED),
+ int depth SKIP_FEATURE_FIND_MAXDEPTH(ATTRIBUTE_UNUSED))
{
int i;
#if ENABLE_FEATURE_FIND_MAXDEPTH
) MAIN_EXTERNALLY_VISIBLE;
#if ENABLE_BUILD_LIBBUSYBOX
#if ENABLE_FEATURE_SHARED_BUSYBOX
-int lbb_main(int argc, char **argv) EXTERNALLY_VISIBLE;
+int lbb_main(char **argv) EXTERNALLY_VISIBLE;
#else
-int lbb_main(int argc, char **argv);
+int lbb_main(char **argv);
#endif
#endif
int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData, int depth),
void* userData, unsigned depth);
extern int device_open(const char *device, int mode);
-extern int getpty(char *line, int size);
+enum { GETPTY_BUFSIZE = 16 }; /* more than enough for "/dev/ttyXXX" */
+extern int getpty(char *line);
extern int get_console_fd(void);
extern char *find_block_device(const char *path);
/* bb_copyfd_XX print read/write errors and return -1 if they occur */
""
#define false_full_usage \
"Return an exit code of FALSE (1)"
+
#define false_example_usage \
"$ false\n" \
"$ echo $?\n" \
#endif
int halt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int halt_main(int argc, char **argv)
+int halt_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
static const int magic[] = {
#ifdef RB_HALT_SYSTEM
#if ENABLE_BUILD_LIBBUSYBOX
-int lbb_main(int argc, char **argv)
+int lbb_main(char **argv)
#else
int main(int argc ATTRIBUTE_UNUSED, char **argv)
#endif
#define DEBUG 0
-int getpty(char *line, int size)
+#define DEBUG 0
+
+int getpty(char *line)
{
int p;
#if ENABLE_FEATURE_DEVPTS
bb_perror_msg("ptsname error (is /dev/pts mounted?)");
return -1;
}
- safe_strncpy(line, name, size);
+ safe_strncpy(line, name, GETPTY_BUFSIZE);
return p;
}
#else
/* Delete the char in front of the cursor, optionally saving it
* for later putback */
+#if !ENABLE_FEATURE_EDITING_VI
+static void input_delete(void)
+#define input_delete(save) input_delete()
+#else
static void input_delete(int save)
+#endif
{
int j = cursor;
fclose(fp);
} else
puts("\r\nSystem closed for routine maintenance\r");
- if (!amroot)
- exit(1);
- puts("\r\n[Disconnect bypassed -- root login allowed]\r");
+ exit(1);
}
#else
static ALWAYS_INLINE void die_if_nologin(void) {}
#include "bbconfigopts.h"
int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int bbconfig_main(int argc, char **argv)
+int bbconfig_main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
{
printf(bbconfig_config);
return 0;
//-----------------------
// do expect
//-----------------------
- size_t expect_len, buf_len = 0;
+ int expect_len;
+ size_t buf_len = 0;
size_t max_len = max_abort_len;
struct pollfd pfd;
exitcode = ERR_OK;
// expected reply received? -> goto next command
- delta = buf_len-expect_len;
+ delta = buf_len - expect_len;
if (delta >= 0 && !memcmp(buf+delta, expect, expect_len))
goto expect_done;
#undef buf
* start of some sections. this info is used by ksymoops to do better
* debugging.
*/
+#if !ENABLE_FEATURE_INSMOD_VERSION_CHECKING
+#define get_module_version(f, str) get_module_version(str)
+#endif
static int
get_module_version(struct obj_file *f, char str[STRVERSIONLEN])
{
};
int lsmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int lsmod_main(int argc, char **argv)
+int lsmod_main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
{
struct module_info info;
char *module_names, *mn, *deps, *dn;
lib-$(CONFIG_HOSTNAME) += hostname.o
lib-$(CONFIG_HTTPD) += httpd.o
lib-$(CONFIG_IFCONFIG) += ifconfig.o interface.o
-lib-$(CONFIG_IFENSLAVE) += ifenslave.o
+lib-$(CONFIG_IFENSLAVE) += ifenslave.o interface.o
lib-$(CONFIG_IFUPDOWN) += ifupdown.o
lib-$(CONFIG_INETD) += inetd.o
lib-$(CONFIG_IP) += ip.o
}
int ether_wake_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int ether_wake_main(int argc, char **argv)
+int ether_wake_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
const char *ifname = "eth0";
char *pass;
/* Try and do our best to parse more lines */
if ((STRNCASECMP(iobuf, "Content-length:") == 0)) {
/* extra read only for POST */
- if (prequest != request_GET && prequest != request_HEAD) {
+ if (prequest != request_GET
+#if ENABLE_FEATURE_HTTPD_CGI
+ && prequest != request_HEAD
+#endif
+ ) {
tptr = iobuf + sizeof("Content-length:") - 1;
if (!tptr[0])
send_headers_and_exit(HTTP_BAD_REQUEST);
*/
send_file_and_exit(tptr,
- (prequest != request_HEAD ? SEND_HEADERS_AND_BODY : SEND_HEADERS));
+#if ENABLE_FEATURE_HTTPD_CGI
+ (prequest != request_HEAD ? SEND_HEADERS_AND_BODY : SEND_HEADERS)
+#else
+ SEND_HEADERS_AND_BODY
+#endif
+ );
}
/*
};
#endif /* ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCPC */
+#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP
static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
{
-#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP
int i;
#if ENABLE_FEATURE_IFUPDOWN_IP
/* ip doesn't up iface when it configures it (unlike ifconfig) */
}
bb_error_msg("no dhcp clients found");
return 0;
+}
#elif ENABLE_APP_UDHCPC
+static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
+{
#if ENABLE_FEATURE_IFUPDOWN_IP
/* ip doesn't up iface when it configures it (unlike ifconfig) */
if (!execute("ip link set %iface% up", ifd, exec))
return execute("udhcpc -R -n -p /var/run/udhcpc.%iface%.pid "
"-i %iface%[[ -H %hostname%]][[ -c %clientid%]][[ -s %script%]]",
ifd, exec);
+}
#else
+static int dhcp_up(struct interface_defn_t *ifd ATTRIBUTE_UNUSED,
+ execfn *exec ATTRIBUTE_UNUSED)
+{
return 0; /* no dhcp support */
-#endif
}
+#endif
+#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP
static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
{
-#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP
int i;
for (i = 0; i < ARRAY_SIZE(ext_dhcp_clients); i++) {
if (exists_execable(ext_dhcp_clients[i].name))
}
bb_error_msg("no dhcp clients found, using static interface shutdown");
return static_down(ifd, exec);
+}
#elif ENABLE_APP_UDHCPC
+static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
+{
return execute("kill "
"`cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
+}
#else
+static int dhcp_down(struct interface_defn_t *ifd ATTRIBUTE_UNUSED,
+ execfn *exec ATTRIBUTE_UNUSED)
+{
return 0; /* no dhcp support */
-#endif
}
+#endif
static int manual_up_down(struct interface_defn_t *ifd ATTRIBUTE_UNUSED, execfn *exec ATTRIBUTE_UNUSED)
{
continue; /* -> check next fd in fd set */
}
- /* we are either child or didn't fork at all */
+ /* we are either child or didn't vfork at all */
#ifdef INETD_BUILTINS_ENABLED
if (sep->se_builtin) {
- if (pid) { /* "pid" is -1: we did fork */
+ if (pid) { /* "pid" is -1: we did vfork */
close(sep->se_fd); /* listening socket */
logmode = 0; /* make xwrite etc silent */
}
sep->se_builtin->bi_stream_fn(ctrl, sep);
else
sep->se_builtin->bi_dgram_fn(ctrl, sep);
- if (pid) /* we did fork */
- _exit(0);
+ if (pid) /* we did vfork */
+ _exit(1);
maybe_close(accepted_fd);
continue; /* -> check next fd in fd set */
}
xwrite(s, line, sz);
}
#else
+ /* We are after vfork here! */
static const char *const args[] = { "cat", NULL };
- /* no error messages */
+ /* move network socket to stdin */
+ xmove_fd(s, STDIN_FILENO);
+ xdup2(STDIN_FILENO, STDOUT_FILENO);
+ /* no error messages please... */
xmove_fd(xopen("/dev/null", O_WRONLY), STDERR_FILENO);
BB_EXECVP("cat", (char**)args);
- _exit(1);
+ /* on failure we return to main, which does exit(1) */
#endif
}
static void echo_dg(int s, servtab_t *sep)
while (safe_read(s, line, LINE_SIZE) > 0)
continue;
#else
+ /* We are after vfork here! */
static const char *const args[] = { "dd", "of=/dev/null", NULL };
+ /* move network socket to stdin */
+ xmove_fd(s, STDIN_FILENO);
+ xdup2(STDIN_FILENO, STDOUT_FILENO);
/* no error messages */
xmove_fd(xopen("/dev/null", O_WRONLY), STDERR_FILENO);
BB_EXECVP("dd", (char**)args);
- _exit(1);
+ /* on failure we return to main, which does exit(1) */
#endif
}
/* ARGSUSED */
* when compared to "standard" nc
*/
-static void timeout(int signum)
+static void timeout(int signum ATTRIBUTE_UNUSED)
{
bb_error_msg_and_die("timed out");
}
int rc;
// retrieve message in ./tmp/
- pop3_check(retr, (const char *)nmsg);
+ pop3_check(retr, (const char *)(ptrdiff_t)nmsg);
pop3_message(filename);
// delete message from server
if (opts & OPTF_z)
- pop3_check("DELE %u", (const char*)nmsg);
+ pop3_check("DELE %u", (const char*)(ptrdiff_t)nmsg);
// run postprocessing program
if (*fargs) {
const char *login_argv[2];
struct termios termbuf;
int fd, pid;
- char tty_name[32];
+ char tty_name[GETPTY_BUFSIZE];
struct tsession *ts = xzalloc(sizeof(struct tsession) + BUFSIZE * 2);
/*ts->buf1 = (char *)(ts + 1);*/
/*ts->buf2 = ts->buf1 + BUFSIZE;*/
/* Got a new connection, set up a tty. */
- fd = getpty(tty_name, 32);
+ fd = getpty(tty_name);
if (fd < 0) {
bb_error_msg("can't create pty");
return NULL;
}
#endif
+#if !ENABLE_FEATURE_TRACEROUTE_VERBOSE
+#define packet_ok(buf, cc, from, seq) \
+ packet_ok(buf, cc, seq)
+#endif
static int
packet_ok(unsigned char *buf, int cc, struct sockaddr_in *from, int seq)
{
BPF_STMT(BPF_LD|BPF_W|BPF_IND, 0),
BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, SERVER_AND_CLIENT_PORTS, 0, 1), /* L3, L4 */
/* returns */
- BPF_STMT(BPF_RET|BPF_K, ~0UL), /* L3: pass */
+ BPF_STMT(BPF_RET|BPF_K, (~(uint32_t)0) ), /* L3: pass */
BPF_STMT(BPF_RET|BPF_K, 0), /* L4: reject */
};
static const struct sock_fprog filter_prog = {
*/
#else /* FEATURE_WGET_STATUSBAR */
-static ALWAYS_INLINE void progressmeter(int flag) { }
+static ALWAYS_INLINE void progressmeter(int flag ATTRIBUTE_UNUSED) { }
#endif
int ps_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int ps_main(int argc, char **argv)
+int ps_main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
{
procps_status_t *p = NULL;
int len;
static smallint job_warning; /* user was warned about stopped jobs (can be 2, 1 or 0). */
static struct job *makejob(/*union node *,*/ int);
+#if !JOBS
+#define forkshell(job, node, mode) forkshell(job, mode)
+#endif
static int forkshell(struct job *, union node *, int);
static int waitforjob(struct job *);
/*
* Convert a job name to a job structure.
*/
+#if !JOBS
+#define getjob(name, getctl) getjob(name)
+#endif
static struct job *
getjob(const char *name, int getctl)
{
}
/* Called after fork(), in parent */
+#if !JOBS
+#define forkparent(jp, n, mode, pid) forkparent(jp, mode, pid)
+#endif
static void
forkparent(struct job *jp, union node *n, int mode, pid_t pid)
{
char *buf = parsefile->buf;
parsenextc = buf;
- retry:
#if ENABLE_FEATURE_EDITING
+ retry:
if (!iflag || parsefile->fd)
nr = nonblock_safe_read(parsefile->fd, buf, BUFSIZ - 1);
else {
* Push a string back onto the input at this current parsefile level.
* We handle aliases this way.
*/
+#if !ENABLE_ASH_ALIAS
+#define pushstring(s, ap) pushstring(s)
+#endif
static void
-pushstring(char *s, void *ap)
+pushstring(char *s, struct alias *ap)
{
struct strpush *sp;
size_t len;
sp->prevstring = parsenextc;
sp->prevnleft = parsenleft;
#if ENABLE_ASH_ALIAS
- sp->ap = (struct alias *)ap;
+ sp->ap = ap;
if (ap) {
- ((struct alias *)ap)->flag |= ALIASINUSE;
+ ap->flag |= ALIASINUSE;
sp->string = s;
}
#endif
};
int cttyhack_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int cttyhack_main(int argc, char **argv)
+int cttyhack_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
int fd;
char console[sizeof(int)*3 + 16];
};
#endif
+#if ENABLE_FEATURE_FBSET_READMODE
static int readmode(struct fb_var_screeninfo *base, const char *fn,
const char *mode)
{
-#if ENABLE_FEATURE_FBSET_READMODE
FILE *f;
char buf[256];
char *p = buf;
return 1;
}
}
-#else
- bb_error_msg("mode reading not compiled in");
-#endif
return 0;
}
+#endif
static inline void setmode(struct fb_var_screeninfo *base,
struct fb_var_screeninfo *set)
fh = xopen(fbdev, O_RDONLY);
xioctl(fh, FBIOGET_VSCREENINFO, &var);
if (g_options & OPT_READMODE) {
+#if !ENABLE_FEATURE_FBSET_READMODE
+ bb_show_usage();
+#else
if (!readmode(&var, modefile, mode)) {
bb_error_msg_and_die("unknown video mode '%s'", mode);
}
+#endif
}
setmode(&var, &varset);
#endif
static const char *partition_type(unsigned char type);
static void get_geometry(void);
+#if ENABLE_FEATURE_SUN_LABEL || ENABLE_FEATURE_FDISK_WRITABLE
static int get_boot(enum action what);
+#else
+static int get_boot(void);
+#endif
#define PLURAL 0
#define SINGULAR 1
* 0: found or created label
* 1: I/O error
*/
-static int
-get_boot(enum action what)
+#if ENABLE_FEATURE_SUN_LABEL || ENABLE_FEATURE_FDISK_WRITABLE
+static int get_boot(enum action what)
+#else
+static int get_boot(void)
+#define get_boot(what) get_boot()
+#endif
{
int i;
int attr_ok; /* NB: 0: ok */
int winsz_ok;
int pty;
- char pty_line[32];
+ char pty_line[GETPTY_BUFSIZE];
struct termios tt, rtt;
struct winsize win;
const char *fname = "typescript";
shell = DEFAULT_SHELL;
}
- pty = getpty(pty_line, sizeof(pty_line));
+ pty = getpty(pty_line);
if (pty < 0) {
bb_perror_msg_and_die("can't get pty");
}
} *uuidCache;
/* for now, only ext2, ext3 and xfs are supported */
+#if !ENABLE_FEATURE_VOLUMEID_ISO9660
+#define get_label_uuid(device, label, uuid, iso_only) \
+ get_label_uuid(device, label, uuid)
+#endif
static int
get_label_uuid(const char *device, char **label, char **uuid, int iso_only)
{
memcpy(last->uuid, uuid, sizeof(last->uuid));
}
+#if !ENABLE_FEATURE_VOLUMEID_ISO9660
+#define uuidcache_check_device(device_name, ma, mi, iso_only) \
+ uuidcache_check_device(device_name, ma, mi)
+#endif
static void
uuidcache_check_device(const char *device_name, int ma, int mi, int iso_only)
{