]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: use futimens, check for all in configure.ac
authorKarel Zak <kzak@redhat.com>
Fri, 21 Nov 2014 10:38:11 +0000 (11:38 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 21 Nov 2014 10:38:11 +0000 (11:38 +0100)
It seems better to warn about --reload in ./configure if futimens or
inotify_init1 are missing.

The patch also replaces futimes() with futimens() to make the code
compatible with Uclibc.

Addresses: https://github.com/karelzak/util-linux/issues/133
Signed-off-by: Karel Zak <kzak@redhat.com>
configure.ac
term-utils/agetty.c

index 5ec30723603f3cf72c933049bf2663f9b0a11273..6c504b8e105f4ba51288162f99f276214416e099 100644 (file)
@@ -313,7 +313,6 @@ AC_CHECK_FUNCS([ \
        getrlimit \
        getsgnam \
        inotify_init \
-       inotify_init1 \
        jrand48 \
        lchown \
        llseek \
@@ -346,6 +345,8 @@ AC_FUNC_FSEEKO
 
 AC_CHECK_FUNCS([openat fstatat unlinkat], [have_openat=yes], [have_openat=no])
 AC_CHECK_FUNCS([ioperm iopl], [have_io=yes])
+AC_CHECK_FUNCS([futimens], [have_futimens=yes])
+AC_CHECK_FUNCS([inotify_init1], [have_inotify_init1=yes])
 
 dnl Old glibc requires -lrt
 AC_CHECK_FUNCS(clock_gettime, [], [
@@ -1052,6 +1053,11 @@ AC_ARG_ENABLE([agetty],
 )
 UL_BUILD_INIT([agetty])
 AM_CONDITIONAL([BUILD_AGETTY], [test "x$build_agetty" = xyes])
+AS_IF([test "x$have_futimens" = xyes -a "x$have_inotify_init1" = xyes ], [
+  AC_DEFINE([AGETTY_RELOAD], [1], [Enable agetty --reload feature])
+],[
+  AC_MSG_WARN([futimens or inotify_init1 not found; agetty(8) will not provide ---reload functionality])
+])
 
 
 AC_ARG_ENABLE([cramfs],
index f7ae570fbf84e020e731ce3b434f8a2ea2e967ee..9871a3685563e859de567395c29992972f8b0cf6 100644 (file)
 /*
  * agetty --reload
  */
-#define AGETTY_RELOAD                  /* enabled by default */
-
-#ifndef HAVE_INOTIFY_INIT1
-# undef AGETTY_RELOAD                  /* disable on systems without inotify */
-#endif
-
 #ifdef AGETTY_RELOAD
 # include <sys/inotify.h>
 # define AGETTY_RELOAD_FILENAME "/run/agetty.reload"   /* trigger file */
@@ -2499,7 +2493,7 @@ static void reload_agettys(void)
        if (fd < 0)
                err(EXIT_FAILURE, _("cannot open: %s"), AGETTY_RELOAD_FILENAME);
 
-       if (futimes(fd, NULL) < 0 || close(fd) < 0)
+       if (futimens(fd, NULL) < 0 || close(fd) < 0)
                err(EXIT_FAILURE, _("cannot touch file: %s"),
                    AGETTY_RELOAD_FILENAME);
 #else