mirror of
https://github.com/troglobit/finit.git
synced 2026-11-03 13:28:27 +00:00
Run-parts code cleanup and minor fixes
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
This commit is contained in:
1 parent
f972ff4d30
commit
1c88ae1f61
2 files changed
+10
-12
No files matched your search
@@ -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