Deal with systems that don't initialize birthtime correctly.
authorJeremy Allison <jra@samba.org>
Fri, 29 Aug 2008 16:29:35 +0000 (09:29 -0700)
committerMichael Adam <obnox@samba.org>
Fri, 12 Sep 2008 13:13:25 +0000 (15:13 +0200)
Pointed out by SATOH Fumiyasu <fumiyas@osstech.jp>.
Jeremy.
(cherry picked from commit 4876e4ffe9f5142bf90dc14b105436eaca35d3f4)

source/lib/time.c

index 8ab001ec9220e0eacf4b0fe8c37ab6382643a85c..425539c3b0d4ea32db9af86b530e8054676d47d8 100644 (file)
@@ -860,20 +860,26 @@ struct timespec get_create_timespec(const SMB_STRUCT_STAT *pst,bool fake_dirs)
        }
 
 #if defined(HAVE_STAT_ST_BIRTHTIMESPEC)
-       return pst->st_birthtimespec;
+       ret = pst->st_birthtimespec;
 #elif defined(HAVE_STAT_ST_BIRTHTIMENSEC)
        ret.tv_sec = pst->st_birthtime;
        ret.tv_nsec = pst->st_birthtimenspec;
-       return ret;
 #elif defined(HAVE_STAT_ST_BIRTHTIME)
        ret.tv_sec = pst->st_birthtime;
        ret.tv_nsec = 0;
-       return ret;
 #else
        ret.tv_sec = calc_create_time(pst);
        ret.tv_nsec = 0;
-       return ret;
 #endif
+
+       /* Deal with systems that don't initialize birthtime correctly.
+        * Pointed out by SATOH Fumiyasu <fumiyas@osstech.jp>.
+        */
+       if (null_timespec(ret)) {
+               ret.tv_sec = calc_create_time(pst);
+               ret.tv_nsec = 0;
+       }
+       return ret;
 }
 
 /****************************************************************************