Skip to contentSkip to conversation

Fix persistent tmp

RFC PATCH New [email protected] 1 participant 6 messages Dec 11, 2023

lore
Share & tools
lore
#0 lore raw

v2 cover Fix persistent tmp

From: Changqing Li <[email protected]>

Hi, All

Currently, VOLATILE_TMP_DIR not works,
set VOLATILE_TMP_DIR="no", VOLATILE_LOG_DIR="no", after boot target, /var/tmp still link to tmpfs /var/volatile/tmp

lrwxrwxrwx  1 root root   11 Mar  9  2018 lock -> ../run/lock
drwxr-xr-x  4 root root 1024 Dec  4 07:55 log
lrwxrwxrwx  1 root root    6 Mar  9  2018 run -> ../run
drwxr-xr-x  3 root root 1024 Mar  9  2018 spool
lrwxrwxrwx  1 root root   12 Mar  9  2018 tmp -> volatile/tmp
drwxrwxrwt  4 root root   80 Dec  4 07:55 volatile

So I do some research, fix this issue and do some other changes accordingly. Please help to review this patch, thanks.

Targets:
1. Support persistent tmp, For persistent tmp, only /var/tmp is persistent, /tmp is tmpfs, For volatile tmp, /tmp link to /var/tmp, /var/tmp link to /var/volatile/tmp
2. make systemd and SysVinit have the same directory structure.

Currently, systemd and SysVinit have different directory structure, the difference focus on how to handle /tmp.

when volatile is enabled, for sysVinit, /tmp link to /var/tmp, /var/tmp link to /var/volatile/tmp refer [4][5]. but for systemd, /tmp is a directory, it is mounted by systemd as tmpfs. /var/tmp linked to /var/volatile/tmp. And for systemd, refer [6], set different age for /tmp and /var/tmp.

Since volatile disabled not works, ignore the difference when volatile is disabled.

With this patch, VOLATILE_TMP_DIR will behavior like this:
For both sysvinit and systemd:
1. VOLATILE_TMP_DIR="yes":
/tmp link to /var/tmp, /var/tmp link to /var/volatile/log, /var/volatile is mounted as tmpfs In this case, for systemd, /tmp and /var/tmp will set to the same age, 10d.

Compare to current behavior, there are 2 changes:
1) for systemd, /tmp changed from a directy to a symlink to /var/tmp
2) age of /tmp and /var/tmp will be same

2. VOLATILE_TMP_DIR="no":
/tmp is a directory mounted as tmpfs, /var/tmp is a directory on persistent fs, and keep the age as [6]

Change like this in order to meet [1][2], also maybe [3] for systemd.

Compare to current behavior, there is one change:
1) for sysVinit, /tmp changed from a symlink to a directory

[1] https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s18.html
[2] https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s15.html
[3] https://systemd.io/TEMPORARY_DIRECTORIES/
[4] https://git.openembedded.org/openembedded/tree/docs/usermanual/chapters/recipes.xml#n3535
[5] https://git.openembedded.org/openembedded-core/commit/?id=12c4acd7ac5a27cf3676065b60f1c8395c96854c
[6] https://github.com/systemd/systemd/blob/main/tmpfiles.d/tmp.conf
[7] https://www.freedesktop.org/software/systemd/man/latest/tmpfiles.d.html

Test Result of following cases:
1.
SysVinit
VOLATILE_TMP_DIR="yes"
VOLATILE_LOG_DIR="yes"

root@qemux86-64:~# ls -al /tmp
lrwxrwxrwx    1 root     root             8 Dec  8 08:51 /tmp -> /var/tmp
root@qemux86-64:~# ls -al /var/log 
lrwxrwxrwx    1 root     root            17 Dec  8 08:51 /var/log -> /var/volatile/log
root@qemux86-64:~# ls -al /var/tmp
lrwxrwxrwx    1 root     root            17 Dec  8 08:51 /var/tmp -> /var/volatile/tmp
root@qemux86-64:~# mount | grep volatile
tmpfs on /var/volatile type tmpfs (rw,relatime)
root@qemux86-64:~# 

2.
SysVinit
VOLATILE_TMP_DIR="no"
VOLATILE_LOG_DIR="no"

