From c69f92d16d57c2387d31b5dfd01aab0685a671d0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 24 Aug 2009 20:57:37 -0700 Subject: Second attempt at fix for bug 6529 - Offline files conflict with Vista and Office 2003. Confirmation from reporter that this fixes the issue in master on ext3/ext4. Back-ports to follow. Jeremy. --- source3/lib/time.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/time.c b/source3/lib/time.c index a9f7899c7b..f6ff6d3407 100644 --- a/source3/lib/time.c +++ b/source3/lib/time.c @@ -301,14 +301,30 @@ void srv_put_dos_date3(char *buf,int offset,time_t unixdate) put_dos_date3(buf, offset, unixdate, server_zone_offset); } +void round_timespec(enum timestamp_set_resolution res, struct timespec *ts) +{ + switch (res) { + case TIMESTAMP_SET_SECONDS: + round_timespec_to_sec(ts); + break; + case TIMESTAMP_SET_MSEC: + round_timespec_to_usec(ts); + break; + case TIMESTAMP_SET_NT_OR_BETTER: + /* No rounding needed. */ + break; + } +} + /**************************************************************************** Take a Unix time and convert to an NTTIME structure and place in buffer - pointed to by p. + pointed to by p, rounded to the correct resolution. ****************************************************************************/ -void put_long_date_timespec(char *p, struct timespec ts) +void put_long_date_timespec(enum timestamp_set_resolution res, char *p, struct timespec ts) { NTTIME nt; + round_timespec(res, &ts); unix_timespec_to_nt_time(&nt, ts); SIVAL(p, 0, nt & 0xFFFFFFFF); SIVAL(p, 4, nt >> 32); @@ -319,7 +335,7 @@ void put_long_date(char *p, time_t t) struct timespec ts; ts.tv_sec = t; ts.tv_nsec = 0; - put_long_date_timespec(p, ts); + put_long_date_timespec(TIMESTAMP_SET_SECONDS, p, ts); } void dos_filetime_timespec(struct timespec *tsp) @@ -472,7 +488,7 @@ int timespec_compare(const struct timespec *ts1, const struct timespec *ts2) then zero nsec. ****************************************************************************/ -void round_timespec(struct timespec *ts) +void round_timespec_to_sec(struct timespec *ts) { ts->tv_sec = convert_timespec_to_time_t(*ts); ts->tv_nsec = 0; -- cgit