[systemd-devel] [PATCH] x86: defconfig: Enable CONFIG_FHANDLE

Lennart Poettering mzxreary at 0pointer.de
Sun Nov 30 17:03:43 PST 2014


On Mon, 01.12.14 01:41, Richard Weinberger (richard at nod.at) wrote:

> CC'ing systemd folks.
> 
> Lennart, can you please explain why you need CONFIG_FHANDLE for systemd?
> Maybe I'm reading the source horrible wrong.

For two usecases:

a) Being able to detect if something is a mount point. The traditional
   way to do this is by stat()ing the dir in question and its parent
   and comparing st_dev. That logic is not able to detect bind mounts
   however, if destination and the place the mount is at are actually
   on the same file system... Thus we check the mount id too, if we
   can get our hands on it. This actually fixes real-life
   problems. For example time-based recursive clean-up logic in /tmp,
   where it is desirable that the clean up stops at
   submounts. However, we had reports where the clean-up fucked up
   people's home directories because they mounted them for some reason
   into some subdir in /tmp and they had /tmp and /home on the same
   fs.

b) Because we sometimes want to know the mount options used for
   specific file systems. For that you want to correlate
   /proc/self/mountinfo with a path in the fs. You can of course try
   to do path prefix matching and then fuck things up as soon as
   people do weird mounts on top of each other. Or you can use use the
   mount id name_to_handle tells you and look it up in
   /proc/self/mountinfo, and everything is clean and reliable.

We have no interest in the actual fhandle data. If you give us some
other syscall to figure out the mount id, we'd be delighted to use it
instead.

udev uses the logic described in b) to determine if /dev is a devtmpfs
instance. Since devtmpfs has the same fs magic as any other tmpfs we
cannot use the statfs() magic stuff to detect this case.

Lennart


More information about the systemd-devel mailing list