root@qemux86-64:/# ls -al
drwxr-xr-x   18 root     root          1024 Dec  8 09:22 .
drwxr-xr-x   18 root     root          1024 Dec  8 09:22 ..
drwxr-xr-x    2 root     root          3072 Mar  9  2018 bin
drwxr-xr-x    2 root     root          1024 Mar  9  2018 boot
drwxr-xr-x   13 root     root          2960 Dec  8 09:24 dev
drwxr-xr-x   20 root     root          1024 Dec  8 09:24 etc
drwxr-xr-x    3 root     root          1024 Mar  9  2018 home
drwxr-xr-x    6 root     root          1024 Mar  9  2018 lib
drwx------    2 root     root         12288 Dec  8 09:22 lost+found
drwxr-xr-x    2 root     root          1024 Mar  9  2018 media
drwxr-xr-x    2 root     root          1024 Mar  9  2018 mnt
dr-xr-xr-x  161 root     root             0 Dec  8 09:24 proc
drwxr-xr-x    4 root     root           240 Dec  8 09:24 run
drwxr-xr-x    2 root     root          3072 Mar  9  2018 sbin
dr-xr-xr-x   12 root     root             0 Dec  8 09:24 sys
drwxrwxrwt    2 root     root            40 Dec  8 09:24 tmp
drwxr-xr-x    9 root     root          1024 Mar  9  2018 usr
drwxr-xr-x   10 root     root          1024 Dec  8 09:24 var
root@qemux86-64:/# cd /var/
root@qemux86-64:/var# ls -al
drwxr-xr-x   10 root     root          1024 Dec  8 09:24 .
drwxr-xr-x   18 root     root          1024 Dec  8 09:22 ..
drwxr-xr-x    2 root     root          1024 Mar  9  2018 backups
drwxr-xr-x    2 root     root          1024 Mar  9  2018 cache
drwxr-xr-x    4 root     root          1024 Mar  9  2018 lib
drwxr-xr-x    2 root     root          1024 Mar  9  2018 local
lrwxrwxrwx    1 root     root             9 Dec  8 09:24 lock -> /run/lock
drwxr-xr-x    2 root     root          1024 Dec  8 09:24 log
lrwxrwxrwx    1 root     root             4 Dec  8 09:24 run -> /run
drwxr-xr-x    2 root     root          1024 Mar  9  2018 spool
drwxrwxrwt    2 root     root          1024 Mar  9  2018 tmp
drwxrwxrwt    4 root     root            80 Dec  8 09:24 volatile
root@qemux86-64:/var# mount | grep tmpfs
devtmpfs on /dev type devtmpfs (rw,relatime,size=1012164k,nr_inodes=253041,mode=755)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /var/volatile type tmpfs (rw,relatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,nr_inodes=1048576)
root@qemux86-64:/var# 

3.
systemd
VOLATILE_TMP_DIR="yes"
VOLATILE_LOG_DIR="yes"

root@qemux86-64:/# ls -al /tmp
lrwxrwxrwx    1 root     root             8 Dec  8 08:49 /tmp -> /var/tmp
           8 Dec  8 08:49 /tmp -> /var/tmp
