What is the standard way to get the current time in seconds (since the epoch) in a kernel module?
I have seen techniques involving getting xtime which are very long-
You can use getnstimeofday for that.
getnstimeofday
/* getnstimeofday - Returns the time of day in a timespec */ void getnstimeofday(struct timespec *ts)
where struct timespec is:
struct timespec
struct timespec { time_t tv_sec; /* seconds */ long tv_nsec; /* nanoseconds */ };
And yes, you'll need #include <linux/time.h>.
#include <linux/time.h>