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

Robert Milasan rmilasan at suse.com
Thu Jan 15 06:47:51 PST 2015

On Thu, 15 Jan 2015 15:42:28 +0100
"Martin Pitt" <martin.pitt at ubuntu.com> wrote:

> Hey Robert,
> thanks for working on this!
> Robert Milasan [2015-01-15 15:24 +0100]:
> > +                        err = execl("/bin/umount", "/bin/umount",
> > node, NULL);
> If this succeeds, umount will completely "take over" the process, and
> cdrom_id is gone.
> This also isn't sufficient if there are multiple partitions, which
> even on CDs/DVDs isn't that uncommon (especially for operating
> systems).
> So I think this should instead find all mount points that belong to
> target, and call umount2(target, MNT_DETACH) on them. The actual
> "eject" program does that.

No its not, eject uses umount binary also, but yes it tries to find all
submounts too (I haven't seen a scenario like that).

I've tried using umount or umount2 function, but I need the actual
mount point, which would need another function to find it or find them.

> ... which leads me to the question: why don't we just call the actual
> "eject" program? Just to avoid that dependency?

Yes, we could do this, I didn't think of it :)

> Thanks,
> Martin

Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmilasan at suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A

More information about the systemd-devel mailing list