1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

lib: add full_timespec_to_nt_time()

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-12-04 12:11:05 +01:00 committed by Jeremy Allison
parent eb42beeb1b
commit b5dc6aa720
2 changed files with 26 additions and 0 deletions

View File

@ -1014,3 +1014,28 @@ struct timespec make_omit_timespec(void)
{ {
return (struct timespec){.tv_nsec = SAMBA_UTIME_OMIT}; return (struct timespec){.tv_nsec = SAMBA_UTIME_OMIT};
} }
/**
* Like unix_timespec_to_nt_time() but without the special casing of tv_sec=0
* and -1. Also dealing with SAMBA_UTIME_OMIT.
**/
NTTIME full_timespec_to_nt_time(const struct timespec *ts)
{
uint64_t d;
if (ts->tv_sec == TIME_T_MAX) {
return 0x7fffffffffffffffLL;
}
if (is_omit_timespec(ts)) {
return 0;
}
d = ts->tv_sec;
d += TIME_FIXUP_CONSTANT_INT;
d *= 1000*1000*10;
/* d is now in 100ns units. */
d += (ts->tv_nsec / 100);
return d;
}

View File

@ -341,5 +341,6 @@ NTTIME unix_timespec_to_nt_time(struct timespec ts);
*/ */
bool is_omit_timespec(const struct timespec *ts); bool is_omit_timespec(const struct timespec *ts);
struct timespec make_omit_timespec(void); struct timespec make_omit_timespec(void);
NTTIME full_timespec_to_nt_time(const struct timespec *ts);
#endif /* _SAMBA_TIME_H_ */ #endif /* _SAMBA_TIME_H_ */