From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 37027 invoked by alias); 22 Jul 2019 12:12:27 -0000 Mailing-List: contact cygwin-cvs-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cygwin-cvs-owner@cygwin.com Received: (qmail 37011 invoked by uid 9996); 22 Jul 2019 12:12:26 -0000 Date: Mon, 22 Jul 2019 12:12:00 -0000 Message-ID: <20190722121226.37010.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Ken Brown To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_0-branch] Cygwin: socket files are not lnk special files X-Act-Checkin: newlib-cygwin X-Git-Author: Ken Brown X-Git-Refname: refs/heads/cygwin-3_0-branch X-Git-Oldrev: 585370924b1141b4615912176f7934644c9034e1 X-Git-Newrev: 0ea62854b44236d3b382ee6b9127dc71c8cc10d4 X-SW-Source: 2019-q3/txt/msg00011.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=0ea62854b44236d3b382ee6b9127dc71c8cc10d4 commit 0ea62854b44236d3b382ee6b9127dc71c8cc10d4 Author: Ken Brown Date: Sat Jul 20 17:55:12 2019 -0400 Cygwin: socket files are not lnk special files Change path_conv::is_lnk_special() so that it returns false on socket files. is_lnk_special() is called by rename2() in order to deal with special files (FIFOs and symlinks, for example) whose Win32 names usually have a ".lnk" suffix. Socket files do not fall into this category, and this change prevents ".lnk" from being appended erroneously when such files are renamed. Remove a now redundant !pc.issocket() from fhandler_disk_file::link(). Diff: --- winsup/cygwin/fhandler_disk_file.cc | 4 ++-- winsup/cygwin/path.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 1931927..fe4ee69 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -1190,10 +1190,10 @@ fhandler_disk_file::link (const char *newpath) char new_buf[nlen + 5]; if (!newpc.error) { - /* If the original file is a lnk special file (except for sockets), + /* If the original file is a lnk special file, and if the original file has a .lnk suffix, add one to the hardlink as well. */ - if (pc.is_lnk_special () && !pc.issocket () + if (pc.is_lnk_special () && RtlEqualUnicodePathSuffix (pc.get_nt_native_path (), &ro_u_lnk, TRUE)) { diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h index 2fd9133..65cfa7e 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -184,7 +184,9 @@ class path_conv int isspecial () const {return dev.not_device (FH_FS);} int iscygdrive () const {return dev.is_device (FH_CYGDRIVE);} int is_fs_special () const {return dev.is_fs_special ();} - int is_lnk_special () const {return (isdevice () && is_fs_special ()) + + int is_lnk_special () const {return (isdevice () && is_fs_special () + && !issocket ()) || isfifo () || is_lnk_symlink ();} #ifdef __WITH_AF_UNIX int issocket () const {return dev.is_device (FH_LOCAL)