summaryrefslogtreecommitdiff
path: root/i/pc104/initrd/conf/busybox/debianutils
diff options
context:
space:
mode:
Diffstat (limited to 'i/pc104/initrd/conf/busybox/debianutils')
-rw-r--r--i/pc104/initrd/conf/busybox/debianutils/Config.in88
-rw-r--r--i/pc104/initrd/conf/busybox/debianutils/Kbuild13
-rw-r--r--i/pc104/initrd/conf/busybox/debianutils/mktemp.c49
-rw-r--r--i/pc104/initrd/conf/busybox/debianutils/pipe_progress.c43
-rw-r--r--i/pc104/initrd/conf/busybox/debianutils/readlink.c52
-rw-r--r--i/pc104/initrd/conf/busybox/debianutils/run_parts.c192
-rw-r--r--i/pc104/initrd/conf/busybox/debianutils/start_stop_daemon.c330
-rw-r--r--i/pc104/initrd/conf/busybox/debianutils/which.c48
8 files changed, 815 insertions, 0 deletions
diff --git a/i/pc104/initrd/conf/busybox/debianutils/Config.in b/i/pc104/initrd/conf/busybox/debianutils/Config.in
new file mode 100644
index 0000000..3d85999
--- /dev/null
+++ b/i/pc104/initrd/conf/busybox/debianutils/Config.in
@@ -0,0 +1,88 @@
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Debian Utilities"
+
+config MKTEMP
+ bool "mktemp"
+ default n
+ help
+ mktemp is used to create unique temporary files
+
+config PIPE_PROGRESS
+ bool "pipe_progress"
+ default n
+ help
+ Display a dot to indicate pipe activity.
+
+config READLINK
+ bool "readlink"
+ default n
+ help
+ This program reads a symbolic link and returns the name
+ of the file it points to
+
+config FEATURE_READLINK_FOLLOW
+ bool "Enable canonicalization by following all symlinks (-f)"
+ default n
+ depends on READLINK
+ help
+ Enable the readlink option (-f).
+
+config RUN_PARTS
+ bool "run-parts"
+ default n
+ help
+ run-parts is a utility designed to run all the scripts in a directory.
+
+ It is useful to set up a directory like cron.daily, where you need to
+ execute all the scripts in that directory.
+
+ In this implementation of run-parts some features (such as report mode)
+ are not implemented.
+
+ Unless you know that run-parts is used in some of your scripts
+ you can safely say N here.
+
+config FEATURE_RUN_PARTS_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on RUN_PARTS && GETOPT_LONG
+ help
+ Support long options for the run-parts applet.
+
+config START_STOP_DAEMON
+ bool "start-stop-daemon"
+ default y
+ help
+ start-stop-daemon is used to control the creation and
+ termination of system-level processes, usually the ones
+ started during the startup of the system.
+
+config FEATURE_START_STOP_DAEMON_FANCY
+ bool "Support additional arguments"
+ default y
+ depends on START_STOP_DAEMON
+ help
+ Support additional arguments.
+ -o|--oknodo ignored since we exit with 0 anyway
+ -v|--verbose
+
+config FEATURE_START_STOP_DAEMON_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on START_STOP_DAEMON && GETOPT_LONG
+ help
+ Support long options for the start-stop-daemon applet.
+
+config WHICH
+ bool "which"
+ default n
+ help
+ which is used to find programs in your PATH and
+ print out their pathnames.
+
+endmenu
+
diff --git a/i/pc104/initrd/conf/busybox/debianutils/Kbuild b/i/pc104/initrd/conf/busybox/debianutils/Kbuild
new file mode 100644
index 0000000..99df6a5
--- /dev/null
+++ b/i/pc104/initrd/conf/busybox/debianutils/Kbuild
@@ -0,0 +1,13 @@
+# Makefile for busybox
+#
+# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
+#
+# Licensed under the GPL v2, see the file LICENSE in this tarball.
+
+lib-y:=
+lib-$(CONFIG_MKTEMP) += mktemp.o
+lib-$(CONFIG_PIPE_PROGRESS) += pipe_progress.o
+lib-$(CONFIG_READLINK) += readlink.o
+lib-$(CONFIG_RUN_PARTS) += run_parts.o
+lib-$(CONFIG_START_STOP_DAEMON) += start_stop_daemon.o
+lib-$(CONFIG_WHICH) += which.o
diff --git a/i/pc104/initrd/conf/busybox/debianutils/mktemp.c b/i/pc104/initrd/conf/busybox/debianutils/mktemp.c
new file mode 100644
index 0000000..ce5bda5
--- /dev/null
+++ b/i/pc104/initrd/conf/busybox/debianutils/mktemp.c
@@ -0,0 +1,49 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Mini mktemp implementation for busybox
+ *
+ *
+ * Copyright (C) 2000 by Daniel Jacobowitz
+ * Written by Daniel Jacobowitz <dan@debian.org>
+ *
+ * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
+ */
+
+#include "busybox.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)
+{
+ unsigned long flags = getopt32(argc, argv, "dqt");
+ char *chp;
+
+ if (optind + 1 != argc)
+ bb_show_usage();
+
+ chp = argv[optind];
+
+ if (flags & 4) {
+ char *dir = getenv("TMPDIR");
+ if (dir && *dir != '\0')
+ chp = concat_path_file(dir, chp);
+ else
+ chp = concat_path_file("/tmp/", chp);
+ }
+
+ if (flags & 1) {
+ if (mkdtemp(chp) == NULL)
+ return EXIT_FAILURE;
+ } else {
+ if (mkstemp(chp) < 0)
+ return EXIT_FAILURE;
+ }
+
+ puts(chp);
+
+ return EXIT_SUCCESS;
+}
diff --git a/i/pc104/initrd/conf/busybox/debianutils/pipe_progress.c b/i/pc104/initrd/conf/busybox/debianutils/pipe_progress.c
new file mode 100644
index 0000000..51a017c
--- /dev/null
+++ b/i/pc104/initrd/conf/busybox/debianutils/pipe_progress.c
@@ -0,0 +1,43 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Monitor a pipe with a simple progress display.
+ *
+ * Copyright (C) 2003 by Rob Landley <rob@landley.net>, Joey Hess
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ */
+
+#include "busybox.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+
+#define PIPE_PROGRESS_SIZE 4096
+
+/* Read a block of data from stdin, write it to stdout.
+ * Activity is indicated by a '.' to stderr
+ */
+int pipe_progress_main(int argc, char **argv);
+int pipe_progress_main(int argc, char **argv)
+{
+ RESERVE_CONFIG_BUFFER(buf, PIPE_PROGRESS_SIZE);
+ time_t t = time(NULL);
+ size_t len;
+
+ while ((len = fread(buf, 1, PIPE_PROGRESS_SIZE, stdin)) > 0) {
+ time_t new_time = time(NULL);
+ if (new_time != t) {
+ t = new_time;
+ fputc('.', stderr);
+ }
+ fwrite(buf, len, 1, stdout);
+ }
+
+ fputc('\n', stderr);
+
+ if (ENABLE_FEATURE_CLEAN_UP)
+ RELEASE_CONFIG_BUFFER(buf);
+
+ return 0;
+}
diff --git a/i/pc104/initrd/conf/busybox/debianutils/readlink.c b/i/pc104/initrd/conf/busybox/debianutils/readlink.c
new file mode 100644
index 0000000..1a2c1ef
--- /dev/null
+++ b/i/pc104/initrd/conf/busybox/debianutils/readlink.c
@@ -0,0 +1,52 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Mini readlink implementation for busybox
+ *
+ * Copyright (C) 2000,2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>
+ *
+ * Licensed under GPL v2 or later, see file LICENSE in this tarball for details.
+ */
+
+#include "busybox.h"
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <getopt.h>
+
+int readlink_main(int argc, char **argv);
+int readlink_main(int argc, char **argv)
+{
+ char *buf;
+ char *fname;
+
+ USE_FEATURE_READLINK_FOLLOW(
+ unsigned opt;
+ /* We need exactly one non-option argument. */
+ opt_complementary = "=1";
+ opt = getopt32(argc, argv, "f");
+ fname = argv[optind];
+ )
+ SKIP_FEATURE_READLINK_FOLLOW(
+ const unsigned opt = 0;
+ if (argc != 2) bb_show_usage();
+ fname = argv[1];
+ )
+
+ /* compat: coreutils readlink reports errors silently via exit code */
+ logmode = LOGMODE_NONE;
+
+ if (opt) {
+ buf = realpath(fname, bb_common_bufsiz1);
+ } else {
+ buf = xmalloc_readlink_or_warn(fname);
+ }
+
+ if (!buf)
+ return EXIT_FAILURE;
+ puts(buf);
+
+ if (ENABLE_FEATURE_CLEAN_UP && buf != bb_common_bufsiz1)
+ free(buf);
+
+ fflush_stdout_and_exit(EXIT_SUCCESS);
+}
diff --git a/i/pc104/initrd/conf/busybox/debianutils/run_parts.c b/i/pc104/initrd/conf/busybox/debianutils/run_parts.c
new file mode 100644
index 0000000..a864a05
--- /dev/null
+++ b/i/pc104/initrd/conf/busybox/debianutils/run_parts.c
@@ -0,0 +1,192 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Mini run-parts implementation for busybox
+ *
+ *
+ * Copyright (C) 2001 by Emanuele Aina <emanuele.aina@tiscali.it>
+ *
+ * Based on the Debian run-parts program, version 1.15
+ * Copyright (C) 1996 Jeff Noxon <jeff@router.patch.net>,
+ * Copyright (C) 1996-1999 Guy Maor <maor@debian.org>
+ *
+ *
+ * Licensed under GPL v2 or later, see file LICENSE in this tarball for details.
+ */
+
+/* This is my first attempt to write a program in C (well, this is my first
+ * attempt to write a program! :-) . */
+
+/* This piece of code is heavily based on the original version of run-parts,
+ * taken from debian-utils. I've only removed the long options and a the
+ * report mode. As the original run-parts support only long options, I've
+ * broken compatibility because the BusyBox policy doesn't allow them.
+ * The supported options are:
+ * -t test. Print the name of the files to be executed, without
+ * execute them.
+ * -a ARG argument. Pass ARG as an argument the program executed. It can
+ * be repeated to pass multiple arguments.
+ * -u MASK umask. Set the umask of the program executed to MASK. */
+
+/* TODO
+ * done - convert calls to error in perror... and remove error()
+ * done - convert malloc/realloc to their x... counterparts
+ * done - remove catch_sigchld
+ * done - use bb's concat_path_file()
+ * done - declare run_parts_main() as extern and any other function as static?
+ */
+
+#include "busybox.h"
+#include <getopt.h>
+
+static const struct option runparts_long_options[] = {
+ { "test", 0, NULL, 't' },
+ { "umask", 1, NULL, 'u' },
+ { "arg", 1, NULL, 'a' },
+ { 0, 0, 0, 0 }
+};
+
+/* valid_name */
+/* True or false? Is this a valid filename (upper/lower alpha, digits,
+ * underscores, and hyphens only?)
+ */
+static int valid_name(const struct dirent *d)
+{
+ const char *c = d->d_name;
+
+ while (*c) {
+ if (!isalnum(*c) && (*c != '_') && (*c != '-')) {
+ return 0;
+ }
+ ++c;
+ }
+ return 1;
+}
+
+/* test mode = 1 is the same as official run_parts
+ * test_mode = 2 means to fail silently on missing directories
+ */
+static int run_parts(char **args, const unsigned char test_mode)
+{
+ struct dirent **namelist = 0;
+ struct stat st;
+ char *filename;
+ char *arg0 = args[0];
+ int entries;
+ int i;
+ int exitstatus = 0;
+
+#if __GNUC__
+ /* Avoid longjmp clobbering */
+ (void) &i;
+ (void) &exitstatus;
+#endif
+ /* scandir() isn't POSIX, but it makes things easy. */
+ entries = scandir(arg0, &namelist, valid_name, alphasort);
+
+ if (entries == -1) {
+ if (test_mode & 2) {
+ return 2;
+ }
+ bb_perror_msg_and_die("cannot open '%s'", arg0);
+ }
+
+ for (i = 0; i < entries; i++) {
+ filename = concat_path_file(arg0, namelist[i]->d_name);
+
+ xstat(filename, &st);
+ if (S_ISREG(st.st_mode) && !access(filename, X_OK)) {
+ if (test_mode) {
+ puts(filename);
+ } else {
+ /* exec_errno is common vfork variable */
+ volatile int exec_errno = 0;
+ int result;
+ int pid;
+
+ if ((pid = vfork()) < 0) {
+ bb_perror_msg_and_die("failed to fork");
+ } else if (!pid) {
+ args[0] = filename;
+ execve(filename, args, environ);
+ exec_errno = errno;
+ _exit(1);
+ }
+
+ waitpid(pid, &result, 0);
+ if (exec_errno) {
+ errno = exec_errno;
+ bb_perror_msg("failed to exec %s", filename);
+ exitstatus = 1;
+ }
+ if (WIFEXITED(result) && WEXITSTATUS(result)) {
+ bb_perror_msg("%s exited with return code %d", filename, WEXITSTATUS(result));
+ exitstatus = 1;
+ } else if (WIFSIGNALED(result)) {
+ bb_perror_msg("%s exited because of uncaught signal %d", filename, WTERMSIG(result));
+ exitstatus = 1;
+ }
+ }
+ } else if (!S_ISDIR(st.st_mode)) {
+ bb_error_msg("component %s is not an executable plain file", filename);
+ exitstatus = 1;
+ }
+
+ free(namelist[i]);
+ free(filename);
+ }
+ free(namelist);
+
+ return exitstatus;
+}
+
+
+/* run_parts_main */
+/* Process options */
+int run_parts_main(int argc, char **argv);
+int run_parts_main(int argc, char **argv)
+{
+ char **args = xmalloc(2 * sizeof(char *));
+ unsigned char test_mode = 0;
+ unsigned short argcount = 1;
+ int opt;
+
+ umask(022);
+
+ while ((opt = getopt_long(argc, argv, "tu:a:",
+ runparts_long_options, NULL)) > 0)
+ {
+ switch (opt) {
+ /* Enable test mode */
+ case 't':
+ test_mode++;
+ break;
+ /* Set the umask of the programs executed */
+ case 'u':
+ /* Check and set the umask of the program executed. As stated in the original
+ * run-parts, the octal conversion in libc is not foolproof; it will take the
+ * 8 and 9 digits under some circumstances. We'll just have to live with it.
+ */
+ umask(xstrtoul_range(optarg, 8, 0, 07777));
+ break;
+ /* Pass an argument to the programs */
+ case 'a':
+ /* Add an argument to the commands that we will call.
+ * Called once for every argument. */
+ args = xrealloc(args, (argcount + 2) * (sizeof(char *)));
+ args[argcount++] = optarg;
+ break;
+ default:
+ bb_show_usage();
+ }
+ }
+
+ /* We require exactly one argument: the directory name */
+ if (optind != (argc - 1)) {
+ bb_show_usage();
+ }
+
+ args[0] = argv[optind];
+ args[argcount] = 0;
+
+ return run_parts(args, test_mode);
+}
diff --git a/i/pc104/initrd/conf/busybox/debianutils/start_stop_daemon.c b/i/pc104/initrd/conf/busybox/debianutils/start_stop_daemon.c
new file mode 100644
index 0000000..1862f11
--- /dev/null
+++ b/i/pc104/initrd/conf/busybox/debianutils/start_stop_daemon.c
@@ -0,0 +1,330 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Mini start-stop-daemon implementation(s) for busybox
+ *
+ * Written by Marek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl>,
+ * Adapted for busybox David Kimdon <dwhedon@gordian.com>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ */
+
+#include "busybox.h"
+#include <getopt.h>
+#include <sys/resource.h>
+
+static int signal_nr = 15;
+static int user_id = -1;
+static char *userspec;
+static char *cmdname;
+static char *execname;
+static char *pidfile;
+static smallint quiet;
+
+struct pid_list {
+ struct pid_list *next;
+ pid_t pid;
+};
+
+static struct pid_list *found;
+
+static inline void push(pid_t pid)
+{
+ struct pid_list *p;
+
+ p = xmalloc(sizeof(*p));
+ p->next = found;
+ p->pid = pid;
+ found = p;
+}
+
+static int pid_is_exec(pid_t pid, const char *name)
+{
+ char buf[sizeof("/proc//exe") + sizeof(int)*3];
+ char *execbuf;
+ int sz;
+ int equal;
+
+ sprintf(buf, "/proc/%d/exe", pid);
+ sz = strlen(name) + 1;
+ execbuf = xzalloc(sz);
+ readlink(buf, execbuf, sz);
+
+ /* if readlink fails, execbuf still contains "" */
+ equal = !strcmp(execbuf, name);
+ if (ENABLE_FEATURE_CLEAN_UP)
+ free(execbuf);
+ return equal;
+}
+
+static int pid_is_user(int pid, int uid)
+{
+ struct stat sb;
+ char buf[sizeof("/proc/") + sizeof(int)*3];
+
+ sprintf(buf, "/proc/%u", pid);
+ if (stat(buf, &sb) != 0)
+ return 0;
+ return (sb.st_uid == uid);
+}
+
+static int pid_is_cmd(pid_t pid, const char *name)
+{
+ char fname[sizeof("/proc//stat") + sizeof(int)*3];
+ char *buf;
+ int r = 0;
+
+ sprintf(fname, "/proc/%u/stat", pid);
+ buf = xmalloc_open_read_close(fname, NULL);
+ if (buf) {
+ char *p = strchr(buf, '(');
+ if (p) {
+ char *pe = strrchr(++p, ')');
+ if (pe) {
+ *pe = '\0';
+ r = !strcmp(p, name);
+ }
+ }
+ free(buf);
+ }
+ return r;
+}
+
+
+static void check(int pid)
+{
+ if (execname && !pid_is_exec(pid, execname)) {
+ return;
+ }
+ if (userspec && !pid_is_user(pid, user_id)) {
+ return;
+ }
+ if (cmdname && !pid_is_cmd(pid, cmdname)) {
+ return;
+ }
+ push(pid);
+}
+
+
+static void do_pidfile(void)
+{
+ FILE *f;
+ pid_t pid;
+
+ f = fopen(pidfile, "r");
+ if (f) {
+ if (fscanf(f, "%u", &pid) == 1)
+ check(pid);
+ fclose(f);
+ } else if (errno != ENOENT)
+ bb_perror_msg_and_die("open pidfile %s", pidfile);
+}
+
+static void do_procinit(void)
+{
+ DIR *procdir;
+ struct dirent *entry;
+ int foundany, pid;
+
+ if (pidfile) {
+ do_pidfile();
+ return;
+ }
+
+ procdir = xopendir("/proc");
+
+ foundany = 0;
+ while ((entry = readdir(procdir)) != NULL) {
+ pid = bb_strtou(entry->d_name, NULL, 10);
+ if (errno)
+ continue;
+ foundany++;
+ check(pid);
+ }
+ closedir(procdir);
+ if (!foundany)
+ bb_error_msg_and_die ("nothing in /proc - not mounted?");
+}
+
+
+static int do_stop(void)
+{
+ char *what;
+ struct pid_list *p;
+ int killed = 0;
+
+ do_procinit();
+
+ if (cmdname)
+ what = xstrdup(cmdname);
+ else if (execname)
+ what = xstrdup(execname);
+ else if (pidfile)
+ what = xasprintf("process in pidfile '%s'", pidfile);
+ else if (userspec)
+ what = xasprintf("process(es) owned by '%s'", userspec);
+ else
+ bb_error_msg_and_die("internal error, please report");
+
+ if (!found) {
+ if (!quiet)
+ printf("no %s found; none killed\n", what);
+ if (ENABLE_FEATURE_CLEAN_UP)
+ free(what);
+ return -1;
+ }
+ for (p = found; p; p = p->next) {
+ if (kill(p->pid, signal_nr) == 0) {
+ p->pid = -p->pid;
+ killed++;
+ } else {
+ bb_perror_msg("warning: failed to kill %d", p->pid);
+ }
+ }
+ if (!quiet && killed) {
+ printf("stopped %s (pid", what);
+ for (p = found; p; p = p->next)
+ if(p->pid < 0)
+ printf(" %d", -p->pid);
+ puts(")");
+ }
+ if (ENABLE_FEATURE_CLEAN_UP)
+ free(what);
+ return killed;
+}
+
+#if ENABLE_FEATURE_START_STOP_DAEMON_LONG_OPTIONS
+static const struct option long_options[] = {
+ { "stop", 0, NULL, 'K' },
+ { "start", 0, NULL, 'S' },
+ { "background", 0, NULL, 'b' },
+ { "quiet", 0, NULL, 'q' },
+ { "make-pidfile", 0, NULL, 'm' },
+#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
+ { "oknodo", 0, NULL, 'o' },
+ { "verbose", 0, NULL, 'v' },
+ { "nicelevel", 1, NULL, 'N' },
+#endif
+ { "startas", 1, NULL, 'a' },
+ { "name", 1, NULL, 'n' },
+ { "signal", 1, NULL, 's' },
+ { "user", 1, NULL, 'u' },
+ { "chuid", 1, NULL, 'c' },
+ { "exec", 1, NULL, 'x' },
+ { "pidfile", 1, NULL, 'p' },
+#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
+ { "retry", 1, NULL, 'R' },
+#endif
+ { 0, 0, 0, 0 }
+};
+#endif
+
+enum {
+ CTX_STOP = 0x1,
+ CTX_START = 0x2,
+ OPT_BACKGROUND = 0x4, // -b
+ OPT_QUIET = 0x8, // -q
+ OPT_MAKEPID = 0x10, // -m
+ OPT_a = 0x20, // -a
+ OPT_n = 0x40, // -n
+ OPT_s = 0x80, // -s
+ OPT_u = 0x100, // -u
+ OPT_c = 0x200, // -c
+ OPT_x = 0x400, // -x
+ OPT_p = 0x800, // -p
+ OPT_OKNODO = 0x1000 * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -o
+ OPT_VERBOSE = 0x2000 * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -v
+ OPT_NICELEVEL = 0x4000 * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -N
+};
+
+int start_stop_daemon_main(int argc, char **argv);
+int start_stop_daemon_main(int argc, char **argv)
+{
+ unsigned opt;
+ char *signame;
+ char *startas;
+ char *chuid;
+#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
+// char *retry_arg = NULL;
+// int retries = -1;
+ char *opt_N;
+#endif
+#if ENABLE_FEATURE_START_STOP_DAEMON_LONG_OPTIONS
+ applet_long_options = long_options;
+#endif
+
+ /* Check required one context option was given */
+ opt_complementary = "K:S:?:K--S:S--K:m?p:K?xpun:S?xa";
+ opt = getopt32(argc, argv, "KSbqma:n:s:u:c:x:p:"
+ USE_FEATURE_START_STOP_DAEMON_FANCY("ovN:"),
+// USE_FEATURE_START_STOP_DAEMON_FANCY("ovN:R:"),
+ &startas, &cmdname, &signame, &userspec, &chuid, &execname, &pidfile
+ USE_FEATURE_START_STOP_DAEMON_FANCY(,&opt_N)
+// USE_FEATURE_START_STOP_DAEMON_FANCY(,&retry_arg)
+ );
+
+ quiet = (opt & OPT_QUIET) && !(opt & OPT_VERBOSE);
+
+ if (opt & OPT_s) {
+ signal_nr = get_signum(signame);
+ if (signal_nr < 0) bb_show_usage();
+ }
+
+ if (!(opt & OPT_a))
+ startas = execname;
+
+// USE_FEATURE_START_STOP_DAEMON_FANCY(
+// if (retry_arg)
+// retries = xatoi_u(retry_arg);
+// )
+ argc -= optind;
+ argv += optind;
+
+ if (userspec) {
+ user_id = bb_strtou(userspec, NULL, 10);
+ if (errno)
+ user_id = xuname2uid(userspec);
+ }
+
+ if (opt & CTX_STOP) {
+ int i = do_stop();
+ return (opt & OPT_OKNODO) ? 0 : (i<=0);
+ }
+
+ do_procinit();
+
+ if (found) {
+ if (!quiet)
+ printf("%s already running\n%d\n", execname, found->pid);
+ return !(opt & OPT_OKNODO);
+ }
+ *--argv = startas;
+ if (opt & OPT_BACKGROUND) {
+ setsid();
+ bb_daemonize();
+ }
+ if (opt & OPT_MAKEPID) {
+ /* user wants _us_ to make the pidfile */
+ FILE *pidf = xfopen(pidfile, "w");
+
+ pid_t pidt = getpid();
+ fprintf(pidf, "%d\n", pidt);
+ fclose(pidf);
+ }
+ if (opt & OPT_c) {
+ struct bb_uidgid_t ugid;
+ parse_chown_usergroup_or_die(&ugid, chuid);
+ if (ugid.gid != (gid_t) -1) xsetgid(ugid.gid);
+ if (ugid.uid != (uid_t) -1) xsetuid(ugid.uid);
+ }
+#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
+ if (opt & OPT_NICELEVEL) {
+ /* Set process priority */
+ int prio = getpriority(PRIO_PROCESS, 0) + xatoi_range(opt_N, INT_MIN/2, INT_MAX/2);
+ if (setpriority(PRIO_PROCESS, 0, prio) < 0) {
+ bb_perror_msg_and_die("setpriority(%d)", prio);
+ }
+ }
+#endif
+ execv(startas, argv);
+ bb_perror_msg_and_die("cannot start %s", startas);
+}
diff --git a/i/pc104/initrd/conf/busybox/debianutils/which.c b/i/pc104/initrd/conf/busybox/debianutils/which.c
new file mode 100644
index 0000000..02992d0
--- /dev/null
+++ b/i/pc104/initrd/conf/busybox/debianutils/which.c
@@ -0,0 +1,48 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Which implementation for busybox
+ *
+ * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
+ * Copyright (C) 2006 Gabriel Somlo <somlo at cmu.edu>
+ *
+ * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
+ *
+ * Based on which from debianutils
+ */
+
+#include "busybox.h"
+
+int which_main(int argc, char **argv);
+int which_main(int argc, char **argv)
+{
+ int status = EXIT_SUCCESS;
+ char *p;
+
+ if (argc <= 1 || argv[1][0] == '-') {
+ bb_show_usage();
+ }
+
+ if (!getenv("PATH")) {
+ setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin", 1);
+ }
+
+ while (--argc > 0) {
+ argv++;
+ if (strchr(*argv, '/')) {
+ if (execable_file(*argv)) {
+ puts(*argv);
+ continue;
+ }
+ } else {
+ p = find_execable(*argv);
+ if (p) {
+ puts(p);
+ free(p);
+ continue;
+ }
+ }
+ status = EXIT_FAILURE;
+ }
+
+ fflush_stdout_and_exit(status);
+}