Hi, Willy
Hi Zhangjin,
On Sat, Jul 08, 2023 at 02:38:57AM +0800, Zhangjin Wu wrote:
create a /tmp directory and mount tmpfs there, if tmpfs is not mountable, use ramfs as tmpfs.
tmpfs will be used instead of procfs for some tests.
Just curious, in which cases do you need this ? We're building an initramfs for the root that's already read-write, so without mounting anything you already have write access. I'm taking it anyway for now, but if you figure it's not needed we can later drop it (or just drop the mount part and keep mkdir).
This "/tmp" directory is originally created to check the 'TMPFS' existence for the old vfprintf/memfd_create (from old version of the minimal config support), it is used to skip the whole vfprintf tests if the TMPFS (or HUGETLBFS) is not there. BTW, Thomas's patch [1] shows, MEMFD_CREATE is able to work with ramfs too.
And it is later used by the old chmod_tmpdir/chmod_tmpfile and chroot_tmpfile too (from old version of the minimal config support), so, it is important to align with the normal Linux systems to let "/tmp" means TMPFS mount.
Now, we use "/tmp" directly in vfprintf, and we use argv0 for chmod_exe and chroot_exe, so, the only user of "/tmp" is vfprintf currently. In this case, it is a simple normal writable directory to allow create tmp files there, so, agree very much to only reserve the mkdir part:
/* create /tmp if not there. Silently fail otherwise */ mkdir("/tmp", 0755);
Another consideration before is whether it is required to be consistent with the normal Linux systems, let the "/tmp" directory mounted as tmpfs at most of the time, but "/tmp" means ramfs for CONFIG_TMPFS=n currently even mount it explicitly (ramfs is a fallback of tmpfs in such case), so, this assumption of "/tmp" means tmpfs is not true currently.
What I'm worried about is people in the future assume "/tmp" as tmpfs at the first glance and use the features only provided by TMPFS but not provided by RAMFS (I'm not sure which one they will use). so, I even tried to create a "/tmp/tmpfs" flag for TMPFS and "/tmp/ramfs" flag for RAMFS before, since there is no user to explicitly prefer TMPFS to RAMFS currently, at last, I removed these flags from the sent patchsets. Based on the same logic, The removal of tmpfs mount is of course ok.
So, Willy, is it ok for you to remove that mount line with corresponding update of the commit message (and the subject title), or require me to send a revision for this patch?
Best regards, Zhangjin
--- [1]: https://lore.kernel.org/lkml/20230703224803.GF4378@monkey/
Willy