]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: build lsfd even if kcmp.h is not available
authorMasatake YAMATO <yamato@redhat.com>
Fri, 19 Jan 2024 20:06:58 +0000 (05:06 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Mon, 22 Jan 2024 12:39:12 +0000 (21:39 +0900)
As reported in #2691 by @rrrossi, lsfd was not built on the platform
where kcmp.h was not available. However, lsfd just uses kcmp(2) only
for optimization; it can work without kcmp.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
configure.ac
misc-utils/lsfd.c

index a03f3c4428f5b362993c97c20134422f5dfc9cf7..d89cf16a7101da13aff5cdaa6b662000533ffe5d 100644 (file)
@@ -1805,7 +1805,6 @@ AC_ARG_ENABLE([lsfd],
 UL_BUILD_INIT([lsfd])
 UL_REQUIRES_LINUX([lsfd])
 UL_REQUIRES_BUILD([lsfd], [libsmartcols])
-UL_REQUIRES_HAVE([lsfd], [linux_kcmp_h], [linux/kcmp.h header file])
 AM_CONDITIONAL([BUILD_LSFD], [test "x$build_lsfd" = xyes])
 
 AC_ARG_ENABLE([lslogins],
index cc6a00e374d7ca42d443870b6c1152d1c6d07bfc..2c1a880c4ea979dfb73ecbae378dec9a1a576b11 100644 (file)
 #include <sys/uio.h>
 #include <linux/sched.h>
 #include <sys/syscall.h>
-#include <linux/kcmp.h>
+
+#ifdef HAVE_LINUX_KCMP_H
+#  include <linux/kcmp.h>
 static int kcmp(pid_t pid1, pid_t pid2, int type,
                unsigned long idx1, unsigned long idx2)
 {
        return syscall(SYS_kcmp, pid1, pid2, type, idx1, idx2);
 }
+#else
+#  ifndef KCMP_FS
+#    define KCMP_FS 0
+#  endif
+#  ifndef KCMP_VM
+#    define KCMP_VM 0
+#  endif
+#  ifndef KCMP_FILES
+#    define KCMP_FILES 0
+#  endif
+static int kcmp(pid_t pid1 __attribute__((__unused__)),
+               pid_t pid2 __attribute__((__unused__)),
+               int type __attribute__((__unused__)),
+               unsigned long idx1 __attribute__((__unused__)),
+               unsigned long idx2 __attribute__((__unused__)))
+{
+       /* lsfd uses kcmp only for optimization. If the platform doesn't provide
+        * kcmp, just returning an error is acceptable. */
+       errno = ENOSYS;
+       return -1;
+}
+#endif
 
 /* See proc(5).
  * Defined in linux/include/linux/sched.h private header file. */