[RFC] XDG_RUNTIME_DIR

Lennart Poettering mzkqt at 0pointer.de
Sat Nov 13 14:28:08 PST 2010


On Sat, 13.11.10 23:12, Mikkel Kamstrup Erlandsen (mikkel.kamstrup at gmail.com) wrote:

> It's not totally clear from the discussions on this list, what kind of
> items you intend to go in XDG_USER_DIR? As I read it we are mainly
> talking sockets, fifos, pid-files and such. However what about stuff
> with non-negligible size - downloads in progress, short lived caches,
> etc. I unpack tonnes of source packages that I always forget to delete
> - will XDG_RUNTIME_DIR be suitible for this?

No. $XDG_CACHE_HOME is for that, or /tmp.

The point of XDG_RUNTIME_DIR is to place stuff there that is needed
mostly as a communication primitive in one form or another. I.e. it's
supposed to be a place where servers and clients can easily discover
each other, without any security hassle in regards to shared
namespaces. As such it is very much comparable to FHS /var/run, except
that it is per-user.

http://www.pathname.com/fhs/pub/fhs-2.3.html#VARRUNRUNTIMEVARIABLEDATA

> Something about the garbage collection scheme triggers my complexity
> alarm bell. Time based GC seems like something that might be tricky to
> get right (both for the session manager, but maybe even more clients
> will not take the nature of the GC properly into account when using
> it). I'd rather like something more deterministic. "When there are no
> file handles on a file it's deleted" - might be too aggressive, but is
> definitely clear cut :-)

Well, except for the point that such a scheme is not really
implementable on current OSes (neither is there an API to figure ot
whether any process is referencing a file, and even if we had that
things would be complex to do right, because you'd need an atomic
'delete-unless-referenced' syscall and stuff) and also not applicable to
stuff like PID files for example.

> I heard mention of using it for mmap()ed files - but if the runtime
> dir is on a tmpfs (and not swapped) that would seem to undermine the
> value of mmapping it - or am I misunderstanding something?

Hmm? tmpfs and mmap mix very well, not sure what you are intending to
say. Note that /dev/shm is usually tmpfs as well.

> What path do you propose for XDG_RUNTIME_DIR? I can think of many
> possibilities - ~/.runtime, /var/users/$login/runtime,
> ~/.runtime/$session_specific_uid..?

systemd implements this as /var/run/user/$USER.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the xdg mailing list