[systemd-devel] [PATCH] cdrom_id: unmount media on --eject-media if media mounted

Lennart Poettering lennart at poettering.net
Thu Jan 15 08:05:54 PST 2015


On Thu, 15.01.15 15:24, Robert Milasan (rmilasan at suse.com) wrote:

> Signed-off-by: Robert Milasan <rmilasan at suse.com>

Humm, I am not convinced that this is really a good idea, first of all
it's pretty incomplete, given that there atons of ways how a device
can be kept busy, and mounts are just one of it. And even mounts might
keept things busy in many different ways, for example because of
overlayfs, or inner bind mounts or whatnot...

I think the best way to fix this is in the kernel properly. And if the
kernel folks are not willing to do add code for that, then I think
it's still better to make sure systemd unmounts it. It can do so
asynchronously, simply via the right dependencies. In fact, are you
sure that this isn't handled properly yet anyway? The .mount units
would just need a BindsTo= on the .device units, and the right thing
should happen?

> +static int media_umount(const char *node)
> +{
> +        int err = 0;
> +
> +        if (!node) {
> +                err = -1;
> +                goto exit;
> +        }

Please never return "fake" error codes like -1 in new code. We use
negative errno pretty universally these days.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list