1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

lib: add functions dealing with struct timespec UTIME_OMIT

BUG: https://bugzilla.samba.org/show_bug.cgi?id=7771

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Ralph Boehme 2019-11-26 17:22:17 +00:00 committed by Jeremy Allison
parent 96418cb156
commit eb42beeb1b
2 changed files with 32 additions and 0 deletions

View File

@ -991,3 +991,26 @@ _PUBLIC_ NTTIME unix_timespec_to_nt_time(struct timespec ts)
return d;
}
/*
* Functions supporting the full range of time_t and struct timespec values,
* including 0, -1 and all other negative values. These functions don't use 0 or
* -1 values as sentinel to denote "unset" variables, but use the POSIX 2008
* define UTIME_OMIT from utimensat(2).
*/
/**
* Check if it's a to be omitted timespec.
**/
bool is_omit_timespec(const struct timespec *ts)
{
return ts->tv_nsec == SAMBA_UTIME_OMIT;
}
/**
* Return a to be omitted timespec.
**/
struct timespec make_omit_timespec(void)
{
return (struct timespec){.tv_nsec = SAMBA_UTIME_OMIT};
}

View File

@ -333,4 +333,13 @@ void round_timespec_to_usec(struct timespec *ts);
void round_timespec_to_nttime(struct timespec *ts);
NTTIME unix_timespec_to_nt_time(struct timespec ts);
/*
* Functions supporting the full range of time_t and struct timespec values,
* including 0, -1 and all other negative values. These functions don't use 0 or
* -1 values as sentinel to denote "unset" variables, but use the POSIX 2008
* define UTIME_OMIT from utimensat(2).
*/
bool is_omit_timespec(const struct timespec *ts);
struct timespec make_omit_timespec(void);
#endif /* _SAMBA_TIME_H_ */