aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert1999-06-18 05:49:18 +0000
committerPaul Eggert1999-06-18 05:49:18 +0000
commita48de9b290e29e49080696fae108e66ad811b481 (patch)
tree3f5f1926b375d927fd8848121583cd8eed3ae5bd /src
parent6693a99a2c8b3d61f0735ba093d3354276ca4f9d (diff)
downloademacs-a48de9b290e29e49080696fae108e66ad811b481.tar.gz
emacs-a48de9b290e29e49080696fae108e66ad811b481.zip
(BOOT_TIME_FILE): New macro.
(get_boot_time): Use it instead of hardwiring the file name. Check BOOT_TIME_FILE only after inspecting the kernel directly.
Diffstat (limited to 'src')
-rw-r--r--src/filelock.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/filelock.c b/src/filelock.c
index 9217b58f188..b671533161f 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -62,6 +62,12 @@ extern int errno;
62 62
63#include <utmp.h> 63#include <utmp.h>
64 64
65/* A file whose last-modified time is just after the most recent boot.
66 Define this to be NULL to disable checking for this file. */
67#ifndef BOOT_TIME_FILE
68#define BOOT_TIME_FILE "/var/run/random-seed"
69#endif
70
65#ifndef WTMP_FILE 71#ifndef WTMP_FILE
66#define WTMP_FILE "/var/log/wtmp" 72#define WTMP_FILE "/var/log/wtmp"
67#endif 73#endif
@@ -113,18 +119,11 @@ static time_t
113get_boot_time () 119get_boot_time ()
114{ 120{
115 int counter; 121 int counter;
116 struct stat st;
117 122
118 if (boot_time_initialized) 123 if (boot_time_initialized)
119 return boot_time; 124 return boot_time;
120 boot_time_initialized = 1; 125 boot_time_initialized = 1;
121 126
122 if (stat ("/var/run/random-seed", &st) == 0)
123 {
124 boot_time = st.st_mtime;
125 return boot_time;
126 }
127
128#if defined (CTL_KERN) && defined (KERN_BOOTTIME) 127#if defined (CTL_KERN) && defined (KERN_BOOTTIME)
129 { 128 {
130 int mib[2]; 129 int mib[2];
@@ -143,6 +142,16 @@ get_boot_time ()
143 } 142 }
144#endif /* defined (CTL_KERN) && defined (KERN_BOOTTIME) */ 143#endif /* defined (CTL_KERN) && defined (KERN_BOOTTIME) */
145 144
145 if (BOOT_TIME_FILE)
146 {
147 struct stat st;
148 if (stat (BOOT_TIME_FILE, &st) == 0)
149 {
150 boot_time = st.st_mtime;
151 return boot_time;
152 }
153 }
154
146#if defined (BOOT_TIME) && ! defined (NO_WTMP_FILE) 155#if defined (BOOT_TIME) && ! defined (NO_WTMP_FILE)
147#ifndef CANNOT_DUMP 156#ifndef CANNOT_DUMP
148 /* The utmp routines maintain static state. 157 /* The utmp routines maintain static state.