mirror of
https://github.com/systemd/systemd.git
synced 2024-10-28 03:25:31 +03:00
base-filesystem: create /lib64 symlink to libdir /usr directory
This commit is contained in:
parent
0099bc15f1
commit
e1ae9755ab
@ -29,6 +29,7 @@
|
|||||||
#include "base-filesystem.h"
|
#include "base-filesystem.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
|
#include "strv.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "label.h"
|
#include "label.h"
|
||||||
#include "mkdir.h"
|
#include "mkdir.h"
|
||||||
@ -42,7 +43,9 @@ typedef struct BaseFilesystem {
|
|||||||
static const BaseFilesystem table[] = {
|
static const BaseFilesystem table[] = {
|
||||||
{ "bin", 0, "usr/bin" },
|
{ "bin", 0, "usr/bin" },
|
||||||
{ "lib", 0, "usr/lib" },
|
{ "lib", 0, "usr/lib" },
|
||||||
{ "lib64", 0, "usr/lib64" },
|
#if defined(__i386__) || defined(__x86_64__)
|
||||||
|
{ "lib64", 0, "usr/lib/x86_64-linux-gnu\0usr/lib64" },
|
||||||
|
#endif
|
||||||
{ "root", 0755, NULL },
|
{ "root", 0755, NULL },
|
||||||
{ "sbin", 0, "usr/sbin" },
|
{ "sbin", 0, "usr/sbin" },
|
||||||
};
|
};
|
||||||
@ -58,11 +61,22 @@ int base_filesystem_create(const char *root) {
|
|||||||
|
|
||||||
for (i = 0; i < ELEMENTSOF(table); i ++) {
|
for (i = 0; i < ELEMENTSOF(table); i ++) {
|
||||||
if (table[i].target) {
|
if (table[i].target) {
|
||||||
/* check if target exists */
|
const char *target = NULL;
|
||||||
if (faccessat(fd, table[i].target, F_OK, AT_SYMLINK_NOFOLLOW) < 0)
|
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;
|
continue;
|
||||||
|
|
||||||
r = symlinkat(table[i].target, fd, table[i].dir);
|
target = s;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!target)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
r = symlinkat(target, fd, table[i].dir);
|
||||||
if (r < 0 && errno != EEXIST) {
|
if (r < 0 && errno != EEXIST) {
|
||||||
log_error("Failed to create symlink at %s/%s: %m", root, table[i].dir);
|
log_error("Failed to create symlink at %s/%s: %m", root, table[i].dir);
|
||||||
return -errno;
|
return -errno;
|
||||||
|
Loading…
Reference in New Issue
Block a user