root@qemux86-64:/# cd /var/
root@qemux86-64:/var# ls -al tmp
lrwxrwxrwx    1 root     root            12 Mar  9  2018 tmp -> volatile/tmp
root@qemux86-64:/var# ls -al log
lrwxrwxrwx    1 root     root            12 Mar  9  2018 log -> volatile/log
root@qemux86-64:/var# mount | grep tmp
devtmpfs on /dev type devtmpfs (rw,relatime,size=1012160k,nr_inodes=253040,mode=755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run type tmpfs (rw,nosuid,nodev,size=405732k,nr_inodes=819200,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,size=4096k,nr_inodes=1024,mode=755)
tmpfs on /var/volatile type tmpfs (rw,relatime)
root@qemux86-64:/var# 

4.
systemd
VOLATILE_TMP_DIR="no"
VOLATILE_LOG_DIR="no"

root@qemux86-64:/# ls -al
drwxr-xr-x   17 root     root          1024 Dec  8 09:16 .
drwxr-xr-x   17 root     root          1024 Dec  8 09:16 ..
lrwxrwxrwx    1 root     root             7 Mar  9  2018 bin -> usr/bin
drwxr-xr-x    2 root     root          1024 Mar  9  2018 boot
drwxr-xr-x   14 root     root          3260 Dec  8 09:16 dev
drwxr-xr-x   21 root     root          3072 Dec  8 09:16 etc
drwxr-xr-x    3 root     root          1024 Mar  9  2018 home
lrwxrwxrwx    1 root     root             7 Mar  9  2018 lib -> usr/lib
drwx------    2 root     root         12288 Dec  8 09:16 lost+found
drwxr-xr-x    2 root     root          1024 Mar  9  2018 media
drwxr-xr-x    2 root     root          1024 Mar  9  2018 mnt
dr-xr-xr-x  173 root     root             0 Dec  8 09:16 proc
drwx------    3 root     root          1024 Dec  8 09:16 root
drwxr-xr-x   11 root     root           320 Dec  8 09:16 run
lrwxrwxrwx    1 root     root             8 Mar  9  2018 sbin -> usr/sbin
drwxr-xr-x    2 root     root          1024 Mar  9  2018 srv
dr-xr-xr-x   12 root     root             0 Dec  8 09:16 sys
drwxrwxrwt    9 root     root           180 Dec  8 09:16 tmp
drwxr-xr-x   10 root     root          1024 Mar  9  2018 usr
drwxr-xr-x   10 root     root          1024 Dec  8 09:16 var
root@qemux86-64:/# cd /var/
root@qemux86-64:/var# ls -al
drwxr-xr-x   10 root     root          1024 Dec  8 09:16 .
drwxr-xr-x   17 root     root          1024 Dec  8 09:16 ..
-rw-r--r--    1 root     root           208 Mar  9  2018 .updated
drwxr-xr-x    2 root     root          1024 Mar  9  2018 backups
drwxr-xr-x    4 root     root          1024 Dec  8 09:16 cache
drwxr-xr-x    6 root     root          1024 Dec  8 09:16 lib
drwxr-xr-x    2 root     root          1024 Mar  9  2018 local
lrwxrwxrwx    1 root     root            11 Mar  9  2018 lock -> ../run/lock
drwxr-xr-x    4 root     root          1024 Dec  8 09:16 log
lrwxrwxrwx    1 root     root             6 Mar  9  2018 run -> ../run
drwxr-xr-x    3 root     root          1024 Mar  9  2018 spool
drwxrwxrwt    5 root     root          1024 Dec  8 09:16 tmp
drwxrwxrwt    2 root     root            40 Dec  8 09:16 volatile
root@qemux86-64:/var# mount | grep tmpfs
devtmpfs on /dev type devtmpfs (rw,relatime,size=1012164k,nr_inodes=253041,mode=755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run type tmpfs (rw,nosuid,nodev,size=405732k,nr_inodes=819200,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,size=4096k,nr_inodes=1024,mode=755)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,nr_inodes=1048576)
tmpfs on /var/volatile type tmpfs (rw,relatime)
root@qemux86-64:/var# 

5.
SysVinit
VOLATILE_TMP_DIR="yes"
VOLATILE_LOG_DIR="no"

root@qemux86-64:/# ls -al
drwxr-xr-x   17 root     root          1024 Dec  8 09:40 .
drwxr-xr-x   17 root     root          1024 Dec  8 09:40 ..
drwxr-xr-x    2 root     root          3072 Mar  9  2018 bin
drwxr-xr-x    2 root     root          1024 Mar  9  2018 boot
drwxr-xr-x   13 root     root          2960 Dec  8 09:40 dev
drwxr-xr-x   20 root     root          1024 Dec  8 09:40 etc
drwxr-xr-x    3 root     root          1024 Mar  9  2018 home
drwxr-xr-x    6 root     root          1024 Mar  9  2018 lib
drwx------    2 root     root         12288 Dec  8 09:40 lost+found
drwxr-xr-x    2 root     root          1024 Mar  9  2018 media
drwxr-xr-x    2 root     root          1024 Mar  9  2018 mnt
dr-xr-xr-x  159 root     root             0 Dec  8 09:40 proc
drwxr-xr-x    4 root     root           240 Dec  8 09:40 run
drwxr-xr-x    2 root     root          3072 Mar  9  2018 sbin
dr-xr-xr-x   12 root     root             0 Dec  8 09:40 sys
lrwxrwxrwx    1 root     root             8 Dec  8 09:40 tmp -> /var/tmp
drwxr-xr-x    9 root     root          1024 Mar  9  2018 usr
drwxr-xr-x    9 root     root          1024 Dec  8 09:40 var
root@qemux86-64:/# cd /var/
root@qemux86-64:/var# ls -al 
drwxr-xr-x    9 root     root          1024 Dec  8 09:40 .
drwxr-xr-x   17 root     root          1024 Dec  8 09:40 ..
drwxr-xr-x    2 root     root          1024 Mar  9  2018 backups
drwxr-xr-x    2 root     root          1024 Mar  9  2018 cache
drwxr-xr-x    4 root     root          1024 Mar  9  2018 lib
drwxr-xr-x    2 root     root          1024 Mar  9  2018 local
lrwxrwxrwx    1 root     root             9 Dec  8 09:40 lock -> /run/lock
drwxr-xr-x    2 root     root          1024 Dec  8 09:40 log
lrwxrwxrwx    1 root     root             4 Dec  8 09:40 run -> /run
drwxr-xr-x    2 root     root          1024 Mar  9  2018 spool
lrwxrwxrwx    1 root     root            17 Dec  8 09:40 tmp -> /var/volatile/tmp
drwxrwxrwt    3 root     root            60 Dec  8 09:40 volatile
root@qemux86-64:/var# mount | grep tmp
devtmpfs on /dev type devtmpfs (rw,relatime,size=1012164k,nr_inodes=253041,mode=755)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /var/volatile type tmpfs (rw,relatime)
root@qemux86-64:/var# 

6.
systemd
VOLATILE_TMP_DIR="no"
VOLATILE_LOG_DIR="yes"

root@qemux86-64:/# ls -al
drwxr-xr-x   17 root     root          1024 Dec  8 09:46 .
drwxr-xr-x   17 root     root          1024 Dec  8 09:46 ..
lrwxrwxrwx    1 root     root             7 Mar  9  2018 bin -> usr/bin
drwxr-xr-x    2 root     root          1024 Mar  9  2018 boot
drwxr-xr-x   14 root     root          3260 Dec  8 09:46 dev
drwxr-xr-x   21 root     root          3072 Dec  8 09:46 etc
drwxr-xr-x    3 root     root          1024 Mar  9  2018 home
lrwxrwxrwx    1 root     root             7 Mar  9  2018 lib -> usr/lib
drwx------    2 root     root         12288 Dec  8 09:44 lost+found
drwxr-xr-x    2 root     root          1024 Mar  9  2018 media
drwxr-xr-x    2 root     root          1024 Mar  9  2018 mnt
dr-xr-xr-x  173 root     root             0 Dec  8 09:46 proc
drwx------    3 root     root          1024 Dec  8 09:46 root
drwxr-xr-x   11 root     root           320 Dec  8 09:46 run
lrwxrwxrwx    1 root     root             8 Mar  9  2018 sbin -> usr/sbin
drwxr-xr-x    2 root     root          1024 Mar  9  2018 srv
dr-xr-xr-x   12 root     root             0 Dec  8 09:46 sys
drwxrwxrwt    9 root     root           180 Dec  8 09:46 tmp
drwxr-xr-x   10 root     root          1024 Mar  9  2018 usr
drwxr-xr-x    9 root     root          1024 Dec  8 09:46 var
root@qemux86-64:/# cd /var/
root@qemux86-64:/var# ls -al
drwxr-xr-x    9 root     root          1024 Dec  8 09:46 .
drwxr-xr-x   17 root     root          1024 Dec  8 09:46 ..
-rw-r--r--    1 root     root           208 Mar  9  2018 .updated
drwxr-xr-x    2 root     root          1024 Mar  9  2018 backups
drwxr-xr-x    4 root     root          1024 Dec  8 09:46 cache
drwxr-xr-x    6 root     root          1024 Dec  8 09:46 lib
drwxr-xr-x    2 root     root          1024 Mar  9  2018 local
lrwxrwxrwx    1 root     root            11 Mar  9  2018 lock -> ../run/lock
lrwxrwxrwx    1 root     root            12 Mar  9  2018 log -> volatile/log
lrwxrwxrwx    1 root     root             6 Mar  9  2018 run -> ../run
drwxr-xr-x    3 root     root          1024 Mar  9  2018 spool
drwxrwxrwt    5 root     root          1024 Dec  8 09:46 tmp
drwxrwxrwt    3 root     root            60 Dec  8 09:46 volatile
root@qemux86-64:/var# mount | grep tmp
devtmpfs on /dev type devtmpfs (rw,relatime,size=1012164k,nr_inodes=253041,mode=755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run type tmpfs (rw,nosuid,nodev,size=405732k,nr_inodes=819200,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,size=4096k,nr_inodes=1024,mode=755)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,nr_inodes=1048576)
tmpfs on /var/volatile type tmpfs (rw,relatime)
root@qemux86-64:/var# 

Changqing Li (5):
bitbake.conf: set correct FILESYSTEM_PERMS_TABLES
base-files: update dirs1777 and volatiles according to
VOLATILE_TMP_DIR
initscripts: support persistent tmp
systemd: support persistent tmp
eudev: create dir /tmp if persistent tmp is used

 meta/conf/bitbake.conf                        |  5 ++-
 ...fs-perms.txt => fs-perms-volatile-log.txt} | 32 -------------------
 ...tent-log.txt => fs-perms-volatile-tmp.txt} | 27 ----------------
 meta/files/fs-perms.txt                       |  3 --
 .../base-files/base-files_3.0.14.bb           |  8 +++--
 .../initscripts/initscripts-1.0/volatiles     |  1 +
 .../initscripts/initscripts_1.0.bb            | 12 ++++---
 .../systemd/systemd/00-create-volatile.conf   |  3 +-
 meta/recipes-core/systemd/systemd_254.4.bb    | 23 +++++++++----
 meta/recipes-core/udev/eudev_3.2.14.bb        |  4 +++
 10 files changed, 40 insertions(+), 78 deletions(-)
 copy meta/files/{fs-perms.txt => fs-perms-volatile-log.txt} (53%)
 rename meta/files/{fs-perms-persistent-log.txt => fs-perms-volatile-tmp.txt} (59%)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/5 bitbake.conf: set correct FILESYSTEM_PERMS_TABLES

