From 76cd9c89bba568cda5d4fd048707fc566bdbbdde Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Fri, 9 Jul 2021 11:32:33 +0800 Subject: [PATCH] libc: Implement futimes on top of futimens Signed-off-by: Xiang Xiao Change-Id: Ie54de66ca1bc26a68f2922861e1edd1fdabb8f33 --- libs/libc/unistd/lib_futimes.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/libs/libc/unistd/lib_futimes.c b/libs/libc/unistd/lib_futimes.c index 1029342a52..30616492f2 100644 --- a/libs/libc/unistd/lib_futimes.c +++ b/libs/libc/unistd/lib_futimes.c @@ -22,10 +22,8 @@ * Included Files ****************************************************************************/ -#include - +#include #include -#include /**************************************************************************** * Public Functions @@ -33,6 +31,17 @@ int futimes(int fd, const struct timeval tv[2]) { - set_errno(ENOTSUP); - return ERROR; + struct timespec times[2]; + + if (tv == NULL) + { + return futimens(fd, NULL); + } + + times[0].tv_sec = tv[0].tv_sec; + times[0].tv_nsec = tv[0].tv_usec * 1000; + times[1].tv_sec = tv[1].tv_sec; + times[1].tv_nsec = tv[1].tv_usec * 1000; + + return futimens(fd, times); }