Use the kernel internal variant of `clock_gettime`,
`uk_sys_clock_gettime`.
This helps avoid unnecessary execution of the syscall wrappers'
logic of syscall shim that would have otherwise been run through
`uk_syscall_r_clock_gettime`.
Lastly, since now RAMFS uses a definition available only through
posix-time, add a dependency to it in the Config.uk. Ideally,
this should have been a depends on HAVE_TIME and an imply, but seeing
that currently this is the only library offering us time services,
do it like this for now.
Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Andrei Tatar <andrei@unikraft.io>
GitHub-Closes: #1587
bool "ramfs: simple RAM file system"
default n
depends on LIBVFSCORE
+ select LIBPOSIX_TIME
#include <fcntl.h>
#include <vfscore/fs.h>
+#include <uk/posix-time.h>
+
/* 16 bits are enough for file mode as defined by POSIX, the rest we can use */
#define RAMFS_MODEMASK 0xffff
#define RAMFS_DELMODE 0x10000
struct timespec *time3)
{
struct timespec now;
+ int rc;
+
+ rc = uk_sys_clock_gettime(CLOCK_REALTIME, &now);
+ if (unlikely(rc)) {
+ /*
+ * We do not consider this a fatal error, but rather
+ * something that might indicate a misconfigured kernel.
+ * Just print the error and ignore.
+ */
+ uk_pr_err("Failed to set current time for vnode: %d\n", rc);
+ UK_ASSERT(rc < 0);
+ }
- clock_gettime(CLOCK_REALTIME, &now);
if (time1)
memcpy(time1, &now, sizeof(struct timespec));
if (time2)