From: Changqing Li <[email protected]>

* Update fs-perms.txt as an common fs-perms file
* Remove fs-perms-persistent-log.txt
* Add fs-perms-volatile-log.txt and fs-perms-volatile-tmp.txt to be used when VOLATILE_LOG_DIR/VOLATILE_TMP_DIR set to yes

---
 meta/conf/bitbake.conf                        |  5 ++-
 ...fs-perms.txt => fs-perms-volatile-log.txt} | 32 -------------------
 ...tent-log.txt => fs-perms-volatile-tmp.txt} | 27 ----------------
 meta/files/fs-perms.txt                       |  3 --
 4 files changed, 4 insertions(+), 63 deletions(-)
 copy meta/files/{fs-perms.txt => fs-perms-volatile-log.txt} (53%)
 rename meta/files/{fs-perms-persistent-log.txt => fs-perms-volatile-tmp.txt} (59%)
meta/conf/bitbake.conf +4 -1
index e7826e7af9..2a8dd2f972 100644
@@ -384,7 +384,10 @@ FILESEXTRAPATHS ?= "__default:"
 #  datadir, sysconfdir, servicedir, sharedstatedir, localstatedir, infodir,
 #  mandir, docdir, bindir, sbindir, libexecdir, libdir, includedir and
 #  oldincludedir
