Use utmpx instead of utmp for Solaris
WHR
5 years ago
31 | 31 | #ifdef xPLATFORM_SOLARIS |
32 | 32 | #include <unistd.h> |
33 | 33 | #include <sys/time.h> |
34 | #include <utmp.h> | |
34 | #include <utmpx.h> | |
35 | 35 | #include <fcntl.h> |
36 | 36 | #endif |
37 | 37 |
171 | 171 | #ifdef PLATFORM_SOLARIS |
172 | 172 | time_t read_uptime(void) { |
173 | 173 | int fd; |
174 | struct utmp ut; | |
174 | struct utmpx ut; | |
175 | 175 | int found=0; |
176 | 176 | |
177 | fd = open (UTMP_FILE, O_RDONLY); | |
177 | fd = open(UTMPX_FILE, O_RDONLY); | |
178 | 178 | if (fd >= 0) { |
179 | 179 | while (!found) { |
180 | 180 | if (read(fd, &ut, sizeof(ut)) < 0) { |
186 | 186 | close(fd); |
187 | 187 | } |
188 | 188 | |
189 | if (found == 1) return time(0) - ut.ut_time; | |
189 | if (found == 1) return time(0) - ut.ut_tv.tv_sec; | |
190 | 190 | |
191 | 191 | return 0; |
192 | 192 | } |
331 | 331 | int createbootid(void) { |
332 | 332 | FILE *f; |
333 | 333 | int fd; |
334 | struct utmp ut; | |
334 | struct utmpx ut; | |
335 | 335 | int found = 0; |
336 | 336 | time_t bootid = 0; |
337 | 337 | |
338 | fd = open (UTMP_FILE, O_RDONLY); | |
338 | fd = open (UTMPX_FILE, O_RDONLY); | |
339 | 339 | if (fd >= 0) { |
340 | 340 | while(!found) { |
341 | 341 | if (read(fd, &ut, sizeof(ut)) < 0) { |
347 | 347 | close(fd); |
348 | 348 | } |
349 | 349 | |
350 | if (found == 1) bootid = ut.ut_time; | |
350 | if (found == 1) bootid = ut.ut_tv.tv_sec; | |
351 | 351 | |
352 | 352 | f = fopen(FILE_BOOTID, "w"); |
353 | 353 | if (!f) { |