On Thu, Dec 29, 2005 at 04:51:56PM +0100, Gilbert Cao wrote: > On Wed, Dec 28, 2005 at 12:25:58PM +0100, Gilbert Cao wrote: > > > > I have quickly looked into the source code of both cp and gqview, and it > > seems > > that cp relies on utimes(), and gqview relies on utime(). > > > > Hi, > I have finally done my little investigation when applying utime() or utimes() > to a SMB file path : > > In both case, the access and modification times are preserved. > So it seems that the cp and tar utilities does not its job about > preserving times over SMB path (I still don't know why ...). > > I have a source code example available, if anyone is interested.
Hi, again. This time, I have done more investigation in the src/bin/cp source code and I have finally found the problem : In SMB only case, when utimes() is called *BEFORE* the fd of the newly created file is close(), it does not do anything. I have made a little patch to correct this. So please, committers, can the correction be applied to the cp utility (Perhaps it is the same problem in the tar utility) ? I will be very grateful. -- -------------------------------- (hika) Gilbert Cao http://www.miaouirc.com - MiaouIRC Project 2002-2003 http://www.bsdmon.com - The BSD DMON Power to serve IRC : #miaule at IRCNET Network --------------------------------
--- ./src/bin/cp/utils.c.orig Sat Nov 12 22:21:45 2005
+++ ./src/bin/cp/utils.c Fri Dec 30 19:23:04 2005
@@ -204,8 +204,6 @@
* to remove it if we created it and its length is 0.
*/
- if (pflag && setfile(fs, to_fd))
- rval = 1;
if (pflag && preserve_fd_acls(from_fd, to_fd) != 0)
rval = 1;
(void)close(from_fd);
@@ -213,6 +211,14 @@
warn("%s", to.p_path);
rval = 1;
}
+ /*
+ * To preserve times in SMB to.p_path,
+ * setfile() should be call *AFTER* we have closed the file
+ * descriptors. As we have closed the descriptors, we should
+ * pass -1 instead of the `to_fd` value
+ */
+ if (pflag && setfile(fs, -1))
+ rval = 1;
return (rval);
}
pgpUxT0IgiDs8.pgp
Description: PGP signature
