[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%)