Hi, Richard

I had send a similar patch before, subjected as "bitbake.conf: support persistent /var/tmp",

and you have replied me with some concerns on 2021/9/13.  But I noticed that another variable VOLATILE_TMP_DIR is added in 2023.

but as I tested, it not works, so I make this patch to make it work for both sysV and systemd. Not sure if you still have those concerns now,

so just kindly ping to check.

Thanks

Changqing

On 12/11/23 08:58, Changqing Li wrote:
From: Changqing Li<changqing...@windriver.com>

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




-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#193346): 
https://lists.openembedded.org/g/openembedded-core/message/193346
Mute This Topic: https://lists.openembedded.org/mt/103100474/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to