<p dir="ltr">Usually we don't do this kind of fallback, but rather disable the relevant functionality if the lib is not available.</p>
<p dir="ltr">In this case I guess it means making support for .mount units optional. I could imagine someone doing that in very specialised use cases, but maybe it makes more sense to make the library a hard dependency for now...</p>
<p dir="ltr">Cheers,</p>
<p dir="ltr">Tom</p>
<div class="gmail_quote">On 7 Nov 2014 06:11, "Chris Leech" <<a href="mailto:cleech@redhat.com">cleech@redhat.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This lets libmount add in user options from /run/mount/utab, like<br>
_netdev which is needed to get proper ordering against remote-fs.target<br>
---<br>
.travis.yml | 2 +-<br>
Makefile.am | 4 +++-<br>
README | 1 +<br>
<a href="http://configure.ac" target="_blank">configure.ac</a> | 13 ++++++++++++<br>
src/core/build.h | 7 +++++++<br>
src/core/mount.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br>
6 files changed, 87 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/.travis.yml b/.travis.yml<br>
index 7e5251c..4ea2bc2 100644<br>
--- a/.travis.yml<br>
+++ b/.travis.yml<br>
@@ -3,7 +3,7 @@ compiler:<br>
- gcc<br>
before_install:<br>
- sudo apt-get update -qq<br>
- - sudo apt-get install autotools-dev automake autoconf libtool libdbus-1-dev libcap-dev libblkid-dev libpam-dev libcryptsetup-dev libaudit-dev libacl1-dev libattr1-dev libselinux-dev liblzma-dev libgcrypt-dev libqrencode-dev libmicrohttpd-dev gtk-doc-tools gperf python2.7-dev<br>
+ - sudo apt-get install autotools-dev automake autoconf libtool libdbus-1-dev libcap-dev libblkid-dev libmount-dev libpam-dev libcryptsetup-dev libaudit-dev libacl1-dev libattr1-dev libselinux-dev liblzma-dev libgcrypt-dev libqrencode-dev libmicrohttpd-dev gtk-doc-tools gperf python2.7-dev<br>
script: ./autogen.sh && ./configure --enable-gtk-doc --enable-gtk-doc-pdf && make V=1 && sudo ./systemd-machine-id-setup && make check && make distcheck<br>
after_failure: cat test-suite.log<br>
notifications:<br>
diff --git a/Makefile.am b/Makefile.am<br>
index 461ffa9..3deffe8 100644<br>
--- a/Makefile.am<br>
+++ b/Makefile.am<br>
@@ -1163,6 +1163,7 @@ libsystemd_core_la_CFLAGS = \<br>
$(KMOD_CFLAGS) \<br>
$(APPARMOR_CFLAGS) \<br>
$(SECCOMP_CFLAGS) \<br>
+ $(MOUNT_CFLAGS) \<br>
-pthread<br>
<br>
libsystemd_core_la_LIBADD = \<br>
@@ -1177,7 +1178,8 @@ libsystemd_core_la_LIBADD = \<br>
$(CAP_LIBS) \<br>
$(KMOD_LIBS) \<br>
$(APPARMOR_LIBS) \<br>
- $(SECCOMP_LIBS)<br>
+ $(SECCOMP_LIBS) \<br>
+ $(MOUNT_LIBS)<br>
<br>
if HAVE_SECCOMP<br>
libsystemd_core_la_LIBADD += \<br>
diff --git a/README b/README<br>
index aefb349..89abc3e 100644<br>
--- a/README<br>
+++ b/README<br>
@@ -108,6 +108,7 @@ REQUIREMENTS:<br>
libcap<br>
libseccomp >= 1.0.0 (optional)<br>
libblkid >= 2.20 (from util-linux) (optional)<br>
+ libmount >= 2.20 (from util-linux) (optional)<br>
libkmod >= 15 (optional)<br>
PAM >= 1.1.2 (optional)<br>
libcryptsetup (optional)<br>
diff --git a/<a href="http://configure.ac" target="_blank">configure.ac</a> b/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
index 05fc00d..85ff053 100644<br>
--- a/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
+++ b/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
@@ -426,6 +426,18 @@ fi<br>
AM_CONDITIONAL(HAVE_BLKID, [test "$have_blkid" = "yes"])<br>
<br>
# ------------------------------------------------------------------------------<br>
+have_libmount=no<br>
+AC_ARG_ENABLE(libmount, AS_HELP_STRING([--disable-libmount], [disable libmount support]))<br>
+if test "x$enable_libmount" != "xno"; then<br>
+ PKG_CHECK_MODULES(MOUNT, [ mount >= 2.20 ],<br>
+ [AC_DEFINE(HAVE_LIBMOUNT, 1, [Define if libmount is available]) have_libmount=yes], have_libmount=no)<br>
+ if test "x$have_libmount" = xno -a "x$enable_libmount" = xyes; then<br>
+ AC_MSG_ERROR([*** libmount support requested but libraries not found])<br>
+ fi<br>
+fi<br>
+AM_CONDITIONAL(HAVE_LIBMOUNT, [test "$have_libmount" = "yes"])<br>
+<br>
+# ------------------------------------------------------------------------------<br>
have_seccomp=no<br>
AC_ARG_ENABLE(seccomp, AS_HELP_STRING([--disable-seccomp], [Disable optional SECCOMP support]))<br>
if test "x$enable_seccomp" != "xno"; then<br>
@@ -1374,6 +1386,7 @@ AC_MSG_RESULT([<br>
efi: ${have_efi}<br>
kmod: ${have_kmod}<br>
blkid: ${have_blkid}<br>
+ libmount: ${have_libmount}<br>
dbus: ${have_dbus}<br>
nss-myhostname: ${have_myhostname}<br>
gudev: ${enable_gudev}<br>
diff --git a/src/core/build.h b/src/core/build.h<br>
index d5e5550..5644693 100644<br>
--- a/src/core/build.h<br>
+++ b/src/core/build.h<br>
@@ -117,6 +117,12 @@<br>
#define _BLKID_FEATURE_ "-BLKID"<br>
#endif<br>
<br>
+#ifdef HAVE_LIBMOUNT<br>
+#define _LIBMOUNT_FEATURE_ "+LIBMOUNT"<br>
+#else<br>
+#define _LIBMOUNT_FEATURE_ "-LIBMOUNT"<br>
+#endif<br>
+<br>
#ifdef HAVE_ELFUTILS<br>
#define _ELFUTILS_FEATURE_ "+ELFUTILS"<br>
#else<br>
@@ -152,6 +158,7 @@<br>
_LZ4_FEATURE_ " " \<br>
_SECCOMP_FEATURE_ " " \<br>
_BLKID_FEATURE_ " " \<br>
+ _LIBMOUNT_FEATURE_ " " \<br>
_ELFUTILS_FEATURE_ " " \<br>
_KMOD_FEATURE_ " " \<br>
_IDN_FEATURE_ " "<br>
diff --git a/src/core/mount.c b/src/core/mount.c<br>
index 8b787f6..a639515 100644<br>
--- a/src/core/mount.c<br>
+++ b/src/core/mount.c<br>
@@ -25,6 +25,12 @@<br>
#include <sys/epoll.h><br>
#include <signal.h><br>
<br>
+#ifdef HAVE_LIBMOUNT<br>
+#include <libmount.h><br>
+#else<br>
+#define mnt_init_debug(m) do {} while (0)<br>
+#endif<br>
+<br>
#include "manager.h"<br>
#include "unit.h"<br>
#include "mount.h"<br>
@@ -1492,6 +1498,58 @@ fail:<br>
return r;<br>
}<br>
<br>
+#ifdef HAVE_LIBMOUNT<br>
+<br>
+static inline void mnt_free_table_p(struct libmnt_table **tb) {<br>
+ mnt_free_table(*tb);<br>
+}<br>
+<br>
+static inline void mnt_free_iter_p(struct libmnt_iter **itr) {<br>
+ mnt_free_iter(*itr);<br>
+}<br>
+<br>
+static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {<br>
+ _cleanup_(mnt_free_table_p) struct libmnt_table *tb = NULL;<br>
+ _cleanup_(mnt_free_iter_p) struct libmnt_iter *itr = NULL;<br>
+ struct libmnt_fs *fs;<br>
+ int r = 0;<br>
+<br>
+ assert(m);<br>
+<br>
+ tb = mnt_new_table();<br>
+ itr = mnt_new_iter(MNT_ITER_FORWARD);<br>
+ if (!tb || !itr)<br>
+ return log_oom();<br>
+<br>
+ mnt_table_parse_mtab(tb, NULL);<br>
+ if (r)<br>
+ return r;<br>
+<br>
+ while (mnt_table_next_fs(tb, itr, &fs) == 0) {<br>
+ const char *device, *path, *options, *fstype;<br>
+ _cleanup_free_ const char *d = NULL, *p = NULL;<br>
+ int k;<br>
+<br>
+ device = mnt_fs_get_source(fs);<br>
+ path = mnt_fs_get_target(fs);<br>
+ options = mnt_fs_get_options(fs);<br>
+ fstype = mnt_fs_get_fstype(fs);<br>
+<br>
+ d = cunescape(device);<br>
+ p = cunescape(path);<br>
+ if (!d || !p)<br>
+ return log_oom();<br>
+<br>
+ k = mount_add_one(m, d, p, options, fstype, set_flags);<br>
+ if (k < 0)<br>
+ r = k;<br>
+ }<br>
+<br>
+ return r;<br>
+}<br>
+<br>
+#else<br>
+<br>
static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {<br>
int r = 0;<br>
unsigned i;<br>
@@ -1548,6 +1606,8 @@ static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {<br>
return r;<br>
}<br>
<br>
+#endif<br>
+<br>
static void mount_shutdown(Manager *m) {<br>
assert(m);<br>
<br>
@@ -1577,6 +1637,8 @@ static int mount_enumerate(Manager *m) {<br>
int r;<br>
assert(m);<br>
<br>
+ mnt_init_debug(0);<br>
+<br>
if (!m->proc_self_mountinfo) {<br>
m->proc_self_mountinfo = fopen("/proc/self/mountinfo", "re");<br>
if (!m->proc_self_mountinfo)<br>
--<br>
1.9.3<br>
<br>
_______________________________________________<br>
systemd-devel mailing list<br>
<a href="mailto:systemd-devel@lists.freedesktop.org">systemd-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/systemd-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/systemd-devel</a><br>
</blockquote></div>