diff --git a/TODO.md b/TODO.md index cfa802aa..779dcda0 100644 --- a/TODO.md +++ b/TODO.md @@ -140,13 +140,6 @@ Documentation how close Finit3 still is to the original easy-to-use Finit0 :) -Investigation -------------- - -* [FHS changes](http://askubuntu.com/questions/57297/why-has-var-run-been-migrated-to-run) - affecting runtime status, plugins, etc. - - [libwdt]: http://www.wehavemorefun.de/fritzbox/Libwdt.so [Fritz!Box source dump]: ftp://ftp.avm.de/fritz.box/fritzbox.fon_wlan_7170/x_misc/opensrc/ diff --git a/finit.c b/finit.c index 4e148bf4..7019c944 100644 --- a/finit.c +++ b/finit.c @@ -27,6 +27,7 @@ #include #include #include +#include #include /* umask(), mkdir() */ #include @@ -69,6 +70,28 @@ static int banner(void) return 0; } +/* Requires /proc to be mounted */ +static int fismnt(char *dir) +{ + FILE *fp; + int found = 0; + struct mntent *mnt; + + fp = setmntent("/proc/mounts", "r"); + if (!fp) + return 0; /* Dunno, maybe not */ + + while ((mnt = getmntent(fp))) { + if (!strcmp(mnt->mnt_dir, dir)) { + found = 1; + break; + } + } + endmntent(fp); + + return found; +} + int main(int argc, char* argv[]) { int err; @@ -100,10 +123,21 @@ int main(int argc, char* argv[]) mount("none", "/proc", "proc", 0, NULL); mount("none", "/proc/bus/usb", "usbfs", 0, NULL); mount("none", "/sys", "sysfs", 0, NULL); + + /* Some systems use /dev/pts */ makedir("/dev/pts", 0755); + mount("devpts", "/dev/pts", "devpts", 0, "gid=5,mode=620"); + makedir("/dev/shm", 0755); - mount("none", "/dev/pts", "devpts", 0, "gid=5,mode=620"); - mount("none", "/dev/shm", "tmpfs", 0, NULL); + if (!fismnt("/dev/shm")) + mount("shm", "/dev/shm", "tmpfs", 0, NULL); + + /* + * New tmpfs based /run for volatile runtime data + * For details, see http://lwn.net/Articles/436012/ + */ + if (fisdir("/run") && !fismnt("/run")) + mount("tmpfs", "/run", "tmpfs", MS_NODEV, "mode=0755,size=10%"); umask(022); /* diff --git a/plugins/bootmisc.c b/plugins/bootmisc.c index 31cfed69..923f36a6 100644 --- a/plugins/bootmisc.c +++ b/plugins/bootmisc.c @@ -44,12 +44,20 @@ static void setup(void *UNUSED(arg)) makedir("/var/lib/misc", 0755); makedir("/var/lib/alarm", 0755); makedir("/var/lib/urandom",0755); - makedir("/var/lock", 0755); + if (fisdir("/run")) { + _d("System with new /run tmpfs ..."); + makedir("/run/lock", 1777); + symlink("/run/lock", "/var/lock"); + symlink("/run", "/var/run"); + symlink("/dev/shm", "/run/shm"); + } else { + makedir("/var/lock", 1777); + makedir("/var/run", 0755); + } makedir("/var/lock/subsys",0755); /* Needed by D-Bus plugin */ makedir("/var/log", 0755); makedir("/var/mail", 0755); makedir("/var/opt", 0755); - makedir("/var/run", 0755); makedir("/var/spool", 0755); makedir("/var/spool/cron", 0755); makedir("/var/tmp", 0755);