Get current time in seconds in kernel module Get current time in seconds in kernel module c c

Get current time in seconds in kernel module


You can use getnstimeofday for that.

/* getnstimeofday - Returns the time of day in a timespec */void getnstimeofday(struct timespec *ts)

where struct timespec is:

struct timespec {    time_t  tv_sec;     /* seconds */    long    tv_nsec;    /* nanoseconds */};

And yes, you'll need #include <linux/time.h>.