]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/shared/base-filesystem.c
nulstr-util: Declare NULSTR_FOREACH() iterator inline
[thirdparty/systemd.git] / src / shared / base-filesystem.c
index 5f5328c8cfa1ad4f4b0fa2d55303e6f7dfd5e270..c2902d35082e40b9d26a69269a64e634885ae518 100644 (file)
@@ -31,7 +31,7 @@ typedef struct BaseFilesystem {
 static const BaseFilesystem table[] = {
         { "bin",      0, "usr/bin\0",                  NULL },
         { "lib",      0, "usr/lib\0",                  NULL },
-        { "root",  0755, NULL,                         NULL, true },
+        { "root",  0750, NULL,                         NULL, true },
         { "sbin",     0, "usr/sbin\0",                 NULL },
         { "usr",   0755, NULL,                         NULL },
         { "var",   0755, NULL,                         NULL },
@@ -63,6 +63,20 @@ static const BaseFilesystem table[] = {
                          "usr/lib64\0",                "ld-linux-x86-64.so.2" },
 #  define KNOW_LIB64_DIRS 1
 #elif defined(__ia64__)
+#elif defined(__loongarch64)
+#  define KNOW_LIB64_DIRS 1
+#  if defined(__loongarch_double_float)
+        { "lib64",    0, "usr/lib/"LIB_ARCH_TUPLE"\0"
+                         "usr/lib64\0",                "ld-linux-loongarch-lp64d.so.1" },
+#  elif defined(__loongarch_single_float)
+        { "lib64",    0, "usr/lib/"LIB_ARCH_TUPLE"\0"
+                         "usr/lib64\0",                "ld-linux-loongarch-lp64f.so.1" },
+#  elif defined(__loongarch_soft_float)
+        { "lib64",    0, "usr/lib/"LIB_ARCH_TUPLE"\0"
+                         "usr/lib64\0",                "ld-linux-loongarch-lp64s.so.1" },
+#  else
+#    error "Unknown LoongArch ABI"
+#  endif
 #elif defined(__m68k__)
         /* No link needed. */
 #  define KNOW_LIB64_DIRS 1
@@ -97,7 +111,7 @@ static const BaseFilesystem table[] = {
         /* s390-linux-gnu */
 #elif defined(__s390x__)
         { "lib64",    0, "usr/lib/"LIB_ARCH_TUPLE"\0"
-                         "usr/lib64",                  "ld-lsb-s390x.so.3" },
+                         "usr/lib64\0",                "ld-lsb-s390x.so.3" },
 #    define KNOW_LIB64_DIRS 1
 #elif defined(__sparc__)
 #endif
@@ -121,7 +135,7 @@ int base_filesystem_create(const char *root, uid_t uid, gid_t gid) {
                         continue;
 
                 if (table[i].target) {
-                        const char *target = NULL, *s;
+                        const char *target = NULL;
 
                         /* check if one of the targets exists */
                         NULSTR_FOREACH(s, table[i].target) {
@@ -176,7 +190,7 @@ int base_filesystem_create(const char *root, uid_t uid, gid_t gid) {
                         return -errno;
                 }
 
-                if (uid != UID_INVALID || gid != UID_INVALID)
+                if (uid_is_valid(uid) || gid_is_valid(gid))
                         if (fchownat(fd, table[i].dir, uid, gid, AT_SYMLINK_NOFOLLOW) < 0)
                                 return log_error_errno(errno, "Failed to chown directory at %s/%s: %m", root, table[i].dir);
         }