[systemd-devel] Masking mount units

Lennart Poettering lennart at poettering.net
Mon Nov 18 22:46:05 UTC 2024


On Do, 14.11.24 14:25, Phillip Susi (phill at thesusis.net) wrote:

> Lennart Poettering <lennart at poettering.net> writes:
>
> > the BLKFLSBUF ioctl() works fine on block device fds open for read only.
>
> Oh, I might have to change that to use a read only open then.
>
> > I am not following anymore. As *long* *as* *the* lock is taken the
> > auto mounting doesn't happen. Once you release the lock then
> > everything will be reprobed and work as it always worked, including
> > auto-mounting.
>
> It is not about delaying the auto mounting, but *preventing it*
> entirely.

It *is* prevented. While you keep the lock open *no* events are
propagated from udev to its clients, hence no automounts will take
place. Any kernel reported event that happen while you keep the lock
will basically be eaten up by udev and not propagated on to rest of
userspace. They are sent to /dev/null if you so will. When you release
the lock once you are fully done (which might as well be 3h later, if
you like) however, then a single *new* event is *synthesized*, to get
the rest of userspace updated again on things. And yes, that *might*
cause userspace to automount things, and other stuff. But that's fine,
you explicit indicated you are now done with the device, hence others
can consume it again.

Or in other words: if you must, just take the frickin' lock the
*entire* time gparted runs, and nothing else will automount or
otherwise touch device while gparted runs.

Hence, again: just take the frickin' lock. It's the API you should be
using. Don't mask units or anything, that's entirely besides the
point and seriously broken.

Did I get through now? I really fail to see why the concept of a lock
is so difficult to grok?

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list