libc: Move the declaration of futimens from sys/time.h to sys/stat.h

to follow the spec here:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Id8e418794bd43827c01af772ce704a8d3e7681c5
This commit is contained in:
Xiang Xiao 2021-07-09 02:34:11 +08:00 committed by Gustavo Henrique Nihei
parent 643ee82e9c
commit bae265274a
3 changed files with 45 additions and 46 deletions

View File

@ -171,6 +171,7 @@ int lstat(FAR const char *path, FAR struct stat *buf);
int fstat(int fd, FAR struct stat *buf); int fstat(int fd, FAR struct stat *buf);
int chmod(FAR const char *path, mode_t mode); int chmod(FAR const char *path, mode_t mode);
int fchmod(int fd, mode_t mode); int fchmod(int fd, mode_t mode);
int futimens(int fd, const struct timespec times[2]);
mode_t umask(mode_t mask); mode_t umask(mode_t mask);

View File

@ -341,30 +341,32 @@ int setitimer(int which, FAR const struct itimerval *value,
* Name: utimes * Name: utimes
* *
* Description: * Description:
* The utimes() function shall set the access and modification times of the * The utimes() function shall set the access and modification times of
* file pointed to by the path argument to the value of the times argument. * the file pointed to by the path argument to the value of the times
* utimes() function allows time specifications accurate to the microsecond. * argument. utimes() function allows time specifications accurate to
* the microsecond.
* For utimes(), the times argument is an array of timeval structures. The *
* first array member represents the date and time of last access, and the * For utimes(), the times argument is an array of timeval structures.
* second member represents the date and time of last modification. The times * The first array member represents the date and time of last access,
* in the timeval structure are measured in seconds and microseconds since * and the second member represents the date and time of last
* the Epoch, although rounding toward the nearest second may occur. * modification. The times in the timeval structure are measured in
* seconds and microseconds since the Epoch, although rounding toward
* If the times argument is a null pointer, the access and modification times * the nearest second may occur.
* of the file shall be set to the current time. The effective user ID of the *
* process shall match the owner of the file, has write access to the file or * If the times argument is a null pointer, the access and modification
* appropriate privileges to use this call in this manner. Upon completion, * times of the file shall be set to the current time. The effective
* utimes() shall mark the time of the last file status change, st_ctime, for * user ID of the process shall match the owner of the file, has write
* update. * access to the file or appropriate privileges to use this call in this
* manner. Upon completion, utimes() shall mark the time of the last
* file status change, st_ctime, for update.
* *
* Input Parameters: * Input Parameters:
* path - Specifies the file to be modified * path - Specifies the file to be modified
* times - Specifies the time value to set * times - Specifies the time value to set
* *
* Returned Value: * Returned Value:
* Upon successful completion, 0 shall be returned. Otherwise, -1 shall be * Upon successful completion, 0 shall be returned. Otherwise, -1 shall
* returned and errno shall be set to indicate the error, and the file * be returned and errno shall be set to indicate the error, and the file
* times shall not be affected. * times shall not be affected.
* *
****************************************************************************/ ****************************************************************************/
@ -375,45 +377,22 @@ int utimes(FAR const char *path, const struct timeval times[2]);
* Name: futimes * Name: futimes
* *
* Description: * Description:
* futimens() update the timestamps of a file with nanosecond precision. * futimes() update the timestamps of a file with microsecond precision.
* This contrasts with the historical utime(2) and utimes(2), which permit * With futimes() the file whose timestamps are to be updated is specified
* only second and microsecond precision, respectively, when setting file * via an open file descriptor, fd.
* timestamps. With futimens() the file whose timestamps are to be updated
* is specified via an open file descriptor, fd.
* *
* Input Parameters: * Input Parameters:
* fd - Specifies the fd to be modified * fd - Specifies the fd to be modified
* times - Specifies the time value to set * times - Specifies the time value to set
* *
* Returned Value: * Returned Value:
* On success, futimens() return 0. * On success, futimes() return 0.
* On error, -1 is returned and errno is set to indicate the error. * On error, -1 is returned and errno is set to indicate the error.
* *
****************************************************************************/ ****************************************************************************/
int futimes(int fd, const struct timeval tv[2]); int futimes(int fd, const struct timeval tv[2]);
/****************************************************************************
* Name: futimes
*
* Description:
* futimens() update the timestamps of a file with nanosecond precision.
* This contrasts with the historical utime(2) and utimes(2), which permit
* only second and microsecond precision, respectively, when setting file
* timestamps.
*
* Input Parameters:
* fd - Specifies the fd to be modified
* times - Specifies the time value to set
*
* Returned Value:
* On success, futimens() return 0.
* On error, -1 is returned and errno is set to indicate the error.
*
****************************************************************************/
int futimens(int fd, const struct timespec times[2]);
/**************************************************************************** /****************************************************************************
* Name: gethrtime * Name: gethrtime
* *

View File

@ -24,13 +24,32 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/time.h> #include <sys/stat.h>
#include <errno.h> #include <errno.h>
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Name: futimens
*
* Description:
* futimens() update the timestamps of a file with nanosecond precision.
* This contrasts with the historical utime(2) and utimes(2), which permit
* only second and microsecond precision, respectively, when setting file
* timestamps.
*
* Input Parameters:
* fd - Specifies the fd to be modified
* times - Specifies the time value to set
*
* Returned Value:
* On success, futimens() return 0.
* On error, -1 is returned and errno is set to indicate the error.
*
****************************************************************************/
int futimens(int fd, const struct timespec times[2]) int futimens(int fd, const struct timespec times[2])
{ {
set_errno(ENOTSUP); set_errno(ENOTSUP);