[systemd-devel] [PATCH v2 5/5] mount: auto-detect iSCSI and FCoE as requiring network

Lennart Poettering lennart at poettering.net
Fri Dec 12 11:11:54 PST 2014

On Fri, 05.12.14 15:54, Karel Zak (kzak at redhat.com) wrote:

> I have added struct libmnt_monitor to make this new interface easy to
> extend and usable for more resources (I'll probably also add mountinfo
> fd for findmnt(8), but this is irrelevant for systemd;-)
> All you need is:
>     mn = mnt_new_monitor();
>     fd = mnt_monitor_userspace_get_fd(mn, NULL);    /* utab monitor fd */
>     mnt_monitor_get_events(mn, fd, &ev.events);     /* EPOLLIN ... */
>     efd = epoll_create1(EPOLL_CLOEXEC);
> 	epoll_ctl(efd, EPOLL_CTL_ADD, fd, &ev);
>     ....
>     n = epoll_wait(efd, events, 1, -1);
>     id (n == 1 && mnt_monitor_is_changed(mn, fd) == 1)
> 		printf("%s: change detected\n", mnt_monitor_get_filename(mn, fd));
>     ....
>     mnt_unref_monitor(mn);
>     close(efd);
> I guess it's enough to add the 'fd' to systmed sd_event_add_io() and
> call mnt_table_parse_mtab() when a change is detected. (As already
> implemeted in the original Chris' patch.)

Karel, if I got this right, then the new monitor stuff will only wrap
inotify on utab, right? I think it would be useful if it would also
abstract notifications via /proc/self/mountinfo in it. To make the
interface easy for this and to be able to just hand out a single fd,
this would mean creating an epoll fd inside the lib, then adding the
inotify fd for utab to it, and then on top the EPOLLPRI watch on

This way apps would get the full set of notifications via your
library, without knowing what's going on underneath, and userspace
notifications and kernel notifications would come the same way. 

Does this make sense?


Lennart Poettering, Red Hat

More information about the systemd-devel mailing list