-FILESYSTEM_PERMS_TABLES ?= "${@'files/fs-perms.txt' if oe.types.boolean(d.getVar('VOLATILE_LOG_DIR')) else 'files/fs-perms-persistent-log.txt'}"
+FILESYSTEM_PERMS_TABLES ?=  " files/fs-perms.txt \
+                              ${@'files/fs-perms-volatile-log.txt' if oe.types.boolean(d.getVar('VOLATILE_LOG_DIR')) else ''} \
+                              ${@'files/fs-perms-volatile-tmp.txt' if oe.types.boolean(d.getVar('VOLATILE_TMP_DIR')) else ''} \
+                            "
 
 ##################################################################
 # General work and output directories for the build system.
meta/files/fs-perms-volatile-log.txt renamed from meta/files/fs-perms.txt +0 -32
similarity index 53%
copy from meta/files/fs-perms.txt
copy to meta/files/fs-perms-volatile-log.txt
index 48191f504c..fc846bbdc5 100644
@@ -28,39 +28,7 @@
 # Note: all standard config directories are automatically assigned "0755 root root false - - -"
 
 # Documentation should always be corrected
-${mandir}		0755	root	root	true	0644	root	root
-${infodir}		0755	root	root	true	0644	root	root
-${docdir}		0755	root	root	true	0644	root	root
-${datadir}/gtk-doc	0755	root	root	true	0644	root	root
-
-# Fixup locales
-${datadir}/locale	0755	root	root	true	0644	root	root
-
-# Cleanup headers
-${includedir}		0755	root	root	true	0644	root	root
-
-# Cleanup debug src
-/usr/src/debug		0755	root	root	true	0644	root	root
 
 # Items from base-files
 # Links
-${localstatedir}/run	link	/run
 ${localstatedir}/log	link	volatile/log
-${localstatedir}/lock	link	/run/lock
-${localstatedir}/tmp	link	volatile/tmp
-
-/home				0755	root	root	false - - -
-/srv				0755	root	root	false - - -
-${prefix}/src			0755	root	root	false - - -
-${localstatedir}/local		0755	root	root	false - - -
-
-# Special permissions from base-files
-# Set 1777
-/tmp				01777	root	root	false - - -
-${localstatedir}/volatile/tmp	01777	root	root	false - - -
-
-# Set 0700
-${ROOT_HOME}			0700	root	root	false - - -
-
-# Set 2775-lsb
-${localstatedir}/mail		02775	root	mail	false - - -
meta/files/fs-perms-volatile-tmp.txt renamed from meta/files/fs-perms-persistent-log.txt +0 -27
similarity index 59%
rename from meta/files/fs-perms-persistent-log.txt
rename to meta/files/fs-perms-volatile-tmp.txt
index 61f0a6e26a..26247acda8 100644
@@ -28,38 +28,11 @@
 # Note: all standard config directories are automatically assigned "0755 root root false - - -"
 
 # Documentation should always be corrected
