[PATCH] s3: Report ctime as change time, not mtime

Christof Schmitt christof.schmitt at us.ibm.com
Tue Feb 14 11:39:00 MST 2012

Jeremy Allison <jra at samba.org> wrote on 02/13/2012 05:59:43 PM:

> On Mon, Feb 13, 2012 at 11:23:41AM -0700, Christof Schmitt wrote:
> > I am working on a patch to store the ctime with the
> > gpfs_set_times() call. While testing setting and storing
> > timestamps i discovered that querying the timestamps from a cifs
> > client does not return all four timestamps. It seems that the
> > mtime is reported for two timestamps and the ctime is being
> > discarded:
> > 
> > E.g. in smbd_do_qfilepathinfo():
> >         mtime_ts = psbuf->st_ex_mtime;
> >         ctime_ts = get_change_timespec(conn, fsp, smb_fname);
> > and get_change_timespec also returns the mtime.
> > 
> > The attached patch changes get_change_timespec to return the
> > ctime, so that all timestamps set through the vfs set_times call can
> > be queried through the vfs stat calls.
> I don't think this is correct, but you'll have to wait
> until I analyse this more in order to be accurate.
> The basic problem is:
> UNIX ctime != Windows change time.
> Jeremy.

Hi Jeremy,

thanks for looking into this. Here are some more things in found
for this issue:

The best testcase seems to be RAW-SFILEINFO in smbtorture: In
samba/source4/torture/raw/setfileinfo.c the step "Test basic_info
level\n" sets all four Windows timestamps and expects that
reading them yields the same values.

In Samba, the "change time" is mapped to ctime in

        /* create time */
        ft.create_time = interpret_long_date(pdata);

        /* access time */
        ft.atime = interpret_long_date(pdata+8);

        /* write time. */
        ft.mtime = interpret_long_date(pdata+16);

        /* change time. */
        ft.ctime = interpret_long_date(pdata+24);

But when reading the timestamps, mtime is mapped to both, "write
time" and "change time". It seems odd to me that i can write
the "change time" from a client, but this value will never be
returned. The patch i submitted seems to be the simplest way to
change this.

Christof Schmitt || IBM || SONAS System Development || Tucson, AZ
christof.schmitt at us.ibm.com  ||  +1-520-799-2469  (T/L: 321-2469)

More information about the samba-technical mailing list