summaryrefslogtreecommitdiff
path: root/src/sysv-generator
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-01-28 01:36:40 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-28 01:36:40 +0100
commita986501b9059b72e8deced262554fbdd1ab9da17 (patch)
tree9dec7d6e324239a741751f26a0adb30454b7444a /src/sysv-generator
parent7dfb0404b3b6882d582a571f61a52b2f56961675 (diff)
sysv-generator: there's really no need to invoke fstatat() multiple times on the same sysv script
It's sufficient to check once if something is a regular file, hence, let's do that.
Diffstat (limited to 'src/sysv-generator')
-rw-r--r--src/sysv-generator/sysv-generator.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index 984beab70a..09ade0dc3a 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -749,12 +749,10 @@ static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
struct stat st;
int r;
- dirent_ensure_type(d, de);
-
- if (!dirent_is_file(de))
- continue;
+ if (hidden_file(de->d_name))
+ continue;
- if (fstatat(dirfd(d), de->d_name, &st, 0) < 0) {
+ if (fstatat(dirfd(d), de->d_name, &st, AT_SYMLINK_NOFOLLOW) < 0) {
log_warning_errno(errno, "stat() failed on %s/%s: %m", *path, de->d_name);
continue;
}
@@ -769,13 +767,13 @@ static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
if (!name)
return log_oom();
+ if (hashmap_contains(all_services, name))
+ continue;
+
fpath = strjoin(*path, "/", de->d_name, NULL);
if (!fpath)
return log_oom();
- if (hashmap_contains(all_services, name))
- continue;
-
service = new0(SysvStub, 1);
if (!service)
return log_oom();