Run-parts code cleanup and minor fixes

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
This commit is contained in:
Claudio Matsuoka
2008-03-16 12:47:37 -03:00
parent f972ff4d30
commit 1c88ae1f61
2 changed files with 10 additions and 12 deletions
+3 -1
View File
@@ -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
+7 -11
View File
@@ -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;