summaryrefslogtreecommitdiff
path: root/source3/lib/time.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2009-08-24 20:57:37 -0700
committerJeremy Allison <jra@samba.org>2009-08-24 20:57:37 -0700
commitc69f92d16d57c2387d31b5dfd01aab0685a671d0 (patch)
tree4eef7104df67108cde2fd436a28c51176473f5e5 /source3/lib/time.c
parent9a86f26a5f0b421f8cf259e579fe5946b39623f6 (diff)
downloadsamba-c69f92d16d57c2387d31b5dfd01aab0685a671d0.tar.gz
samba-c69f92d16d57c2387d31b5dfd01aab0685a671d0.tar.bz2
samba-c69f92d16d57c2387d31b5dfd01aab0685a671d0.zip
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.
Diffstat (limited to 'source3/lib/time.c')
-rw-r--r--source3/lib/time.c24
1 files changed, 20 insertions, 4 deletions
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;