Hi Ken, Thanks for the report.
> > First, there is a comment > > saying that /var/run/utmp is empty on Cygwin. This is not true, at > > least on my system. I'm running Cygwin 3.5.3, the latest stable > > release. In my Cygwin 3.5.3 installation, /var/run/utmp is empty. But anyway, since you already found the answer: > Specifically, in > boot-time.c:113, ut->ut_type != BOOT_TIME. As a result, get_boot_time > ends up calling get_windows_boot_time, which fails on my system because > of the cygdrive problem described in the next paragraph. OK, nothing to do here. > > Second, and more serious, is the use of /cygdrive/c to refer to the C: > > drive. In fact, users can set the "cygdrive prefix" to anything they > > want in /etc/fstab. For example, I use /mnt as the cygdrive prefix, so > > I would use /mnt/c for the C: drive. The correct way to use the > > cygdrive prefix is to use /proc/cygdrive. For example, /proc/cygdrive > > is a symlink to /mnt/ on my system. I did not know about /proc/cygdrive; thanks for teaching us. I guess it can be assumed that /proc/cygdrive exists, because unlike in Linux, there are no Docker containers and unlike in FreeBSD, there are no jails? I'm committing this patch: 2024-05-01 Bruno Haible <br...@clisp.org> readutmp, boot-time: Improve for some Cygwin installations. Reported by Ken Brown <kbr...@cornell.edu> in <https://lists.gnu.org/archive/html/bug-gnulib/2024-05/msg00008.html>. * lib/boot-time-aux.h (get_windows_boot_time): Use /proc/cygdrive/ instead of /cygdrive/. diff --git a/lib/boot-time-aux.h b/lib/boot-time-aux.h index 8b966fe691..a94cdb3f30 100644 --- a/lib/boot-time-aux.h +++ b/lib/boot-time-aux.h @@ -306,7 +306,8 @@ get_windows_boot_time (struct timespec *p_boot_time) process, namely C:\pagefile.sys. */ const char * const boot_touched_file = #if defined __CYGWIN__ && !defined _WIN32 - "/cygdrive/c/pagefile.sys" + /* It is more portable to use /proc/cygdrive/c than /cygdrive/c. */ + "/proc/cygdrive/c/pagefile.sys" #else "C:\\pagefile.sys" #endif