Preserve date when cp over smbfs
- From: Gilbert Cao <hika@xxxxxxxxxx>
- Date: Fri, 30 Dec 2005 23:13:16 +0100
Hi, the list.
I have recently notice a problem when I copy a file to a SMB mount
directory :
My SMB client is a FreeBSD 6.0-STABLE.
My SMB server is a FreeBSD 5.4-STABLE (with port samba-3.0.8,1).
When I do a 'cp -p somefile /path/to/smbmountdir/anotherfolder', the
access time and modification time are not preserved, even if I use the -p
flag.
The user doing the copy with cp is the owner of /path/to/smbmountdir.
Few days later, I have finally found the problem in the src/bin/cp
source code, especially the utils.c file :
I have found out that utimes() does nothing on the newly created file,
if its file descriptor is not closed yet, and this is only the case in a
SMB destination path.
Here is a small patch I have made.
So pleeaaase, committers, I hope(pray) that the correction to the cp
utility can be applied (with or without the patch), for the next time ;)
I will be very grateful for that, as it is very important for me to
preserve the modification time when I copy some photos to my file
server over smbfs :)
--
--------------------------------
(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);
}
Attachment:
pgpQFggsoKzMN.pgp
Description: PGP signature
- Follow-Ups:
- Re: Preserve date when cp over smbfs
- From: Doug Barton
- Re: Preserve date when cp over smbfs
- From: Doug Barton
- Re: Preserve date when cp over smbfs
- Prev by Date: Problem about libnet on FreeBSD 6.0
- Next by Date: Re: Preserve date when cp over smbfs
- Previous by thread: Problem about libnet on FreeBSD 6.0
- Next by thread: Re: Preserve date when cp over smbfs
- Index(es):
Relevant Pages
|
|