]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
build-sys: improve dependences for lib/procfs.c
authorKarel Zak <kzak@redhat.com>
Mon, 4 Apr 2022 11:17:44 +0000 (13:17 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 4 Apr 2022 11:20:40 +0000 (13:20 +0200)
* add #ifdefs when use statfs() and include statfs.h or vfs.h

Addresses: https://github.com/util-linux/util-linux/issues/1634
Signed-off-by: Karel Zak <kzak@redhat.com>
configure.ac
include/statfs_magic.h
lib/procfs.c
misc-utils/hardlink.c

index 3fba95336a5b60b277d90615089093901fec723e..11c86b9a70809cbade98539b17fb2e1186984ebb 100644 (file)
@@ -346,6 +346,7 @@ AC_CHECK_HEADERS([ \
        sys/socket.h \
        sys/sockio.h \
        sys/stat.h \
+       sys/statfs.h \
        sys/swap.h \
        sys/syscall.h \
        sys/sysmacros.h \
@@ -355,6 +356,7 @@ AC_CHECK_HEADERS([ \
        sys/types.h \
        sys/ucred.h \
        sys/un.h \
+       sys/vfs.h \
        sys/xattr.h \
        unistd.h \
        utmp.h \
index b6b0225e865aeb3c04610ecab177f3e95f1cc61a..67ad0af2595862795299f0bcdb7baa5778742185 100644 (file)
@@ -1,7 +1,9 @@
 #ifndef UTIL_LINUX_STATFS_MAGIC_H
 #define UTIL_LINUX_STATFS_MAGIC_H
 
-#include <sys/statfs.h>
+#ifdef HAVE_SYS_STATFS_H
+# include <sys/statfs.h>
+#endif
 
 /*
  * If possible then don't depend on internal libc __SWORD_TYPE type.
index 4d6d25b6d78eba56aada4cd9acacee4d2e69f656..0d58857c83b378cb1cb3baf00f88f992ff8dce1e 100644 (file)
@@ -6,9 +6,13 @@
  */
 #include <ctype.h>
 #include <unistd.h>
-#include <sys/vfs.h>
 #include <errno.h>
 
+#ifdef HAVE_SYS_VFS_H
+# include <sys/vfs.h>
+# include "statfs_magic.h"
+#endif
+
 #include "c.h"
 #include "pathnames.h"
 #include "procfs.h"
@@ -16,7 +20,6 @@
 #include "all-io.h"
 #include "debug.h"
 #include "strutils.h"
-#include "statfs_magic.h"
 
 static void procfs_process_deinit_path(struct path_cxt *pc);
 
@@ -356,6 +359,7 @@ int procfs_dirent_match_name(DIR *procfs, struct dirent *d, const char *name)
        return 0;
 }
 
+#ifdef HAVE_SYS_VFS_H
 /* checks if fd is file in a procfs;
  * returns 1 if true, 0 if false or couldn't determine */
 int fd_is_procfs(int fd)
@@ -375,7 +379,14 @@ int fd_is_procfs(int fd)
        } while (ret != 0);
 
        return st.f_type == STATFS_PROC_MAGIC;
+       return 0;
 }
+#else
+int fd_is_procfs(int fd __attribute__((__unused__)))
+{
+       return 0;
+}
+#endif
 
 static char *strdup_procfs_file(pid_t pid, const char *name)
 {
index dd55af12aab7903e6025d0a39ea020c2400300e8..08af2882c1359e41fba37377a08c9a18647b0f9f 100644 (file)
@@ -38,7 +38,7 @@
 #include <ctype.h>             /* tolower() */
 #include <sys/ioctl.h>
 
-#if defined(HAVE_LINUX_FIEMAP_H)
+#if defined(HAVE_LINUX_FIEMAP_H) && defined(HAVE_SYS_VFS_H)
 # include <linux/fs.h>
 # include <linux/fiemap.h>
 # ifdef FICLONE