libc: Implement futimes on top of futimens

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ie54de66ca1bc26a68f2922861e1edd1fdabb8f33
This commit is contained in:
Xiang Xiao
2021-07-09 11:32:33 +08:00
committed by Gustavo Henrique Nihei
parent 800acff10e
commit 76cd9c89bb
+14 -5
View File
@@ -22,10 +22,8 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <errno.h>
/****************************************************************************
* 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);
}