From: Glenn L McGrath Date: Mon, 11 Nov 2002 03:00:12 +0000 (-0000) Subject: Move readlink, mktemp, run-parts and which to a new debianutils dir. X-Git-Tag: 1_00_pre1~453 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8f0722a53b9a88c0b4e60b79e4362d0f31c32c54;p=oweals%2Fbusybox.git Move readlink, mktemp, run-parts and which to a new debianutils dir. --- diff --git a/Makefile b/Makefile index 9a9780ec9..d61d945a6 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ TOPDIR:= $(shell /bin/pwd)/ include $(TOPDIR).config include $(TOPDIR)Rules.mak -SUBDIRS:=applets archival archival/libunarchive console-tools \ +SUBDIRS:=applets archival archival/libunarchive console-tools debianutils \ editors fileutils findutils init miscutils modutils networking \ networking/libiproute networking/udhcp procps loginutils shell \ shellutils sysklogd textutils util-linux libbb libpwdgrp diff --git a/debianutils/Makefile b/debianutils/Makefile new file mode 100644 index 000000000..35b32e73b --- /dev/null +++ b/debianutils/Makefile @@ -0,0 +1,30 @@ +# Makefile for busybox +# +# Copyright (C) 1999-2002 Erik Andersen +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +TOPDIR:= ../ +DEBIANUTILS_DIR:=./ +include $(TOPDIR).config +include $(TOPDIR)Rules.mak +include Makefile.in +all: $(libraries-y) +-include $(TOPDIR).depend + +clean: + rm -f *.o *.a $(AR_TARGET) + diff --git a/debianutils/Makefile.in b/debianutils/Makefile.in new file mode 100644 index 000000000..91887bda1 --- /dev/null +++ b/debianutils/Makefile.in @@ -0,0 +1,36 @@ +# Makefile for busybox +# +# Copyright (C) 1999-2002 Erik Andersen +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +DEBIANUTILS_AR:=debianutils.a +ifndef $(DEBIANUTILS_DIR) +DEBIANUTILS_DIR:=$(TOPDIR)debianutils/ +endif + + +DEBIANUTILS-y:= +DEBIANUTILS-$(CONFIG_MKTEMP) += mktemp.o +DEBIANUTILS-$(CONFIG_READLINK) += readlink.o +DEBIANUTILS-$(CONFIG_RUN_PARTS) += run_parts.o +DEBIANUTILS-$(CONFIG_WHICH) += which.o + +libraries-y+=$(DEBIANUTILS_DIR)$(DEBIANUTILS_AR) + +$(DEBIANUTILS_DIR)$(DEBIANUTILS_AR): $(patsubst %,$(DEBIANUTILS_DIR)%, $(DEBIANUTILS-y)) + $(AR) -ro $@ $(patsubst %,$(DEBIANUTILS_DIR)%, $(DEBIANUTILS-y)) + diff --git a/debianutils/config.in b/debianutils/config.in new file mode 100644 index 000000000..7b1d92991 --- /dev/null +++ b/debianutils/config.in @@ -0,0 +1,15 @@ +# +# For a description of the syntax of this configuration file, +# see scripts/kbuild/config-language.txt. +# + +mainmenu_option next_comment +comment 'Debian Utilities' + +bool 'mktemp' CONFIG_MKTEMP +bool 'readlink' CONFIG_READLINK +bool 'run-parts' CONFIG_RUN_PARTS +bool 'which' CONFIG_WHICH + +endmenu + diff --git a/debianutils/mktemp.c b/debianutils/mktemp.c new file mode 100644 index 000000000..bc47d0af0 --- /dev/null +++ b/debianutils/mktemp.c @@ -0,0 +1,40 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini mktemp implementation for busybox + * + * + * Copyright (C) 2000 by Daniel Jacobowitz + * Written by Daniel Jacobowitz + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include +#include +#include +#include "busybox.h" + +extern int mktemp_main(int argc, char **argv) +{ + if (argc != 2 && (argc != 3 || strcmp(argv[1], "-q"))) + show_usage(); + if(mkstemp(argv[argc-1]) < 0) + return EXIT_FAILURE; + (void) puts(argv[argc-1]); + return EXIT_SUCCESS; +} diff --git a/debianutils/readlink.c b/debianutils/readlink.c new file mode 100644 index 000000000..da5259038 --- /dev/null +++ b/debianutils/readlink.c @@ -0,0 +1,46 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini readlink implementation for busybox + * + * Copyright (C) 2000,2001 Matt Kraai + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include +#include "busybox.h" + +int readlink_main(int argc, char **argv) +{ + char *buf = NULL; + + /* no options, no getopt */ + + if (argc != 2) + show_usage(); + + buf = xreadlink(argv[1]); + if (!buf) + return EXIT_FAILURE; + puts(buf); +#ifdef CONFIG_FEATURE_CLEAN_UP + free(buf); +#endif + + return EXIT_SUCCESS; +} diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c new file mode 100644 index 000000000..3ec4b9d10 --- /dev/null +++ b/debianutils/run_parts.c @@ -0,0 +1,251 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini run-parts implementation for busybox + * + * + * Copyright (C) 2001 by Emanuele Aina + * + * Based on the Debian run-parts program, version 1.15 + * Copyright (C) 1996 Jeff Noxon , + * Copyright (C) 1996-1999 Guy Maor + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + * + */ + +/* 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 +#include +#include +/* #include */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "busybox.h" + +static int test_mode = 0; +static int exitstatus = 0; + +static int argcount = 0, argsize = 0; +static char **args = 0; + + +/* set_umask */ +/* 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. + */ + +static void set_umask (void) +{ + int mask, result; + + /*TODO + * We must substitute sscanf, according to bb's style guide? */ + result = sscanf (optarg, "%o", &mask); + if ((result != 1) || (mask > 07777) || (mask < 0)) { + perror_msg_and_die ("bad umask value"); + } + + umask (mask); +} + +/* add_argument */ +/* Add an argument to the commands that we will call. Called once for + every argument. */ +static void add_argument (char *newarg) +{ + if (argcount+1 >= argsize) { + argsize = argsize ? argsize*2 : 4; + /*TODO if we convert to xrealloc we lose the verbose error message */ + args = realloc(args, argsize * (sizeof(char*))); + if (!args) { + perror_msg_and_die ("failed to reallocate memory for arguments"); + } + } + args[argcount++] = newarg; + args[argcount] = 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) +{ + char *c = d->d_name; + while (*c) { + if (!isalnum(*c) && *c!='_' && *c!='-') { + return 0; + } + ++c; + } + return 1; +} + + +/* run_part */ +/* Execute a file */ + +static void run_part (char *progname) +{ + int result; + int pid; + + + if ((pid=fork()) < 0) { + perror_msg_and_die ("failed to fork"); + } + else if (!pid) { + args[0] = progname; + execv (progname, args); + perror_msg_and_die ("failed to exec %s", progname); + } + + if (0) { + + } else { + + waitpid(pid, &result, 0); + } + + if (WIFEXITED (result) && WEXITSTATUS(result)) { + perror_msg ("%s exited with return code %d", progname, WEXITSTATUS(result)); + exitstatus = 1; + } + else if (WIFSIGNALED (result)) { + perror_msg ("%s exited because of uncaught signal %d", progname, + WTERMSIG(result)); + exitstatus = 1; + } +} + +/* run_parts */ +/* Find the parts to run & call run_part() */ + +static void run_parts (char *dir_name) +{ + struct dirent **namelist = 0; + char *filename; + int entries, i; + struct stat st; + + /* -- */ + + /* scandir() isn't POSIX, but it makes things easy. */ + entries = scandir (dir_name, &namelist, valid_name, alphasort); + + if (entries < 0) { + perror_msg_and_die ("failed to open directory %s", dir_name); + } + + for (i = 0; i < entries; i++) { + + /* -- */ + + filename = concat_path_file (dir_name, namelist[i]->d_name); + + if (stat (filename, &st) < 0) { + perror_msg_and_die ("failed to stat component %s", filename); + } + if (S_ISREG(st.st_mode) && !access (filename, X_OK)) { + if (test_mode) + printf ("run-parts would run %s\n", filename); + else { + run_part (filename); + } + } + + else if (!S_ISDIR(st.st_mode)) { + error_msg ("component %s is not an executable plain file", + filename); + exitstatus = 1; + } + + free (namelist[i]); + free (filename); + } + free (namelist); +} + +/* run_parts_main */ +/* Process options */ +int run_parts_main (int argc, char *argv[]) +{ + umask (022); + add_argument(0); + + for (;;) { + int c; + + opterr = 0; + c = getopt(argc, argv, "tu:a:"); + + if (c == EOF) + break; + switch (c) { + case 't': /* Enable test mode */ + test_mode = 1; + break; + case 'u': /* Set the umask of the programs executed */ + set_umask (); + break; + case 'a': /* Pass an argument to the programs */ + add_argument (optarg); + break; + default: + show_usage(); + } + } + + /* We require exactly one argument: the directory name */ + if (optind != (argc - 1)) { + show_usage(); + } + + run_parts (argv[optind]); + + return exitstatus; +} diff --git a/debianutils/which.c b/debianutils/which.c new file mode 100644 index 000000000..b2af5a8ea --- /dev/null +++ b/debianutils/which.c @@ -0,0 +1,81 @@ +/* vi: set sw=4 ts=4: */ +/* + * Which implementation for busybox + * + * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen + * Copyright (C) 1999,2000,2001 by Erik Andersen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* getopt not needed */ +#include +#include +#include +#include "busybox.h" + +extern int which_main(int argc, char **argv) +{ + char *path_list, *path_n; + struct stat filestat; + int i, count=1, found, status = EXIT_SUCCESS; + + if (argc <= 1 || **(argv + 1) == '-') + show_usage(); + argc--; + + path_list = getenv("PATH"); + if (path_list != NULL) { + for(i=strlen(path_list); i > 0; i--) + if (path_list[i]==':') { + path_list[i]=0; + count++; + } + } else { + path_list = "/bin\0/sbin\0/usr/bin\0/usr/sbin\0/usr/local/bin"; + count = 5; + } + + while(argc-- > 0) { + path_n = path_list; + argv++; + found = 0; + for (i = 0; i < count; i++) { + char *buf; + buf = concat_path_file(path_n, *argv); + if (stat (buf, &filestat) == 0 + && filestat.st_mode & S_IXUSR) + { + puts(buf); + found = 1; + break; + } + free(buf); + path_n += (strlen(path_n) + 1); + } + if (!found) + status = EXIT_FAILURE; + } + return status; +} + +/* +Local Variables: +c-file-style: "linux" +c-basic-offset: 4 +tab-width: 4 +End: +*/ diff --git a/findutils/Makefile.in b/findutils/Makefile.in index 2deaadb05..4133d1c3f 100644 --- a/findutils/Makefile.in +++ b/findutils/Makefile.in @@ -25,7 +25,6 @@ endif FINDUTILS-y:= FINDUTILS-$(CONFIG_FIND) += find.o FINDUTILS-$(CONFIG_GREP) += grep.o -FINDUTILS-$(CONFIG_WHICH) += which.o FINDUTILS-$(CONFIG_XARGS) += xargs.o libraries-y+=$(FINDUTILS_DIR)$(FINDUTILS_AR) diff --git a/findutils/config.in b/findutils/config.in index d5a3714d2..41a23c00a 100644 --- a/findutils/config.in +++ b/findutils/config.in @@ -18,7 +18,6 @@ if [ "$CONFIG_GREP" = "y" ] ; then bool ' Support extended regular expressions (egrep & grep -E)' CONFIG_FEATURE_GREP_EGREP_ALIAS bool ' Enable before and after context flags (-A, -B and -C)' CONFIG_FEATURE_GREP_CONTEXT fi -bool 'which' CONFIG_WHICH bool 'xargs' CONFIG_XARGS endmenu diff --git a/findutils/which.c b/findutils/which.c deleted file mode 100644 index b2af5a8ea..000000000 --- a/findutils/which.c +++ /dev/null @@ -1,81 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* - * Which implementation for busybox - * - * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen - * Copyright (C) 1999,2000,2001 by Erik Andersen - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/* getopt not needed */ -#include -#include -#include -#include "busybox.h" - -extern int which_main(int argc, char **argv) -{ - char *path_list, *path_n; - struct stat filestat; - int i, count=1, found, status = EXIT_SUCCESS; - - if (argc <= 1 || **(argv + 1) == '-') - show_usage(); - argc--; - - path_list = getenv("PATH"); - if (path_list != NULL) { - for(i=strlen(path_list); i > 0; i--) - if (path_list[i]==':') { - path_list[i]=0; - count++; - } - } else { - path_list = "/bin\0/sbin\0/usr/bin\0/usr/sbin\0/usr/local/bin"; - count = 5; - } - - while(argc-- > 0) { - path_n = path_list; - argv++; - found = 0; - for (i = 0; i < count; i++) { - char *buf; - buf = concat_path_file(path_n, *argv); - if (stat (buf, &filestat) == 0 - && filestat.st_mode & S_IXUSR) - { - puts(buf); - found = 1; - break; - } - free(buf); - path_n += (strlen(path_n) + 1); - } - if (!found) - status = EXIT_FAILURE; - } - return status; -} - -/* -Local Variables: -c-file-style: "linux" -c-basic-offset: 4 -tab-width: 4 -End: -*/ diff --git a/include/usage.h b/include/usage.h index b741360cf..3677dff7a 100644 --- a/include/usage.h +++ b/include/usage.h @@ -2262,6 +2262,7 @@ #define which_example_usage \ "$ which login\n" \ "/bin/login\n" + #define who_trivial_usage \ " " #define who_full_usage \ diff --git a/init/Makefile.in b/init/Makefile.in index cd3ead839..a43c4a7f4 100644 --- a/init/Makefile.in +++ b/init/Makefile.in @@ -29,7 +29,6 @@ INIT-$(CONFIG_MESG) += mesg.o INIT-$(CONFIG_POWEROFF) += poweroff.o INIT-$(CONFIG_REBOOT) += reboot.o INIT-$(CONFIG_START_STOP_DAEMON) += start_stop_daemon.o -INIT-$(CONFIG_RUN_PARTS) += run_parts.o libraries-y+=$(INIT_DIR)$(INIT_AR) diff --git a/init/config.in b/init/config.in index e4aa4fbba..3688eaa10 100644 --- a/init/config.in +++ b/init/config.in @@ -21,7 +21,6 @@ if [ "$CONFIG_INIT" = "y" ]; then fi bool 'start-stop-daemon' CONFIG_START_STOP_DAEMON -bool 'run-parts' CONFIG_RUN_PARTS bool 'mesg' CONFIG_MESG endmenu diff --git a/init/run_parts.c b/init/run_parts.c deleted file mode 100644 index 3ec4b9d10..000000000 --- a/init/run_parts.c +++ /dev/null @@ -1,251 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* - * Mini run-parts implementation for busybox - * - * - * Copyright (C) 2001 by Emanuele Aina - * - * Based on the Debian run-parts program, version 1.15 - * Copyright (C) 1996 Jeff Noxon , - * Copyright (C) 1996-1999 Guy Maor - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - * - */ - -/* 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 -#include -#include -/* #include */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "busybox.h" - -static int test_mode = 0; -static int exitstatus = 0; - -static int argcount = 0, argsize = 0; -static char **args = 0; - - -/* set_umask */ -/* 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. - */ - -static void set_umask (void) -{ - int mask, result; - - /*TODO - * We must substitute sscanf, according to bb's style guide? */ - result = sscanf (optarg, "%o", &mask); - if ((result != 1) || (mask > 07777) || (mask < 0)) { - perror_msg_and_die ("bad umask value"); - } - - umask (mask); -} - -/* add_argument */ -/* Add an argument to the commands that we will call. Called once for - every argument. */ -static void add_argument (char *newarg) -{ - if (argcount+1 >= argsize) { - argsize = argsize ? argsize*2 : 4; - /*TODO if we convert to xrealloc we lose the verbose error message */ - args = realloc(args, argsize * (sizeof(char*))); - if (!args) { - perror_msg_and_die ("failed to reallocate memory for arguments"); - } - } - args[argcount++] = newarg; - args[argcount] = 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) -{ - char *c = d->d_name; - while (*c) { - if (!isalnum(*c) && *c!='_' && *c!='-') { - return 0; - } - ++c; - } - return 1; -} - - -/* run_part */ -/* Execute a file */ - -static void run_part (char *progname) -{ - int result; - int pid; - - - if ((pid=fork()) < 0) { - perror_msg_and_die ("failed to fork"); - } - else if (!pid) { - args[0] = progname; - execv (progname, args); - perror_msg_and_die ("failed to exec %s", progname); - } - - if (0) { - - } else { - - waitpid(pid, &result, 0); - } - - if (WIFEXITED (result) && WEXITSTATUS(result)) { - perror_msg ("%s exited with return code %d", progname, WEXITSTATUS(result)); - exitstatus = 1; - } - else if (WIFSIGNALED (result)) { - perror_msg ("%s exited because of uncaught signal %d", progname, - WTERMSIG(result)); - exitstatus = 1; - } -} - -/* run_parts */ -/* Find the parts to run & call run_part() */ - -static void run_parts (char *dir_name) -{ - struct dirent **namelist = 0; - char *filename; - int entries, i; - struct stat st; - - /* -- */ - - /* scandir() isn't POSIX, but it makes things easy. */ - entries = scandir (dir_name, &namelist, valid_name, alphasort); - - if (entries < 0) { - perror_msg_and_die ("failed to open directory %s", dir_name); - } - - for (i = 0; i < entries; i++) { - - /* -- */ - - filename = concat_path_file (dir_name, namelist[i]->d_name); - - if (stat (filename, &st) < 0) { - perror_msg_and_die ("failed to stat component %s", filename); - } - if (S_ISREG(st.st_mode) && !access (filename, X_OK)) { - if (test_mode) - printf ("run-parts would run %s\n", filename); - else { - run_part (filename); - } - } - - else if (!S_ISDIR(st.st_mode)) { - error_msg ("component %s is not an executable plain file", - filename); - exitstatus = 1; - } - - free (namelist[i]); - free (filename); - } - free (namelist); -} - -/* run_parts_main */ -/* Process options */ -int run_parts_main (int argc, char *argv[]) -{ - umask (022); - add_argument(0); - - for (;;) { - int c; - - opterr = 0; - c = getopt(argc, argv, "tu:a:"); - - if (c == EOF) - break; - switch (c) { - case 't': /* Enable test mode */ - test_mode = 1; - break; - case 'u': /* Set the umask of the programs executed */ - set_umask (); - break; - case 'a': /* Pass an argument to the programs */ - add_argument (optarg); - break; - default: - show_usage(); - } - } - - /* We require exactly one argument: the directory name */ - if (optind != (argc - 1)) { - show_usage(); - } - - run_parts (argv[optind]); - - return exitstatus; -} diff --git a/miscutils/Makefile.in b/miscutils/Makefile.in index 72292b69d..535e65467 100644 --- a/miscutils/Makefile.in +++ b/miscutils/Makefile.in @@ -30,9 +30,7 @@ MISCUTILS-$(CONFIG_CRONTAB) += crontab.o MISCUTILS-$(CONFIG_DC) += dc.o MISCUTILS-$(CONFIG_DUTMP) += dutmp.o MISCUTILS-$(CONFIG_MAKEDEVS) += makedevs.o -MISCUTILS-$(CONFIG_MKTEMP) += mktemp.o MISCUTILS-$(CONFIG_MT) += mt.o -MISCUTILS-$(CONFIG_READLINK) += readlink.o MISCUTILS-$(CONFIG_STRINGS) += strings.o MISCUTILS-$(CONFIG_TIME) += time.o MISCUTILS-$(CONFIG_UPDATE) += update.o diff --git a/miscutils/config.in b/miscutils/config.in index 3dc5e2c8b..063e02b36 100644 --- a/miscutils/config.in +++ b/miscutils/config.in @@ -12,9 +12,7 @@ bool 'crontab' CONFIG_CRONTAB bool 'dc' CONFIG_DC bool 'dutmp' CONFIG_DUTMP bool 'makedevs' CONFIG_MAKEDEVS -bool 'mktemp' CONFIG_MKTEMP bool 'mt' CONFIG_MT -bool 'readlink' CONFIG_READLINK bool 'strings' CONFIG_STRINGS bool 'time' CONFIG_TIME bool 'update' CONFIG_UPDATE diff --git a/miscutils/mktemp.c b/miscutils/mktemp.c deleted file mode 100644 index bc47d0af0..000000000 --- a/miscutils/mktemp.c +++ /dev/null @@ -1,40 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* - * Mini mktemp implementation for busybox - * - * - * Copyright (C) 2000 by Daniel Jacobowitz - * Written by Daniel Jacobowitz - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include -#include -#include -#include "busybox.h" - -extern int mktemp_main(int argc, char **argv) -{ - if (argc != 2 && (argc != 3 || strcmp(argv[1], "-q"))) - show_usage(); - if(mkstemp(argv[argc-1]) < 0) - return EXIT_FAILURE; - (void) puts(argv[argc-1]); - return EXIT_SUCCESS; -} diff --git a/miscutils/readlink.c b/miscutils/readlink.c deleted file mode 100644 index da5259038..000000000 --- a/miscutils/readlink.c +++ /dev/null @@ -1,46 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* - * Mini readlink implementation for busybox - * - * Copyright (C) 2000,2001 Matt Kraai - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include -#include "busybox.h" - -int readlink_main(int argc, char **argv) -{ - char *buf = NULL; - - /* no options, no getopt */ - - if (argc != 2) - show_usage(); - - buf = xreadlink(argv[1]); - if (!buf) - return EXIT_FAILURE; - puts(buf); -#ifdef CONFIG_FEATURE_CLEAN_UP - free(buf); -#endif - - return EXIT_SUCCESS; -} diff --git a/sysdeps/linux/config.in b/sysdeps/linux/config.in index dac74e8e0..d33a9826d 100644 --- a/sysdeps/linux/config.in +++ b/sysdeps/linux/config.in @@ -31,18 +31,19 @@ endmenu source archival/config.in source console-tools/config.in +source debianutils/config.in source editors/config.in +source fileutils/config.in source findutils/config.in source init/config.in +source loginutils/config.in source miscutils/config.in source modutils/config.in source networking/config.in -source loginutils/config.in source procps/config.in source shell/config.in source shellutils/config.in source sysklogd/config.in source textutils/config.in source util-linux/config.in -source fileutils/config.in