[SCM] Samba Shared Repository - branch v3-2-test updated
- release-3-2-0pre2-2967-g0cba300
Jeremy Allison
jra at samba.org
Fri Aug 29 16:28:18 GMT 2008
On Fri, Aug 29, 2008 at 10:58:39AM +0900, SATOH Fumiyasu wrote:
> At Thu, 28 Aug 2008 14:11:15 -0500 (CDT),
> Jeremy Allison wrote:
> > commit 0cba30073410ba499834ac26dee3f81a75c8de4f
> > Author: Jeremy Allison <jra at samba.org>
> > Date: Thu Aug 28 12:09:06 2008 -0700
> >
> > Add st_birthtime and friends for accurate create times on systems that support it (*BSD and MacOSX). This really needs to be in 3.2.x.
> > Should have done this ages ago, sorry.
> > Jeremy.
>
> If a filesystem (e.g. UFSv1) does not support birthtimes,
> pst->st_birthtime* have invalid value.
> You should ignore pst->st_birthtime* on that case
> and fallback to legacy code (calc_create_time()).
>
> How to check if pst->st_birthtime* are valid or not?
> I think Samba should fallback to calc_create_time()
> when:
>
> (1) pst->st_birthtime == (time_t)0 (if pst has no st_birthtimensec)
> (2) pst->st_birthtime == (time_t)0 and pst->st_birthtimensec == 0L
> (3) pst->st_birthtime == (time_t)0 and pst->st_birthtimensec == -1L
> (4) pst->st_birthtime == (time_t)-1 (if pst has no st_birthtimensec)
> (5) pst->st_birthtime == (time_t)-1 and pst->st_birthtimensec == -1L
>
> I've NOT confirmed that there is standard specification for
> st_birthtime* (especially, what value indicates that
> a filesystem does not suport it), and the above (1)-(5)
> conditions are suitable for judgement.
Ok, we already have a null_timespec() call, which only
checks the time_t val for zero, -1 or 0xFFFFFFFF which
covers the cases you mention above (in all of them
the time_t val is either 0 or -1.
I'm going to add this patch. Thanks a *lot* for
pointing this out ! That could have been embarrassing :-).
Jeremy.
-------------- next part --------------
diff --git a/source/lib/time.c b/source/lib/time.c
index 8ab001e..425539c 100644
--- a/source/lib/time.c
+++ b/source/lib/time.c
@@ -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 at osstech.jp>.
+ */
+ if (null_timespec(ret)) {
+ ret.tv_sec = calc_create_time(pst);
+ ret.tv_nsec = 0;
+ }
+ return ret;
}
/****************************************************************************
More information about the samba-technical
mailing list