On Tue, 14.08.12 20:00, Dave Reisner (dreis...@archlinux.org) wrote:
With this adjustment, we can reuse this code elsewhere, such as in
nspawn.
Applied both, and made a couple of changes afterwards so that NULL as
param has the same effect as .
Lennart
---
src/core/mount-setup.c | 2 +-
src/shared/dev-setup.c | 16 +---
src/shared/dev-setup.h | 7 ++-
src/udev/udevd.c | 2 +-
4 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c
index e86a893..be11bb8 100644
--- a/src/core/mount-setup.c
+++ b/src/core/mount-setup.c
@@ -398,7 +398,7 @@ int mount_setup(bool loaded_policy) {
/* Create a few default symlinks, which are normally created
* by udevd, but some scripts might need them before we start
* udevd. */
-dev_setup();
+dev_setup();
/* Mark the root directory as shared in regards to mount
* propagation. The kernel defaults to private, but we think
diff --git a/src/shared/dev-setup.c b/src/shared/dev-setup.c
index 0b3d648..759ecd7 100644
--- a/src/shared/dev-setup.c
+++ b/src/shared/dev-setup.c
@@ -50,7 +50,7 @@ static int symlink_and_label(const char *old_path, const
char *new_path) {
return r;
}
-void dev_setup(void) {
+void dev_setup(const char *pathprefix) {
const char *j, *k;
static const char symlinks[] =
@@ -60,6 +60,16 @@ void dev_setup(void) {
/proc/self/fd/1\0 /dev/stdout\0
/proc/self/fd/2\0 /dev/stderr\0;
-NULSTR_FOREACH_PAIR(j, k, symlinks)
-symlink_and_label(j, k);
+NULSTR_FOREACH_PAIR(j, k, symlinks) {
+char *linkname;
+
+if (asprintf(linkname, %s/%s, pathprefix, k) 0) {
+log_oom();
+break;
+}
+
+symlink_and_label(j, linkname);
+
+free(linkname);
+}
}
diff --git a/src/shared/dev-setup.h b/src/shared/dev-setup.h
index 5850758..320c0b3 100644
--- a/src/shared/dev-setup.h
+++ b/src/shared/dev-setup.h
@@ -1,7 +1,6 @@
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-#ifndef foodevsetuphfoo
-#define foodevsetuphfoo
+#pragma once
/***
This file is part of systemd.
@@ -22,6 +21,4 @@
along with systemd; If not, see http://www.gnu.org/licenses/.
***/
-void dev_setup(void);
-
-#endif
+void dev_setup(const char *pathprefix);
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 23351ae..1bb15d8 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -1155,7 +1155,7 @@ int main(int argc, char *argv[])
mkdir(/run/udev, 0755);
-dev_setup();
+dev_setup();
static_dev_create_from_modules(udev);
/* before opening new files, make sure std{in,out,err} fds are in a
sane state */
Lennart
--
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel