/* This structure defines protocol families and their handlers. */
struct aftype {
- char *name;
- char *title;
+ const char *name;
+ const char *title;
int af;
int alen;
char *(*print) (unsigned char *);
/* This structure defines hardware protocols and their handlers. */
struct hwtype {
- char *name;
- char *title;
+ const char *name;
+ const char *title;
int type;
int alen;
char *(*print) (unsigned char *);
struct mod_list_t { /* two-way list of modules to process */
/* a module description */
- char * m_name;
- char * m_path;
- struct mod_opt_t * m_options;
+ const char * m_name;
+ char * m_path;
+ struct mod_opt_t * m_options;
struct mod_list_t * m_prev;
struct mod_list_t * m_next;
return ret;
}
-static int mod_process(struct mod_list_t *list, int do_insert)
+static int mod_process(const struct mod_list_t *list, int do_insert)
{
int rc = 0;
char **argv = NULL;
argv = xmalloc(6 * sizeof(char*));
if (do_insert) {
if (already_loaded(list->m_name) != 1) {
- argv[argc++] = "insmod";
+ argv[argc++] = (char*)"insmod";
if (ENABLE_FEATURE_2_4_MODULES) {
if (do_syslog)
- argv[argc++] = "-s";
+ argv[argc++] = (char*)"-s";
if (autoclean)
- argv[argc++] = "-k";
+ argv[argc++] = (char*)"-k";
if (quiet)
- argv[argc++] = "-q";
+ argv[argc++] = (char*)"-q";
else if (verbose) /* verbose and quiet are mutually exclusive */
- argv[argc++] = "-v";
+ argv[argc++] = (char*)"-v";
}
argv[argc++] = list->m_path;
if (ENABLE_FEATURE_CLEAN_UP)
} else {
/* modutils uses short name for removal */
if (already_loaded(list->m_name) != 0) {
- argv[argc++] = "rmmod";
+ argv[argc++] = (char*)"rmmod";
if (do_syslog)
- argv[argc++] = "-s";
- argv[argc++] = list->m_name;
+ argv[argc++] = (char*)"-s";
+ argv[argc++] = (char*)list->m_name;
if (ENABLE_FEATURE_CLEAN_UP)
argc_malloc = argc;
}
static int mod_insert(char *mod, int argc, char **argv)
{
- struct mod_list_t *tail = 0;
- struct mod_list_t *head = 0;
+ struct mod_list_t *tail = NULL;
+ struct mod_list_t *head = NULL;
int rc;
// get dep list for module mod
check_dep(mod, &head, &tail);
+ rc = 1;
if (head && tail) {
if (argc) {
int i;
}
// process tail ---> head
- if ((rc = mod_process(tail, 1)) != 0) {
+ rc = mod_process(tail, 1);
+ if (rc) {
/*
* In case of using udev, multiple instances of modprobe can be
* spawned to load the same module (think of two same usb devices,
rc = 0;
}
}
- else
- rc = 1;
-
return rc;
}
static int mod_remove(char *mod)
{
int rc;
- static struct mod_list_t rm_a_dummy = { "-a", NULL, NULL, NULL, NULL };
+ static const struct mod_list_t rm_a_dummy = { "-a", NULL, NULL, NULL, NULL };
- struct mod_list_t *head = 0;
- struct mod_list_t *tail = 0;
+ struct mod_list_t *head = NULL;
+ struct mod_list_t *tail = NULL;
if (mod)
check_dep(mod, &head, &tail);
else // autoclean
- head = tail = &rm_a_dummy;
+ head = tail = (struct mod_list_t*) &rm_a_dummy;
+ rc = 1;
if (head && tail)
rc = mod_process(head, 0); // process head ---> tail
- else
- rc = 1;
return rc;
-
}
int modprobe_main(int argc, char** argv)
* (default AF was wrong)
*/
-#include "inet_common.h"
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
#include <net/if.h>
#include <net/if_arp.h>
+#include "inet_common.h"
#include "busybox.h"
#ifdef CONFIG_FEATURE_IPV6
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
return safe_strncpy(buff, "[NONE SET]", sizeof(buff));
- if (INET6_rresolve
- (buff, sizeof(buff), (struct sockaddr_in6 *) sap, numeric) != 0)
+ if (INET6_rresolve(buff, sizeof(buff), (struct sockaddr_in6 *) sap, numeric))
return safe_strncpy(buff, "[UNKNOWN]", sizeof(buff));
return buff;
}
static int do_if_fetch(struct interface *ife)
{
if (if_fetch(ife) < 0) {
- char *errmsg;
+ const char *errmsg;
if (errno == ENODEV) {
/* Give better error message for this case. */
#define __PF(f,n) { ETH_P_##f, #n },
static struct {
int id;
- char *name;
+ const char *name;
} llproto_names[] = {
__PF(LOOP,loop)
__PF(PUP,pup)
#include <stdlib.h>
#include <string.h>
-
#include "rt_names.h"
#include "utils.h"
-char *rtnl_rtntype_n2a(int id, char *buf, int len)
+const char *rtnl_rtntype_n2a(int id, char *buf, int len)
{
switch (id) {
case RTN_UNSPEC:
#ifndef __RTM_MAP_H__
#define __RTM_MAP_H__ 1
-char *rtnl_rtntype_n2a(int id, char *buf, int len);
+const char *rtnl_rtntype_n2a(int id, char *buf, int len);
int rtnl_rtntype_a2n(int *id, char *arg);
int get_rt_realms(uint32_t *realms, char *arg);
#include "runit_lib.h"
static char *action;
-static char *acts;
-static char *varservice = "/var/service/";
+static const char *acts;
+static const char *varservice = "/var/service/";
static char **service;
static char **servicex;
static unsigned services;
-static unsigned rc = 0;
-static unsigned verbose = 0;
+static unsigned rc;
+static unsigned verbose;
static unsigned long waitsec = 7;
-static unsigned kll = 0;
+static unsigned kll;
static struct taia tstart, tnow, tdiff;
static struct tai tstatus;
-static int (*act)(char*) = 0;
-static int (*cbk)(char*) = 0;
+static int (*act)(const char*);
+static int (*cbk)(const char*);
static int curdir, fd, r;
static char svstatus[20];
#define usage() bb_show_usage()
-static void fatal_cannot(char *m1)
+static void fatal_cannot(const char *m1)
{
bb_perror_msg("fatal: cannot %s", m1);
_exit(151);
}
-static void out(char *p, char *m1)
+static void out(const char *p, const char *m1)
{
printf("%s%s: %s", p, *service, m1);
if (errno) {
#define TIMEOUT "timeout: "
#define KILL "kill: "
-static void fail(char *m1) { ++rc; out(FAIL, m1); }
-static void failx(char *m1) { errno = 0; fail(m1); }
-static void warn_cannot(char *m1) { ++rc; out("warning: cannot ", m1); }
-static void warnx_cannot(char *m1) { errno = 0; warn_cannot(m1); }
-static void ok(char *m1) { errno = 0; out(OK, m1); }
+static void fail(const char *m1) { ++rc; out(FAIL, m1); }
+static void failx(const char *m1) { errno = 0; fail(m1); }
+static void warn_cannot(const char *m1) { ++rc; out("warning: cannot ", m1); }
+static void warnx_cannot(const char *m1) { errno = 0; warn_cannot(m1); }
+static void ok(const char *m1) { errno = 0; out(OK, m1); }
static int svstatus_get(void)
{
- if ((fd = open_write("supervise/ok")) == -1) {
+ fd = open_write("supervise/ok");
+ if (fd == -1) {
if (errno == ENODEV) {
*acts == 'x' ? ok("runsv not running")
: failx("runsv not running");
return -1;
}
close(fd);
- if ((fd = open_read("supervise/status")) == -1) {
+ fd = open_read("supervise/status");
+ if (fd == -1) {
warn_cannot("open supervise/status");
return -1;
}
return 1;
}
-static unsigned svstatus_print(char *m)
+static unsigned svstatus_print(const char *m)
{
int pid;
int normallyup = 0;
return pid ? 1 : 2;
}
-static int status(char *unused)
+static int status(const char *unused)
{
r = svstatus_get();
switch (r) { case -1: case 0: return 0; }
return 0;
}
if (!pid) {
- prog[0] = "./check";
- prog[1] = 0;
+ prog[0] = (char*)"./check";
+ prog[1] = NULL;
close(1);
execve("check", prog, environ);
bb_perror_msg(WARN"cannot run %s/check", *service);
return !wait_exitcode(w);
}
-static int check(char *a)
+static int check(const char *a)
{
unsigned pid;
if ((!pid && tstart.sec.x > tstatus.x) || (pid && svstatus[17] != 'd'))
return 0;
}
- printf(OK); svstatus_print(*service); puts(""); /* will also flush the output */
+ printf(OK);
+ svstatus_print(*service);
+ puts(""); /* will also flush the output */
return 1;
}
-static int control(char *a)
+static int control(const char *a)
{
if (svstatus_get() <= 0) return -1;
if (svstatus[17] == *a) return 0;
- if ((fd = open_write("supervise/control")) == -1) {
+ fd = open_write("supervise/control");
+ if (fd == -1) {
if (errno != ENODEV)
warn_cannot("open supervise/control");
else
if (opt & 4) usage();
if (!(action = *argv++)) usage();
--argc;
- service = argv; services = argc;
+ service = argv;
+ services = argc;
if (!*service) usage();
- taia_now(&tnow); tstart = tnow;
- if ((curdir = open_read(".")) == -1)
+ taia_now(&tnow);
+ tstart = tnow;
+ curdir = open_read(".");
+ if (curdir == -1)
fatal_cannot("open current directory");
- act = &control; acts = "s";
- if (verbose) cbk = ✓
+ act = &control;
+ acts = "s";
+ if (verbose)
+ cbk = ✓
switch (*action) {
case 'x': case 'e':
acts = "x"; break;
cbk = ✓
break;
}
- act = &status; cbk = 0; break;
+ act = &status;
+ cbk = NULL;
+ break;
case 'r':
if (!str_diff(action, "restart")) {
acts = "tcu";