-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
16 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* fsmon -- MIT - Copyright NowSecure 2015-2019 - [email protected] */ | ||
/* fsmon -- MIT - Copyright NowSecure 2015-2020 - [email protected] */ | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
|
@@ -57,6 +57,17 @@ static bool setup_signals() { | |
return res; | ||
} | ||
|
||
static uint64_t __sys_now(void) { | ||
uint64_t ret; | ||
struct timeval now; | ||
gettimeofday (&now, NULL); | ||
ret = now.tv_sec; | ||
ret <<= 20; | ||
ret |= now.tv_usec; | ||
//(sizeof (now.tv_sec) == 4 | ||
return ret; | ||
} | ||
|
||
static bool callback(FileMonitor *fm, FileMonitorEvent *ev) { | ||
if (fm->child) { | ||
if (fm->pid && ev->pid != fm->pid) { | ||
|
@@ -97,6 +108,10 @@ static bool callback(FileMonitor *fm, FileMonitorEvent *ev) { | |
if (ev->inode) { | ||
printf ("\"inode\":%d,", ev->inode); | ||
} | ||
if (ev->tstamp) { | ||
uint64_t now = __sys_now(); | ||
printf ("\"time\":%" PRId64 ",", now); | ||
} | ||
if (ev->tstamp) { | ||
printf ("\"timestamp\":%" PRId64 ",", ev->tstamp); | ||
} | ||
|