chiark / gitweb /
cgroup: the "tasks" attribute is obsolete, cgroup.procs is the new replacement
[elogind.git] / src / shared / dev-setup.c
index 0b3d648acb879daedc77ef1aacbdd010155e3ef8..b0ac02d4611ef6e7110624d5764036161b350b5f 100644 (file)
@@ -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 *prefix) {
         const char *j, *k;
 
         static const char symlinks[] =
@@ -60,6 +60,19 @@ 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) {
+
+                if (prefix) {
+                        char *linkname;
+
+                        if (asprintf(&linkname, "%s/%s", prefix, k) < 0) {
+                                log_oom();
+                                break;
+                        }
+
+                        symlink_and_label(j, linkname);
+                        free(linkname);
+                } else
+                        symlink_and_label(j, k);
+        }
 }