Second part of fix for 6529 - Offline files conflict with Vista and Office 2003.
authorJeremy Allison <jra@samba.org>
Mon, 24 Aug 2009 19:30:05 +0000 (12:30 -0700)
committerJeremy Allison <jra@samba.org>
Mon, 24 Aug 2009 19:30:05 +0000 (12:30 -0700)
ext4 may be able to store ns timestamps, but the only API to *set* timestamps
takes usec, not nsec. Round to usec on set requests.
Jeremy.

source3/include/proto.h
source3/lib/time.c
source3/smbd/trans2.c

index 1b097326797e3c3670fd5ad0f602b1a7c1c5d870..97d05b369917fa4a8ee01d081416752bcdd30c58 100644 (file)
@@ -1045,6 +1045,7 @@ struct timespec timespec_min(const struct timespec *ts1,
                           const struct timespec *ts2);
 int timespec_compare(const struct timespec *ts1, const struct timespec *ts2);
 void round_timespec(struct timespec *ts);
+void round_timespec_to_usec(struct timespec *ts);
 struct timespec interpret_long_date(const char *p);
 void cli_put_dos_date(struct cli_state *cli, char *buf, int offset, time_t unixdate);
 void cli_put_dos_date2(struct cli_state *cli, char *buf, int offset, time_t unixdate);
index 06605cd30a79b16940e0423354d9e993d01dd4aa..c80b59a662f77f39bdd9eeccf39fc4ba187df92a 100644 (file)
@@ -478,6 +478,16 @@ void round_timespec(struct timespec *ts)
        ts->tv_nsec = 0;
 }
 
+/****************************************************************************
+ Round a timespec to usec value.
+****************************************************************************/
+
+void round_timespec_to_usec(struct timespec *ts)
+{
+       struct timeval tv = convert_timespec_to_timeval(*ts);
+       *ts = convert_timeval_to_timespec(tv);
+}
+
 /****************************************************************************
  Interprets an nt time into a unix struct timespec.
  Differs from nt_time_to_unix in that an 8 byte value of 0xffffffffffffffff
index 2900e764e8ad484e0df714550f067941525e1dcc..a1043e27ff130bc513eb859e9238b675520f92cf 100644 (file)
@@ -5409,6 +5409,17 @@ NTSTATUS smb_set_file_time(connection_struct *conn,
                round_timespec(&ft->ctime);
                round_timespec(&ft->atime);
                round_timespec(&ft->mtime);
+       } else {
+               /* The highest resolution timestamp
+                * setting function available in POSIX
+                * is utimes(), which uses usec resolution,
+                * not nsec resolution. So we must round to
+                * usec, then back to nsec. JRA.
+                */
+               round_timespec_to_usec(&ft->create_time);
+               round_timespec_to_usec(&ft->ctime);
+               round_timespec_to_usec(&ft->atime);
+               round_timespec_to_usec(&ft->mtime);
        }
 
        DEBUG(5,("smb_set_filetime: actime: %s\n ",