summaryrefslogtreecommitdiffstats
path: root/src/detection/uptime/uptime_sunos.c
blob: 2a372999e8c4217f7e1eb8b7406f3f82ebde71c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "uptime.h"
#include "common/time.h"

#include <utmpx.h>

const char* ffDetectUptime(FFUptimeResult* result) {
    struct utmpx* ut;

    setutxent();
    while (NULL != (ut = getutxent())) {
        if (ut->ut_type == BOOT_TIME) {
            result->bootTime = (uint64_t) ut->ut_tv.tv_sec * 1000 + (uint64_t) ut->ut_tv.tv_usec / 1000000;
            result->uptime = ffTimeGetNow() - result->bootTime;
            break;
        }
    }
    endutxent();
    return NULL;
}