From: Ralph Boehme Date: Fri, 29 Nov 2019 15:28:54 +0000 (+0000) Subject: s3:lib: add put_long_date_full_timespec() X-Git-Tag: ldb-2.1.0~420 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b1a3445e3dbd9c08bc733377f7c3b95a9e8d2755;p=thirdparty%2Fsamba.git s3:lib: add put_long_date_full_timespec() put_long_date_full_timespec() will be used in the fileserver to marshall struct timespec timestamps that are sent to the client. By using full_timespec_to_nt_time() which supports tv_sec=0 and negative values, we can return timestamps to clients with a date before the UNIX epoch. BUG: https://bugzilla.samba.org/show_bug.cgi?id=7771 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/include/proto.h b/source3/include/proto.h index 7683d3eefbb..992c7462316 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -287,6 +287,9 @@ void srv_put_dos_date2(char *buf,int offset, time_t unixdate); void srv_put_dos_date3(char *buf,int offset,time_t unixdate); void round_timespec(enum timestamp_set_resolution res, struct timespec *ts); void put_long_date_timespec(enum timestamp_set_resolution res, char *p, struct timespec ts); +void put_long_date_full_timespec(enum timestamp_set_resolution res, + char *p, + const struct timespec *ts); void put_long_date(char *p, time_t t); void dos_filetime_timespec(struct timespec *tsp); time_t make_unix_date(const void *date_ptr, int zone_offset); diff --git a/source3/lib/time.c b/source3/lib/time.c index e81ecfe3f46..a5882f3d8ff 100644 --- a/source3/lib/time.c +++ b/source3/lib/time.c @@ -171,6 +171,18 @@ void put_long_date_timespec(enum timestamp_set_resolution res, char *p, struct t SBVAL(p, 0, nt); } +void put_long_date_full_timespec(enum timestamp_set_resolution res, + char *p, + const struct timespec *_ts) +{ + struct timespec ts = *_ts; + NTTIME nt; + + round_timespec(res, &ts); + nt = full_timespec_to_nt_time(&ts); + SBVAL(p, 0, nt); +} + void put_long_date(char *p, time_t t) { struct timespec ts;