Fix incorrect use of variable arguments in run_parts() and simplify code

The run_parts() implementation used variable arguments in a bad way,
resulting in it not working properly.  Replaced va_*() code with a
simple cmd argument that's passed to each script called.

Also, the opendir()/readdir() code has been replaced with scandir()
using regular alphasort(). This simplifies the code somewhat as well.

Otherwise, minor cleanups.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2012-10-06 15:45:42 +02:00
1 parent af59174e49
commit f29d2733c7
7 files changed
+46 -64

No files matched your search

+4 -2
View File
@@ -50,7 +50,9 @@
#ifndef blkdev
# define blkdev(x,m,maj,min) mknod((x), S_IFBLK|(m), makedev((maj),(min)))
#endif
#ifndef S_ISEXEC
# define S_ISEXEC(m) (((m) & S_IXUSR) == S_IXUSR)
#endif
#ifndef UNUSED
#define UNUSED(x) UNUSED_ ## x __attribute__ ((unused))
#endif
@@ -87,7 +89,7 @@ void set_hostname (char *hostname);
int run (char *cmd);
int run_interactive (char *cmd, char *fmt, ...);
pid_t run_getty (char *cmd, char *argv[]);
int run_parts (char *dir, ...);
int run_parts (char *dir, char *cmd);
/* strlcpy.c */
size_t strlcpy(char *dst, const char *src, size_t siz);