Codebase list uptimed / 777d6fc
Use utmpx instead of utmp for Solaris WHR 5 years ago
3 changed file(s) with 8 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
3131 #ifdef xPLATFORM_SOLARIS
3232 #include <unistd.h>
3333 #include <sys/time.h>
34 #include <utmp.h>
34 #include <utmpx.h>
3535 #include <fcntl.h>
3636 #endif
3737
171171 #ifdef PLATFORM_SOLARIS
172172 time_t read_uptime(void) {
173173 int fd;
174 struct utmp ut;
174 struct utmpx ut;
175175 int found=0;
176176
177 fd = open (UTMP_FILE, O_RDONLY);
177 fd = open(UTMPX_FILE, O_RDONLY);
178178 if (fd >= 0) {
179179 while (!found) {
180180 if (read(fd, &ut, sizeof(ut)) < 0) {
186186 close(fd);
187187 }
188188
189 if (found == 1) return time(0) - ut.ut_time;
189 if (found == 1) return time(0) - ut.ut_tv.tv_sec;
190190
191191 return 0;
192192 }
331331 int createbootid(void) {
332332 FILE *f;
333333 int fd;
334 struct utmp ut;
334 struct utmpx ut;
335335 int found = 0;
336336 time_t bootid = 0;
337337
338 fd = open (UTMP_FILE, O_RDONLY);
338 fd = open (UTMPX_FILE, O_RDONLY);
339339 if (fd >= 0) {
340340 while(!found) {
341341 if (read(fd, &ut, sizeof(ut)) < 0) {
347347 close(fd);
348348 }
349349
350 if (found == 1) bootid = ut.ut_time;
350 if (found == 1) bootid = ut.ut_tv.tv_sec;
351351
352352 f = fopen(FILE_BOOTID, "w");
353353 if (!f) {
3535 #ifdef PLATFORM_SOLARIS
3636 #include <unistd.h>
3737 #include <sys/time.h>
38 #include <utmp.h>
38 #include <utmpx.h>
3939 #include <fcntl.h>
4040 #endif
4141