sysv-generator: port to use new unit_file_exists() call
authorLennart Poettering <lennart@poettering.net>
Thu, 7 Apr 2016 17:18:59 +0000 (19:18 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 12 Apr 2016 11:43:32 +0000 (13:43 +0200)
The code previously queries the state of a unit file, but was only interested
in the existance of it, hence let's use unit_file_exists() instead, the same
way the SysV compat code in systemctl does it.

src/sysv-generator/sysv-generator.c

index e44304c..cae920e 100644 (file)
@@ -806,11 +806,11 @@ static int enumerate_sysv(const LookupPaths *lp, Hashmap *all_services) {
                         if (hashmap_contains(all_services, name))
                                 continue;
 
-                        r = unit_file_lookup_state(UNIT_FILE_SYSTEM, lp, name, NULL);
-                        if (r < 0 && r != -ENOENT) {
+                        r = unit_file_exists(UNIT_FILE_SYSTEM, lp, name);
+                        if (r < 0) {
                                 log_debug_errno(r, "Failed to detect whether %s exists, skipping: %m", name);
                                 continue;
-                        } else if (r >= 0) {
+                        } else if (r > 0) {
                                 log_debug("Native unit for %s already exists, skipping.", name);
                                 continue;
                         }