Run-parts code cleanup and minor fixes

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
This commit is contained in:
Claudio Matsuoka committed 2008-03-16 12:47:37 -03:00
1 parent f972ff4d30
commit 1c88ae1f61
2 files changed
+10 -12

No files matched your search

+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;