Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Reply-To: From: "Vlad Soutyrine" To: , , Cc: , Subject: rsync under cygwin Date: Thu, 29 Jun 2000 13:29:26 -0700 Message-ID: <7BF34D04641AD411919D0090277E15A33F3F@mbox.softaware.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0004_01BFE1CE.0ADB73D0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 ------=_NextPart_000_0004_01BFE1CE.0ADB73D0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Dear rsync developers, I've been testing rsync under cygwin on NT. It works great, with one exception. If a file that rsync is supposed to replace is open by other application, rsync cannot replace the file even if it is opened in a shared mode. This in particular happens when rsync is trying to replace a file that is being served by IIS as a web content. I was able to resolve the issue with a minor modification of rsync code. When the described above situation happens (in rsync.c) I make a copy of file instead of renaming it by calling function copy_file from util.c. I also had to modify function copy_file not to delete file before opening it, but to truncate file during the opening. This seems to solve the problem. The patch is attached. Cygwin developers, could you please review the patch, and see if there is a better solution. I hope it will be taken into account on next rsync release. I have preserved the code for all other platforms, but cigwin. Thank you very much for your consideration, Vlad ------=_NextPart_000_0004_01BFE1CE.0ADB73D0 Content-Type: application/octet-stream; name="rsync-2.4.3.cygwin.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="rsync-2.4.3.cygwin.diff" diff -ur rsync-2.4.3.orig/rsync.c rsync-2.4.3.cygwin/rsync.c=0A= --- rsync-2.4.3.orig/rsync.c Sat Jan 29 03:35:03 2000=0A= +++ rsync-2.4.3.cygwin/rsync.c Thu Jun 29 11:59:55 2000=0A= @@ -240,9 +240,17 @@=0A= =0A= /* move tmp file over real file */=0A= if (robust_rename(fnametmp,fname) !=3D 0) {=0A= - if (errno =3D=3D EXDEV) {=0A= - /* rename failed on cross-filesystem link. =0A= - Copy the file instead. */=0A= +#ifdef __CYGWIN__=0A= + if (errno =3D=3D EXDEV || errno =3D=3D EACCES)=0A= + /* rename failed on cross-filesystem link=0A= + or destination may be open in shared mode by other application.=0A= + Copy the file instead. */=0A= +#else=0A= + if (errno =3D=3D EXDEV)=0A= + /* rename failed on cross-filesystem link=0A= + Copy the file instead. */=0A= +#endif=0A= + {=0A= if (copy_file(fnametmp,fname, file->mode & INITACCESSPERMS)) {=0A= rprintf(FERROR,"copy %s -> %s : %s\n",=0A= fnametmp,fname,strerror(errno));=0A= diff -ur rsync-2.4.3.orig/util.c rsync-2.4.3.cygwin/util.c=0A= --- rsync-2.4.3.orig/util.c Sat Apr 8 19:53:31 2000=0A= +++ rsync-2.4.3.cygwin/util.c Thu Jun 29 12:11:01 2000=0A= @@ -316,13 +316,17 @@=0A= return -1;=0A= }=0A= =0A= +#ifndef __CYGWIN__=0A= if (robust_unlink(dest) && errno !=3D ENOENT) {=0A= rprintf(FERROR,"unlink %s: %s\n",=0A= dest,strerror(errno));=0A= return -1;=0A= }=0A= -=0A= ofd =3D do_open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, mode);=0A= +#else=0A= + ofd =3D do_open(dest, O_WRONLY | O_CREAT | O_TRUNC, mode);=0A= +#endif=0A= +=0A= if (ofd =3D=3D -1) {=0A= rprintf(FERROR,"open %s: %s\n",=0A= dest,strerror(errno));=0A= ------=_NextPart_000_0004_01BFE1CE.0ADB73D0 Content-Type: text/plain; charset=us-ascii -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com ------=_NextPart_000_0004_01BFE1CE.0ADB73D0--