diff options
author | Michael Biebl <biebl@debian.org> | 2013-07-06 00:13:29 +0200 |
---|---|---|
committer | Michael Biebl <biebl@debian.org> | 2013-07-06 00:13:29 +0200 |
commit | f5638ea86a8626b7e0e471d720359cb4e3d8cb1c (patch) | |
tree | fd1fffc1917bd10431c829e0a439c2a522ffda6d /runtime/msg.c | |
parent | c62e2e3b0f562a4ce54f7edcbb76400d90118717 (diff) | |
download | rsyslog-f5638ea86a8626b7e0e471d720359cb4e3d8cb1c.tar.gz |
Imported Upstream version 7.4.2upstream/7.4.2
Diffstat (limited to 'runtime/msg.c')
-rw-r--r-- | runtime/msg.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/runtime/msg.c b/runtime/msg.c index a5c5281..9d5fa88 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -2989,15 +2989,39 @@ uchar *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, break; case PROP_SYS_UPTIME: # ifndef HAVE_SYSINFO_UPTIME - /* An alternative on some systems (eg Solaris) is to scan - * /var/adm/utmpx for last boot time. - */ + /* An alternative on some systems (eg Solaris) is to scan + * /var/adm/utmpx for last boot time. + */ pRes = (uchar*) "UPTIME NOT available on this system"; *pbMustBeFreed = 0; + +# elif defined(__FreeBSD__) + + { + struct timespec tp; + + if(*pbMustBeFreed == 1) + free(pRes); + if((pRes = (uchar*) MALLOC(sizeof(uchar) * 32)) == NULL) { + RET_OUT_OF_MEMORY; + } + *pbMustBeFreed = 1; + + if(clock_gettime(CLOCK_UPTIME, &tp) == -1) { + *pPropLen = sizeof("**SYSCALL FAILED**") - 1; + return(UCHAR_CONSTANT("**SYSCALL FAILED**")); + } + + snprintf((char*) pRes, sizeof(uchar) * 32, "%ld", tp.tv_sec); + } + # else + { struct sysinfo s_info; + if(*pbMustBeFreed == 1) + free(pRes); if((pRes = (uchar*) MALLOC(sizeof(uchar) * 32)) == NULL) { RET_OUT_OF_MEMORY; } |