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:
parent
eb42beeb1b
commit
b5dc6aa720
@ -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;
|
||||||
|
}
|
||||||
|
@ -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_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user