News for hackers. Stuff that matters.
Re:Save your disk, write files directly into RAM with /dev/shm by quotemstr on Thursday June 26, 2025 @07:59PM (#44392630)
> /dev/shm is typically world-writable by default:

You are relying on random implementation details instead of universal APIs that work across OSes and environments. Please stop.

So help me God, if I make a Linux system, I will make it _not_ have a /dev/shm just to avoid people relying on non-standard stuff for no good reason. Honestly, it's because of stuff like this that we need Docker.

Re:Save your disk, write files directly into RAM with /dev/shm by frollogaston on Thursday June 26, 2025 @08:06PM (#44392663)
/tmp isn't a standard place for RAM disk either, all it says is: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s18.htm...

I'm not really seeing a right or wrong here anyway unless you're distributing a script that's meant to run on all sorts of Linux systems. In which case you probably aren't concerned with the physical storage medium being used.

Re:Save your disk, write files directly into RAM with /dev/shm by quotemstr on Thursday June 26, 2025 @08:16PM (#44392723)
/tmp is literally POSIX:

https://pubs.opengroup.org/onlinepubs/9799919799/

It doesn't get more standard than that.

It's because of people doing random nonstandard shit that we need to Docker-ize a lot of software these days. People refuse to lift a single finger to adhere to conventions that let programs co-exist without simulating a whole god damn computational universe for each damn program.

Re:Save your disk, write files directly into RAM with /dev/shm by fluidcruft on Thursday June 26, 2025 @08:51PM (#44392902)
/tmp is not specified to be a RAM disk by POSIX. Just that things in there are considered to be not persistent after a program stops (with implications for backups and disaster recovery). Sure, RAM disks work if the amount of /tmp space you need is less than your free physical RAM but sometimes that's not the case, either.

Back in the day you might place /tmp in a good spot for random access of small files on a disk platter. /var is vaguely similar but intended for things that need to be persistent.

Anyway it's not uncommon for systems to persist /tmp and clean it periodically from cron using various retention heuristics.

Ultimately POSIX concepts of mountpoints are strongly tied to optimizing spinning rust performance and maintenance and not necessarily relevant for SSD/NVME.

Re:Save your disk, write files directly into RAM with /dev/shm by gyesxnuibh on Thursday June 26, 2025 @08:26PM (#44392770)
> /tmp A directory made available for applications that need a place to create temporary files. Applications shall be allowed to create files in this directory, but shall not assume that such files are preserved between invocations of the application.

It doesn't say anything about what it's backed by.

Re:Save your disk, write files directly into RAM with /dev/shm by frollogaston on Thursday June 26, 2025 @08:23PM (#44392751)
I meant the author specifically wants to write files to RAM and nowhere else. There isn't a standard place for that.
Re:Save your disk, write files directly into RAM with /dev/shm by half-kh-hacker on Thursday June 26, 2025 @08:05PM (#44392659)
file-hierarchy(7) states /dev/shm is tmpfs and that "all users have write access to this directory", so I think you'd have to be making a non-systemd distro
Re:Save your disk, write files directly into RAM with /dev/shm by hackyhacky on Thursday June 26, 2025 @08:15PM (#44392718)
It also says:

> Usually, it is a better idea to use memory mapped files in /run/ (for system programs) or $XDG_RUNTIME_DIR (for user programs) instead of POSIX shared memory segments, since these directories are not world-writable and hence not vulnerable to security-sensitive name clashes.

$XDG_RUNTIME_DIR usually points to /run/user/${uid}, so you're guaranteed that other users won't write there, and possibly won't even be able to read there.