Skip to content

Commit

Permalink
lklfuse: set lkl clock time to the host walltime
Browse files Browse the repository at this point in the history
This ensures that file times aren't stuck around Epoch.

Signed-off-by: David Disseldorp <[email protected]>
  • Loading branch information
ddiss committed May 30, 2024
1 parent 3c57c31 commit 71ef8cc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tools/lkl/lklfuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,13 +509,30 @@ static int start_lkl(void)
{
long ret;
char mpoint[32];
struct timespec walltime;
struct lkl_timespec ts;

ret = lkl_start_kernel("mem=%dM", lklfuse.mb);
if (ret) {
fprintf(stderr, "can't start kernel: %s\n", lkl_strerror(ret));
goto out;
}

/* forward host walltime to lkl */
ret = clock_gettime(CLOCK_REALTIME, &walltime);
if (ret < 0)
goto out_halt;

ts = (struct lkl_timespec){ tv_sec: walltime.tv_sec,
tv_nsec: walltime.tv_nsec };
ret = lkl_sys_clock_settime(LKL_CLOCK_REALTIME,
(struct __lkl__kernel_timespec *)&ts);
if (ret < 0) {
fprintf(stderr, "lkl_sys_clock_settime() failed: %s\n",
lkl_strerror(ret));
goto out_halt;
}

ret = lkl_mount_dev(lklfuse.disk_id, lklfuse.part, lklfuse.type,
lklfuse.ro ? LKL_MS_RDONLY : 0, lklfuse.opts,
mpoint, sizeof(mpoint));
Expand Down

0 comments on commit 71ef8cc

Please sign in to comment.