How to set only last accessed timestamp

derrell at samba.org derrell at samba.org
Wed Jun 15 13:34:18 GMT 2005


"Satwik Hebbar" <satwikh at calsoftinc.com> writes:

> I am using the libsmbclient functionality that we get with samba to  
> connect to Windows servers and access files. When we touch the files, the  
> last accessed timestamp changes on them, and so I use the cli_setattrE()  
> api provided in libsmb/clifile.c to reset the timestamps back to the  
> original. The problem is that it seems there is a small rounding error of  
> +/- 2 secs that occurs on the set action. The cli_setattrE() call accepts  
> all 3 timestamp parameters, so that even the created timestamp and last  
> modified timestamp are incorrectly set.
>
> Is there a way to set only the last accessed timestamp without touching  
> the other two? Because, a lot of programs on the windows servers are  
> highly dependent on these timestamps and it could lead to unsolicited  
> actions occuring on the files, simply because their timestamps have moved  
> forward or behind.

Hi Satwik,

I recently made some corrections to the attribute-setting code in libsmbclient
(a few weeks ago).  smbc_utimes() calls smbc_setatr() which now tries
setpathinfo first, and if that fails, uses setattrE().  In my testing all
times were being set correctly using that method.  What version of samba are
you using?  Does this problem occur if you call smbc_utimes(pathname) instead
of directly calling cli_setattrE(fd), using current code pulled from svn?

As to setting only atime, I believe you'll have to first retrieve the mtime
(and ctime if you're using an interface that can set that), and then provide
the retrieved value(s) along with the new atime.

If the times being set are not accurate even using the current code and
smbc_utimes(), please post a bug on libsmbclient, and attach the following:

  - the parameters that you are passing to smbc_utimes()
  - a raw, binary packet trace generated with:
      tcpdump -s 0 -w trace.pcap 'port 139 or port 445'

If the problem does not occur when using smbc_utimes() but does occur when
calling the lower-level functions directly, if you can identify what's
different about your code than what smbc_utimes_ctx() in libsmb/libsmbclient.c
does, it would likely help.

Thanks,

Derrell


More information about the samba-technical mailing list