chiark / gitweb /
install: treat non-existent directory as empty
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 16 Sep 2012 10:35:46 +0000 (12:35 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 16 Sep 2012 12:00:25 +0000 (14:00 +0200)
When looking for symlinks, it doesn't make sense to error-out if
the directory is missing. The user might delete an empty directory.

This check caused test-unit-file to fail when run before installation.

src/shared/install.c
src/test/test-unit-file.c

index 1a69337f5aef8c1d338a6c7a616b295e4434ca8b..0d38bccd7220061ce8813faf3f03c1cb404f5b3a 100644 (file)
@@ -524,8 +524,11 @@ static int find_symlinks(
         assert(same_name_link);
 
         fd = open(config_path, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW);
-        if (fd < 0)
+        if (fd < 0) {
+                if (errno == ENOENT)
+                        return 0;
                 return -errno;
+        }
 
         /* This takes possession of fd and closes it */
         return find_symlinks_fd(name, fd, config_path, config_path, same_name_link);
index b390c44b059e87e2d64c2e0b2e99ea8e21802bf9..95e2b680156d52e815094c4a5cc9bc65dfb9957c 100644 (file)
@@ -40,7 +40,7 @@ int main(int argc, char *argv[]) {
         assert(h);
 
         r = unit_file_get_list(UNIT_FILE_SYSTEM, NULL, h);
-        log_info("%s", strerror(-r));
+        log_info("unit_file_get_list: %s", strerror(-r));
         assert(r >= 0);
 
         HASHMAP_FOREACH(p, h, i)