+2023-08-12 Bruno Haible <bruno@clisp.org>
+
+ readutmp: On Linux, don't fail if /var/run/utmp is not accessible.
+ * lib/boot-time-aux.h (get_linux_boot_time_final_fallback): Don't test
+ NEED_BOOT_TIME_FINAL_FALLBACK.
+ * lib/boot-time.c (NEED_BOOT_TIME_FINAL_FALLBACK): Remove macro.
+ * lib/readutmp.c (NEED_BOOT_TIME_FINAL_FALLBACK): Remove macro.
+ (read_utmp_from_file): As a fallback on Linux, invoke
+ get_linux_boot_time_final_fallback.
+ (get_boot_time_uncached): Don't do it here.
+ * m4/readutmp.m4 (gl_READUTMP): Add $CLOCK_TIME_LIB to READUTMP_LIB.
+
2023-08-12 Bruno Haible <bruno@clisp.org>
readutmp, boot-time: On Haiku, return the boot time.
return -1;
}
-# if NEED_BOOT_TIME_FINAL_FALLBACK
-
/* The following approach is only usable as a fallback, because it is of
the form
boot_time = (time now) - (kernel's ktime_get_boottime[_ts64] ())
return -1;
}
-# endif
-
#endif
#if defined __ANDROID__
#include "unlocked-io.h"
/* Some helper functions. */
-#define NEED_BOOT_TIME_FINAL_FALLBACK 1
#include "boot-time-aux.h"
/* The following macros describe the 'struct UTMP_STRUCT_NAME',
#include "unlocked-io.h"
/* Some helper functions. */
-#define NEED_BOOT_TIME_FINAL_FALLBACK READUTMP_USE_SYSTEMD
#include "boot-time-aux.h"
/* The following macros describe the 'struct UTMP_STRUCT_NAME',
# endif
+# if defined __linux__ && !defined __ANDROID__
+ if ((options & (READ_UTMP_USER_PROCESS | READ_UTMP_NO_BOOT_TIME)) == 0
+ && strcmp (file, UTMP_FILE) == 0
+ && !have_boot_time (a))
+ {
+ struct timespec boot_time;
+ if (get_linux_boot_time_final_fallback (&boot_time) >= 0)
+ a = add_utmp (a, options,
+ "reboot", strlen ("reboot"),
+ "", 0,
+ "~", strlen ("~"),
+ "", 0,
+ 0, BOOT_TIME, boot_time, 0, 0, 0);
+ }
+
+# endif
+
# if HAVE_SYS_SYSCTL_H && HAVE_SYSCTL \
&& defined CTL_KERN && defined KERN_BOOTTIME \
&& !defined __minix
free (utmp);
}
- {
- struct timespec boot_time;
- if (get_linux_boot_time_final_fallback (&boot_time) >= 0)
- return boot_time;
- }
-
/* We shouldn't get here. */
return (struct timespec) {0};
}
-# readutmp.m4 serial 26
+# readutmp.m4 serial 27
dnl Copyright (C) 2002-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
fi
fi
fi
+ AC_REQUIRE([gl_CLOCK_TIME])
+ READUTMP_LIB="$READUTMP_LIB $CLOCK_TIME_LIB"
AC_SUBST([READUTMP_LIB])
gl_PREREQ_READUTMP_H