From: Carlos Santos <casantos@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@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
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On 10/16/19 1:22 PM, casantos@redhat.com wrote:
> From: Carlos Santos <casantos@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@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
Well, in fact glibc has the _PATH_MOUNTED defined in paths.h too but
only thanks to mntent.h including paths.h (to define deprecated MOUNTED
macro) we are not hitting error there. Therefore, we can and should
always include paths.h. IOW, those ifndef-s can be dropped.
>
> 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"
>
Michal
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2026 Red Hat, Inc.