aboutsummaryrefslogtreecommitdiff
path: root/src/librc-misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/librc-misc.c')
-rw-r--r--src/librc-misc.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/librc-misc.c b/src/librc-misc.c
index 29d2763d..4cc69be0 100644
--- a/src/librc-misc.c
+++ b/src/librc-misc.c
@@ -147,21 +147,6 @@ bool rc_exists (const char *pathname)
}
librc_hidden_def(rc_exists)
-bool rc_is_dir (const char *pathname)
-{
- struct stat buf;
-
- if (! pathname)
- return (false);
-
- if (stat (pathname, &buf) == 0)
- return (S_ISDIR (buf.st_mode));
-
- errno = 0;
- return (false);
-}
-librc_hidden_def(rc_is_dir)
-
char **rc_ls_dir (const char *dir, int options)
{
DIR *dp;
@@ -189,6 +174,12 @@ char **rc_ls_dir (const char *dir, int options)
d->d_name[l - 1] == 'h')
continue;
}
+ if (options & RC_LS_DIRS) {
+ struct stat buf;
+
+ if (stat (d->d_name, &buf) == 0 && ! S_ISDIR (buf.st_mode))
+ continue;
+ }
rc_strlist_addsort (&list, d->d_name);
}
}
@@ -592,7 +583,7 @@ char **rc_env_config (void)
We store this special system in RC_SYS so our scripts run fast */
memset (sys, 0, sizeof (sys));
- if (rc_is_dir ("/proc/xen")) {
+ if (rc_exists ("/proc/xen")) {
if ((fp = fopen ("/proc/xen/capabilities", "r"))) {
fclose (fp);
if (file_regex ("/proc/xen/capabilities", "control_d"))