[libvirt] [PATCH 2/2] storage: fix build with musl libc

casantos at redhat.com casantos at redhat.com
Wed Oct 16 01:36:46 UTC 2019


From: Carlos Santos <casantos at redhat.com>

On musl _PATH_MOUNTED is defined in paths.h, not in mntent.h, which
causes compilation errors:

storage/storage_backend_fs.c: In function 'virStorageBackendFileSystemIsMounted':
storage/storage_backend_fs.c:255:23: error: '_PATH_MOUNTED' undeclared (first use in this function); did you mean 'XPATH_POINT'?
     if ((mtab = fopen(_PATH_MOUNTED, "r")) == NULL) {
                       ^~~~~~~~~~~~~
                       XPATH_POINT

Fix this including paths.h if _PATH_MOUNTED is still not defined after
including mntent.h. This also works with glibc and uClibc-ng.

Signed-off-by: Carlos Santos <casantos at redhat.com>
---
 src/storage/storage_backend_fs.c       | 3 +++
 src/storage/storage_backend_vstorage.c | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index ed677058ed..fafe2745cc 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -42,6 +42,9 @@ VIR_LOG_INIT("storage.storage_backend_fs");
 #if WITH_STORAGE_FS
 
 # include <mntent.h>
+#ifndef _PATH_MOUNTED
+# include <paths.h>
+#endif
 
 struct _virNetfsDiscoverState {
     const char *host;
diff --git a/src/storage/storage_backend_vstorage.c b/src/storage/storage_backend_vstorage.c
index cec21dccbf..685f78a22f 100644
--- a/src/storage/storage_backend_vstorage.c
+++ b/src/storage/storage_backend_vstorage.c
@@ -7,6 +7,9 @@
 #include "virlog.h"
 #include "virstring.h"
 #include <mntent.h>
+#ifndef _PATH_MOUNTED
+#include <paths.h>
+#endif
 #include <pwd.h>
 #include <grp.h>
 #include "storage_util.h"
-- 
2.18.1




More information about the libvir-list mailing list