summaryrefslogtreecommitdiff
path: root/src/shared/dev-setup.c
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-08-14 20:00:30 -0400
committerLennart Poettering <lennart@poettering.net>2012-08-21 17:19:35 +0200
commit8f0e73f250f4a397ea07d29a339bd7e64d077612 (patch)
tree7e2c29db498f9ad706d36bff595372f7812d9844 /src/shared/dev-setup.c
parent50b3e64e27d1e73b84f96359f9f38dd497cb9b59 (diff)
dev-setup: allow a path prefix for use in chroots
With this adjustment, we can reuse this code elsewhere, such as in nspawn.
Diffstat (limited to 'src/shared/dev-setup.c')
-rw-r--r--src/shared/dev-setup.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/shared/dev-setup.c b/src/shared/dev-setup.c
index 0b3d648acb..759ecd799f 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);
+ }
}