-${mandir}		0755	root	root	true	0644	root	root
-${infodir}		0755	root	root	true	0644	root	root
-${docdir}		0755	root	root	true	0644	root	root
-${datadir}/gtk-doc	0755	root	root	true	0644	root	root
-
-# Fixup locales
-${datadir}/locale	0755	root	root	true	0644	root	root
-
-# Cleanup headers
-${includedir}		0755	root	root	true	0644	root	root
-
-# Cleanup debug src
-/usr/src/debug		0755	root	root	true	0644	root	root
 
 # Items from base-files
 # Links
-${localstatedir}/run	link	/run
-${localstatedir}/lock	link	/run/lock
 ${localstatedir}/tmp	link	volatile/tmp
 
-/home				0755	root	root	false - - -
-/srv				0755	root	root	false - - -
-${prefix}/src			0755	root	root	false - - -
-${localstatedir}/local		0755	root	root	false - - -
-
 # Special permissions from base-files
 # Set 1777
-/tmp				01777	root	root	false - - -
 ${localstatedir}/volatile/tmp	01777	root	root	false - - -
-
-# Set 0700
-${ROOT_HOME}			0700	root	root	false - - -
-
-# Set 2775-lsb
-${localstatedir}/mail		02775	root	mail	false - - -
meta/files/fs-perms.txt +0 -3
index 48191f504c..d2266c1b26 100644
@@ -45,9 +45,7 @@ ${includedir}		0755	root	root	true	0644	root	root
 # Items from base-files
 # Links
 ${localstatedir}/run	link	/run
-${localstatedir}/log	link	volatile/log
 ${localstatedir}/lock	link	/run/lock
-${localstatedir}/tmp	link	volatile/tmp
 
 /home				0755	root	root	false - - -
 /srv				0755	root	root	false - - -
@@ -57,7 +55,6 @@ ${localstatedir}/local		0755	root	root	false - - -
 # Special permissions from base-files
 # Set 1777
 /tmp				01777	root	root	false - - -
-${localstatedir}/volatile/tmp	01777	root	root	false - - -
 
 # Set 0700
 ${ROOT_HOME}			0700	root	root	false - - -
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 2/5 base-files: update dirs1777 and volatiles according to VOLATILE_TMP_DIR

In reply to [email protected]

From: Changqing Li <[email protected]>

* update dirs1777 so that only create /var/volatiles/tmp when VOLATILE_TMP_DIR set to yes, create /var/tmp when VOLATILE_TMP_DIR set to no

* update volatiles so that only symlink /var/tmp to /var/volatiles/tmp when VOLATILE_TMP_DIR set to yes

* mount /tmp as tmpfs fs when VOLATILE_TMP_DIR set to no and init manager is sysvinit

---
 meta/recipes-core/base-files/base-files_3.0.14.bb | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
meta/recipes-core/base-files/base-files_3.0.14.bb +6 -2
index 9fab53ce63..b523c4aa62 100644
@@ -30,7 +30,7 @@ S = "${WORKDIR}"
 INHIBIT_DEFAULT_DEPS = "1"
 
 docdir:append = "/${P}"
-dirs1777 = "/tmp ${localstatedir}/volatile/tmp"
+dirs1777 = "/tmp ${localstatedir}/${@'volatile/' if oe.types.boolean('${VOLATILE_TMP_DIR}') else ''}tmp"
 dirs2775 = ""
 dirs555 = "/sys /proc"
 dirs755 = "/boot /dev ${base_bindir} ${base_sbindir} ${base_libdir} \
@@ -54,7 +54,8 @@ dirs755-lsb = "/srv  \
                ${prefix}/lib/locale"
 dirs2775-lsb = "/var/mail"
 
-volatiles = "${@'log' if oe.types.boolean('${VOLATILE_LOG_DIR}') else ''} tmp"
+volatiles = "${@'log' if oe.types.boolean('${VOLATILE_LOG_DIR}') else ''} \
+             ${@'tmp' if oe.types.boolean('${VOLATILE_TMP_DIR}') else ''}"
 conffiles = "${sysconfdir}/debian_version ${sysconfdir}/host.conf \
              ${sysconfdir}/issue /${sysconfdir}/issue.net \
              ${sysconfdir}/nsswitch.conf ${sysconfdir}/profile \
@@ -122,6 +123,9 @@ do_install () {
 	fi
 
 	install -m 0644 ${WORKDIR}/fstab ${D}${sysconfdir}/fstab
