[systemd-commits] src/shared

Kay Sievers kay at kemper.freedesktop.org
Tue Jul 1 02:48:26 PDT 2014


 src/shared/base-filesystem.c |   28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

New commits:
commit e1ae9755ab70a58b8fb84973e084296b1d2df3d5
Author: Kay Sievers <kay at vrfy.org>
Date:   Tue Jul 1 11:42:58 2014 +0200

    base-filesystem: create /lib64 symlink to libdir /usr directory

diff --git a/src/shared/base-filesystem.c b/src/shared/base-filesystem.c
index a220101..682155b 100644
--- a/src/shared/base-filesystem.c
+++ b/src/shared/base-filesystem.c
@@ -29,6 +29,7 @@
 #include "base-filesystem.h"
 #include "log.h"
 #include "macro.h"
+#include "strv.h"
 #include "util.h"
 #include "label.h"
 #include "mkdir.h"
@@ -40,11 +41,13 @@ typedef struct BaseFilesystem {
 } BaseFilesystem;
 
 static const BaseFilesystem table[] = {
-        { "bin",      0, "usr/bin"   },
-        { "lib",      0, "usr/lib"   },
-        { "lib64",    0, "usr/lib64" },
+        { "bin",      0, "usr/bin" },
+        { "lib",      0, "usr/lib" },
+#if defined(__i386__) || defined(__x86_64__)
+        { "lib64",    0, "usr/lib/x86_64-linux-gnu\0usr/lib64" },
+#endif
         { "root",  0755, NULL },
-        { "sbin",     0, "usr/sbin"  },
+        { "sbin",     0, "usr/sbin" },
 };
 
 int base_filesystem_create(const char *root) {
@@ -58,11 +61,22 @@ int base_filesystem_create(const char *root) {
 
         for (i = 0; i < ELEMENTSOF(table); i ++) {
                 if (table[i].target) {
-                        /* check if target exists */
-                        if (faccessat(fd, table[i].target, F_OK, AT_SYMLINK_NOFOLLOW) < 0)
+                        const char *target = NULL;
+                        const char *s;
+
+                        /* check if one of the targets exists */
+                        NULSTR_FOREACH(s, table[i].target) {
+                                if (faccessat(fd, s, F_OK, AT_SYMLINK_NOFOLLOW) < 0)
+                                        continue;
+
+                                target = s;
+                                break;
+                        }
+
+                        if (!target)
                                 continue;
 
-                        r = symlinkat(table[i].target, fd, table[i].dir);
+                        r = symlinkat(target, fd, table[i].dir);
                         if (r < 0 && errno != EEXIST) {
                                 log_error("Failed to create symlink at %s/%s: %m", root, table[i].dir);
                                 return -errno;



More information about the systemd-commits mailing list