Skip to content

Commit 32939ea

Browse files
committed
Uptime (NetBSD): fix invalid result
1 parent bdd87a6 commit 32939ea

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/detection/uptime/uptime_bsd.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66

77
const char* ffDetectUptime(FFUptimeResult* result)
88
{
9+
#if __NetBSD__
10+
struct timespec bootTime;
11+
#else
912
struct timeval bootTime;
13+
#endif
1014
size_t bootTimeSize = sizeof(bootTime);
1115
if(sysctl(
1216
(int[]) {CTL_KERN, KERN_BOOTTIME}, 2,
@@ -15,7 +19,11 @@ const char* ffDetectUptime(FFUptimeResult* result)
1519
) != 0)
1620
return "sysctl({CTL_KERN, KERN_BOOTTIME}) failed";
1721

22+
#if __NetBSD__
23+
result->bootTime = (uint64_t) bootTime.tv_sec * 1000 + (uint64_t) bootTime.tv_nsec / 10000000;
24+
#else
1825
result->bootTime = (uint64_t) bootTime.tv_sec * 1000 + (uint64_t) bootTime.tv_usec / 1000;
26+
#endif
1927
result->uptime = ffTimeGetNow() - result->bootTime;
2028

2129
return NULL;

0 commit comments

Comments
 (0)