+	if [ ${@ oe.types.boolean('${VOLATILE_TMP_DIR}') } = False ] && ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'false', 'true', d)} ;then
+		echo "tmpfs   /tmp  tmpfs  mode=1777,strictatime,nosuid,nodev,size=50%,nr_inodes=1m   0  0" >> ${D}${sysconfdir}/fstab
+	fi
 	install -m 0644 ${WORKDIR}/profile ${D}${sysconfdir}/profile
 	sed -i 's#ROOTHOME#${ROOT_HOME}#' ${D}${sysconfdir}/profile
         sed -i 's#@BINDIR@#${bindir}#g' ${D}${sysconfdir}/profile
Signature · 1 line
2.25.1
#3 lore raw

PATCH v2 3/5 initscripts: support persistent tmp

In reply to [email protected]

From: Changqing Li <[email protected]>

* default volatiles file is for VOLATILE_TMP_DIR=yes, and VOLATILE_LOG_DIR=yes, if they set to no, remove volatile related config

* replace /var/volatile/tmp with /var/tmp for populate-volatile.sh

---
 .../initscripts/initscripts-1.0/volatiles            |  1 +
 meta/recipes-core/initscripts/initscripts_1.0.bb     | 12 +++++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)
meta/recipes-core/initscripts/initscripts-1.0/volatiles +1 -0
index cd8a4be05f..a280c47dda 100644
@@ -28,6 +28,7 @@ d root root 0755 /var/volatile/log none
 d root root 1777 /var/volatile/tmp none
 l root root 1777 /var/lock /run/lock
 l root root 0755 /var/run /run
+l root root 0755 /var/log /var/volatile/log
 l root root 1777 /var/tmp /var/volatile/tmp
 l root root 1777 /tmp /var/tmp
 d root root 0755 /var/lock/subsys none
