mirror of
https://github.com/troglobit/finit.git
synced 2026-10-08 16:34:45 +07:00
Run-parts code cleanup and minor fixes
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
This commit is contained in:
@@ -33,7 +33,7 @@ CFLAGS += -march=pentium-m
|
||||
#CFLAGS += -DDIRECTISA
|
||||
|
||||
# Use built-in run-parts instead of /bin/run-parts
|
||||
#CFLAGS += BUILTIN_RUNPARTS
|
||||
CFLAGS += -DBUILTIN_RUNPARTS
|
||||
|
||||
ifneq ($(USER), "user")
|
||||
CFLAGS += -DDEFUSER=\"$(USER)\"
|
||||
@@ -67,6 +67,8 @@ finit.o: finit.c Makefile
|
||||
|
||||
finit-mod.o: finit-mod.c Makefile
|
||||
|
||||
helpers.o: helpers.c Makefile
|
||||
|
||||
dist:
|
||||
rm -Rf $(PKG)
|
||||
mkdir -p $(PKG)/contrib
|
||||
|
||||
@@ -117,24 +117,18 @@ int run_parts(char *dir, ...)
|
||||
char *args[NUM_ARGS];
|
||||
va_list ap;
|
||||
|
||||
if ((d = opendir(dir)) == NULL)
|
||||
return -1;
|
||||
|
||||
if (chdir(dir))
|
||||
return -1;
|
||||
|
||||
if ((d = opendir(dir)) == NULL)
|
||||
return -1;
|
||||
|
||||
va_start(ap, dir);
|
||||
while (argnum < NUM_ARGS && (args[argnum++] = va_arg(ap, char *)));
|
||||
va_end(ap);
|
||||
|
||||
while (1) {
|
||||
if ((e = readdir(d)) == NULL)
|
||||
break;
|
||||
|
||||
if (e->d_type == DT_REG) {
|
||||
if (stat(e->d_name, &st))
|
||||
continue;
|
||||
|
||||
while ((e = readdir(d))) {
|
||||
if (e->d_type == DT_REG && stat(e->d_name, &st) == 0) {
|
||||
if (st.st_mode & S_IXUSR) {
|
||||
ent[num++] = strdup(e->d_name);
|
||||
if (num >= NUM_SCRIPTS)
|
||||
@@ -143,6 +137,8 @@ int run_parts(char *dir, ...)
|
||||
}
|
||||
}
|
||||
|
||||
closedir(d);
|
||||
|
||||
if (num == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user