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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/16/19 1:22 PM, casantos@xxxxxxxxxx wrote:
From: Carlos Santos <casantos@xxxxxxxxxx>

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@xxxxxxxxxx>
---
  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@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux