chiark / gitweb /
base-filesystem: avoid all searching if the link already exists
authorKay Sievers <kay@vrfy.org>
Tue, 1 Jul 2014 10:25:38 +0000 (12:25 +0200)
committerKay Sievers <kay@vrfy.org>
Tue, 1 Jul 2014 10:25:38 +0000 (12:25 +0200)
src/shared/base-filesystem.c

index f68386b8e35ba9d5858fc3f243f7286260158fa6..daaeaca515dea0dbc11055d5f6eccafe755d9408 100644 (file)
@@ -65,6 +65,9 @@ int base_filesystem_create(const char *root) {
                         const char *target = NULL;
                         const char *s;
 
+                        if (faccessat(fd, table[i].dir, F_OK, AT_SYMLINK_NOFOLLOW) >= 0)
+                                continue;
+
                         /* check if one of the targets exists */
                         NULSTR_FOREACH(s, table[i].target) {
                                 if (faccessat(fd, s, F_OK, AT_SYMLINK_NOFOLLOW) < 0)