From owner-freebsd-bugs@FreeBSD.ORG Sun Jan 1 00:07:11 2006 Return-Path: X-Original-To: freebsd-bugs@freebsd.org Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6C2B516A41F; Sun, 1 Jan 2006 00:07:11 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailout1.pacific.net.au (mailout1.pacific.net.au [61.8.0.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id A8D7643D49; Sun, 1 Jan 2006 00:07:10 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.0.86]) by mailout1.pacific.net.au (8.13.4/8.13.4/Debian-3) with ESMTP id k0106r4r028031; Sun, 1 Jan 2006 11:06:53 +1100 Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailproxy1.pacific.net.au (8.13.4/8.13.4/Debian-3) with ESMTP id k0106oJc004492; Sun, 1 Jan 2006 11:06:52 +1100 Date: Sun, 1 Jan 2006 11:06:48 +1100 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Gilbert Cao In-Reply-To: <20051231112258.C4B72B853@sdf1.bsdmon.com> Message-ID: <20060101105648.J39665@delplex.bde.org> References: <20051231112258.C4B72B853@sdf1.bsdmon.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-bugs@freebsd.org, FreeBSD-gnats-submit@freebsd.org Subject: Re: bin/91134: [PATCH] Preserve access and modification time when cp to a smbfs destination path X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Jan 2006 00:07:11 -0000 On Sat, 31 Dec 2005, Gilbert Cao wrote: >> Fix: > The following patch has fixed the problem as 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. This is a bug in smbfs. cp only works on POSIX file systems. > --- patch_cp_utils.diff begins here --- > --- ./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); > } It can't be right to always close the file. This leaves the fd >= 0 case in setfile() unused and bogotifies all the code that handles this case, even for POSIX file systems where this code just works. However, I can't see any reason to have the fd >= 0 case except to avoid minor races for regular files only. Bruce