s3:lib: add put_long_date_full_timespec()
authorRalph Boehme <slow@samba.org>
Fri, 29 Nov 2019 15:28:54 +0000 (15:28 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 6 Dec 2019 00:17:36 +0000 (00:17 +0000)
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 <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/include/proto.h
source3/lib/time.c

index 7683d3eefbbaef67946fce4139f2c3c27d5d6748..992c7462316eeba5970c6fa3d4582ac540e6edee 100644 (file)
@@ -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);
index e81ecfe3f461e8c16089cd42aa7b02f258db57ae..a5882f3d8ff5db0b84f44cdf712c3c9a9ad867b4 100644 (file)
@@ -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;