diff --git a/Makefile b/Makefile index 2ed75017..0332676f 100644 --- a/Makefile +++ b/Makefile @@ -130,7 +130,10 @@ sysroot-fsh: mkdir -p "$(SYSROOT)/tix/manifest" mkdir -p "$(SYSROOT)/tmp" -m 1777 mkdir -p "$(SYSROOT)/var" + mkdir -p "$(SYSROOT)/var/cache" mkdir -p "$(SYSROOT)/var/empty" -m 555 + mkdir -p "$(SYSROOT)/var/log" + mkdir -p "$(SYSROOT)/var/run" ln -sfT . "$(SYSROOT)/usr" .PHONY: sysroot-base-headers @@ -160,7 +163,10 @@ sysroot-system: sysroot-fsh sysroot-base-headers echo /tmp >> "$(SYSROOT)/tix/manifest/system" echo /usr >> "$(SYSROOT)/tix/manifest/system" echo /var >> "$(SYSROOT)/tix/manifest/system" + echo /var/cache >> "$(SYSROOT)/tix/manifest/system" echo /var/empty >> "$(SYSROOT)/tix/manifest/system" + echo /var/log >> "$(SYSROOT)/tix/manifest/system" + echo /var/run >> "$(SYSROOT)/tix/manifest/system" echo "$(HOST_MACHINE)" > "$(SYSROOT)/etc/machine" echo /etc/machine >> "$(SYSROOT)/tix/manifest/system" (echo 'NAME="Sortix"' && \ diff --git a/init/init.8 b/init/init.8 index 1fc5dfe1..bbf7ce5e 100644 --- a/init/init.8 +++ b/init/init.8 @@ -84,11 +84,20 @@ command line if it hasn't been password protected. Likewise unprivileged users can use their own replacement bootloader by booting a portable device under their control if the firmware configuration has not been password protected. -.Ss Cleanup of /tmp +.Ss Cleanup of /tmp and /var/run .Nm deletes everything inside of .Pa /tmp if it exists, otherwise it is created with mode 1777. +.Pp +.Nm +creates +.Pa /var +with mode 755 if it doesn't exist. +.Nm +deletes everything inside of +.Pa /var/run +if it exists, otherwise it is created with mode 755. .Ss Partition Creation .Nm will scan every block device for valid partition tables and create the diff --git a/init/init.c b/init/init.c index 30735bc2..ae6ef693 100644 --- a/init/init.c +++ b/init/init.c @@ -561,9 +561,8 @@ struct clean_tmp int current_entry; }; -static void clean_tmp(void) +static void clean_tmp(const char* tmp_path) { - const char* tmp_path = "/tmp"; struct clean_tmp* state = calloc(1, sizeof(struct clean_tmp)); if ( !state ) { @@ -680,7 +679,13 @@ static void init_early(void) // Make sure that we have a /tmp directory. umask(0000); mkdir("/tmp", 01777); - clean_tmp(); + clean_tmp("/tmp"); + + // Make sure that we have a /var/run directory. + umask(0000); + mkdir("/var", 0755); + mkdir("/var/run", 0755); + clean_tmp("/var/run"); // Set the default file creation mask. umask(0022); diff --git a/share/man/man7/hier.7 b/share/man/man7/hier.7 index e6b95827..1a47309b 100644 --- a/share/man/man7/hier.7 +++ b/share/man/man7/hier.7 @@ -45,11 +45,19 @@ delayed upgrades. .It Pa /tix Package management. .It Pa /tmp -Temporary files. +Temporary files that is on boot. .It Pa /usr Symlink to the current directory. .It Pa /var -Various files. +Variable data files. +.It Pa /var/cache +Cached application data that can be removed without data loss. +.It Pa /var/empty +Empty directory. +.It Pa /var/log +Log files. +.It Pa /var/run +Runtime program data that is cleaned on boot. .El .Sh SEE ALSO .Xr user-guide 7