meta/recipes-core/initscripts/initscripts_1.0.bb +7 -5
index 4b34c6a67f..c6a0d35dbf 100644
@@ -103,12 +103,14 @@ do_install () {
 	install -m 0755    ${WORKDIR}/read-only-rootfs-hook.sh ${D}${sysconfdir}/init.d
 	install -m 0755    ${WORKDIR}/save-rtc.sh	${D}${sysconfdir}/init.d
 	install -m 0644    ${WORKDIR}/volatiles		${D}${sysconfdir}/default/volatiles/00_core
-	if [ ${@ oe.types.boolean('${VOLATILE_LOG_DIR}') } = True ]; then
-		sed -i -e '\@^d root root 0755 /var/volatile/log none$@ a\l root root 0755 /var/log /var/volatile/log' \
-			${D}${sysconfdir}/default/volatiles/00_core
+	if [ ${@ oe.types.boolean('${VOLATILE_LOG_DIR}') } = False ]; then
+		sed -i -e '/^[d|l].*\/var\/volatile\/log/d' ${D}${sysconfdir}/default/volatiles/00_core
 	fi
-	if [ "${VOLATILE_TMP_DIR}" != "yes" ]; then
-		sed -i -e "/\<tmp\>/d" ${D}${sysconfdir}/default/volatiles/00_core
+	if [ ${@ oe.types.boolean('${VOLATILE_TMP_DIR}') } = False ]; then
+		sed -i -e "/^[d|l].*\/var\/volatile\/tmp/d" ${D}${sysconfdir}/default/volatiles/00_core
+		sed -i -e "/^l.*\/tmp/d" ${D}${sysconfdir}/default/volatiles/00_core
+		sed -i -e 's;TMPROOT="${ROOT_DIR}/var/volatile/tmp";TMPROOT="${ROOT_DIR}/var/tmp";g' \
+			${D}${sysconfdir}/init.d/populate-volatile.sh
 	fi
 	install -m 0755    ${WORKDIR}/dmesg.sh		${D}${sysconfdir}/init.d
 	install -m 0644    ${WORKDIR}/logrotate-dmesg.conf ${D}${sysconfdir}/
Signature · 1 line
2.25.1
#4 lore raw

PATCH v2 4/5 systemd: support persistent tmp

In reply to [email protected]

From: Changqing Li <[email protected]>

* update 00-create-volatile.conf, for volatile tmp, make /tmp -> /var/tmp, /var/tmp -> /var/volatile/tmp and set age of /var/volatile/tmp to 10d

* if VOLATILE_TMP_DIR/VOLATILE_LOG_DIR set to no, remove volatile related configs from 00-create-volatile.conf

---
 .../systemd/systemd/00-create-volatile.conf   |  3 ++-
 meta/recipes-core/systemd/systemd_254.4.bb    | 22 +++++++++++++------
 2 files changed, 17 insertions(+), 8 deletions(-)
meta/recipes-core/systemd/systemd/00-create-volatile.conf +2 -1
index c4277221a2..860f2783ef 100644
@@ -5,4 +5,5 @@
 
 d		/run/lock		1777	-	-	-
 d		/var/volatile/log		-	-	-	-
-d		/var/volatile/tmp		1777	-	-
+d		/var/volatile/tmp		1777	-	-   10d
+L+      /tmp                   1777    root   root   -     /var/tmp
meta/recipes-core/systemd/systemd_254.4.bb +15 -7
index 0c12926bef..01ef5cfd7b 100644
@@ -289,6 +289,21 @@ do_install() {
 	done
 
 	install -m 0644 ${WORKDIR}/00-create-volatile.conf ${D}${nonarch_libdir}/tmpfiles.d/
+	if [ ${@ oe.types.boolean('${VOLATILE_LOG_DIR}') } = False ]; then
+		sed -i -e "/^d.*\/var\/volatile\/log/d" ${D}${nonarch_libdir}/tmpfiles.d/00-create-volatile.conf
+	fi
+
+	if [ ${@ oe.types.boolean('${VOLATILE_TMP_DIR}') } = False ]; then
+		sed -i -e "/^d.*\/var\/volatile\/tmp/d" ${D}${nonarch_libdir}/tmpfiles.d/00-create-volatile.conf
+		sed -i -e "/^L+.*\/tmp/d" ${D}${nonarch_libdir}/tmpfiles.d/00-create-volatile.conf
+	else
+		# For volatile tmp, /tmp link to /var/tmp, /var/tmp links to /var/volatile/tmp, so don't need
+		# mount /tmp again
+		rm -f ${D}${systemd_unitdir}/system/tmp.mount
+		rm -f ${D}${systemd_unitdir}/system/local-fs.target.wants/tmp.mount
+		# The age are set in 00-create-volatile.conf
+		rm -rf ${D}${nonarch_libdir}/tmpfiles.d/tmp.conf
+	fi
 
 	if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then
 		install -d ${D}${sysconfdir}/init.d
@@ -308,13 +323,6 @@ do_install() {
 		rm -rf ${D}${localstatedir}/log/journal/remote
 	fi
 
-	# if the user requests /tmp be on persistent storage (i.e. not volatile)
-	# then don't use a tmpfs for /tmp
-	if [ "${VOLATILE_TMP_DIR}" != "yes" ]; then
-		rm -f ${D}${rootlibdir}/systemd/system/tmp.mount
-		rm -f ${D}${rootlibdir}/systemd/system/local-fs.target.wants/tmp.mount
-	fi
-
 	install -d ${D}${systemd_system_unitdir}/graphical.target.wants
 	install -d ${D}${systemd_system_unitdir}/multi-user.target.wants
 	install -d ${D}${systemd_system_unitdir}/poweroff.target.wants
Signature · 1 line
2.25.1
#5 lore raw

PATCH v2 5/5 eudev: create dir /tmp if persistent tmp is used

In reply to [email protected]

From: Changqing Li <[email protected]>

the automount rule for udev needs /tmp directory available, if VOLATILE_TMP_DIR = yes, to make sure /var/volatile/tmp exist, if VOLATILE_TMP_DIR = no, to make sure /tmp exist.

---
 meta/recipes-core/udev/eudev_3.2.14.bb | 4 ++++
 1 file changed, 4 insertions(+)
meta/recipes-core/udev/eudev_3.2.14.bb +4 -0
index d0758691bd..56c2e453b7 100644
@@ -50,6 +50,10 @@ do_install:append() {
 
 	# Use classic network interface naming scheme
 	touch ${D}${sysconfdir}/udev/rules.d/80-net-name-slot.rules
+
+	if [ ${@ oe.types.boolean('${VOLATILE_TMP_DIR}') } = False ]; then
+		sed -i -e 's%mkdir -m 1777 -p /var/volatile/tmp%mkdir -m 1777 -p /tmp%g' ${D}${sysconfdir}/init.d/udev
+	fi
 }
 
 do_install:prepend:class-target () {
Signature · 1 line
2.25.1