2 * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License version 2.1
7 * as published by the Free Software Foundation
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
16 #include <sys/types.h>
17 #include <sys/mount.h>
25 static struct uloop_process udevtrigger
;
27 static void coldplug_complete(struct uloop_timeout
*t
)
29 DEBUG(4, "Coldplug complete\n");
30 hotplug_last_event(NULL
);
34 static void udevtrigger_complete(struct uloop_process
*proc
, int ret
)
36 DEBUG(4, "Finished udevtrigger\n");
37 hotplug_last_event(coldplug_complete
);
40 void procd_coldplug(void)
42 char *argv
[] = { "udevtrigger", NULL
};
44 umount2("/dev/pts", MNT_DETACH
);
45 umount2("/dev/", MNT_DETACH
);
46 mount("tmpfs", "/dev", "tmpfs", 0, "mode=0755,size=512K");
47 mkdir("/dev/shm", 0755);
48 mkdir("/dev/pts", 0755);
49 mount("devpts", "/dev/pts", "devpts", 0, 0);
50 udevtrigger
.cb
= udevtrigger_complete
;
51 udevtrigger
.pid
= fork();
52 if (!udevtrigger
.pid
) {
53 execvp(argv
[0], argv
);
54 ERROR("Failed to start coldplug\n");
58 if (udevtrigger
.pid
<= 0) {
59 ERROR("Failed to start new coldplug instance\n");
63 uloop_process_add(&udevtrigger
);
65 DEBUG(4, "Launched coldplug instance, pid=%d\n", (int) udevtrigger
.pid
);