From owner-freebsd-questions@FreeBSD.ORG Fri Dec 30 18:39:25 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 178D116A420 for ; Fri, 30 Dec 2005 18:39:25 +0000 (GMT) (envelope-from hika@bsdmon.com) Received: from smtp.bsdmon.com (hosting-28.42.rev.fr.colt.net [213.41.42.28]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3692943D55 for ; Fri, 30 Dec 2005 18:39:09 +0000 (GMT) (envelope-from hika@bsdmon.com) Received: from localhost (localhost [127.0.0.1]) by smtp.bsdmon.com (Postfix) with ESMTP id 280D63760BA for ; Fri, 30 Dec 2005 19:39:07 +0100 (CET) Received: from smtp.bsdmon.com ([127.0.0.1]) by localhost (freefugu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 20876-05 for ; Fri, 30 Dec 2005 19:38:57 +0100 (CET) Received: from mail.bsdmon.com (14.128.101-84.rev.gaoland.net [84.101.128.14]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.bsdmon.com (Postfix) with ESMTP id 527553760B7 for ; Fri, 30 Dec 2005 19:38:57 +0100 (CET) Received: by sdf1.bsdmon.com (Postfix, from userid 1001) id A40EBB853; Fri, 30 Dec 2005 19:38:47 +0100 (CET) Date: Fri, 30 Dec 2005 19:38:47 +0100 From: Gilbert Cao To: freebsd-questions@freebsd.org Message-ID: <20051230183847.GA9133@bsdmon.com> References: <20051228112558.GA79302@bsdmon.com> <20051229155156.GB1075@bsdmon.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wzJLGUyc3ArbnUjN" Content-Disposition: inline In-Reply-To: <20051229155156.GB1075@bsdmon.com> X-Operating-System: FreeBSD 6.0-STABLE i386 Organization: BSDMon X-GPG-Key: http://www.bsdmon.com/public_key.gpg User-Agent: Mutt/1.5.11 X-Virus-Scanned: amavisd-new at bsdmon.com Subject: Re: Preserve date when cp over smbfs X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Dec 2005 18:39:25 -0000 --wzJLGUyc3ArbnUjN Content-Type: multipart/mixed; boundary="6TrnltStXW4iwmi0" Content-Disposition: inline --6TrnltStXW4iwmi0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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: > >=20 > > I have quickly looked into the source code of both cp and gqview, and i= t seems > > that cp relies on utimes(), and gqview relies on utime(). > >=20 >=20 > Hi, > I have finally done my little investigation when applying utime() or utim= es() > to a SMB file path : >=20 > 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 ...). >=20 > 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. --=20 -------------------------------- (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 -------------------------------- --6TrnltStXW4iwmi0 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch_cp_utils.diff" Content-Transfer-Encoding: quoted-printable --- ./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. */ =20 - if (pflag && setfile(fs, to_fd)) - rval =3D 1; if (pflag && preserve_fd_acls(from_fd, to_fd) !=3D 0) rval =3D 1; (void)close(from_fd); @@ -213,6 +211,14 @@ warn("%s", to.p_path); rval =3D 1; } + /* + * To preserve times in SMB to.p_path,=20 + * 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 =3D 1; return (rval); } =20 --6TrnltStXW4iwmi0-- --wzJLGUyc3ArbnUjN Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQFDtX62SyQfFTqAEpcRAmQbAKCue9dusLD+gwiT2jb3jcncBljAlQCgujKs dQ43k1FgMN3bZwTj1LfDxGg= =0e9J -----END PGP SIGNATURE----- --wzJLGUyc3ArbnUjN--