This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
[PATCH 4/4] Cygwin: socket files are not lnk special files
- From: Ken Brown <kbrown at cornell dot edu>
- To: "cygwin-patches at cygwin dot com" <cygwin-patches at cygwin dot com>
- Date: Sun, 21 Jul 2019 01:53:03 +0000
- Subject: [PATCH 4/4] Cygwin: socket files are not lnk special files
- Arc-authentication-results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=cornell.edu;dmarc=pass action=none header.from=cornell.edu;dkim=pass header.d=cornell.edu;arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eTlt80V4/2c0I8goV+neZwfvOY3HEW7NQKCJ+7AG/mM=; b=RlW4DjBbQJ6blopWh0+Myjo1UUcZyQPcf+pzQ+VMmJJ1Zo21mPKG/sXy/ww37X/CmjH+XHbuYuvnqkHd5cM2aWU3Zv5uGIoazM4+k+XtFmcwFHLxX6TV3VJR3+MchHEePwF9qU8aCgWc5recTS2x3BV2Q++jg7vEZ12J8ABtBeINuRFydsu+SVDgktAN3zwf7H+zyL2kcSSAt+zijm6bKHJECQbjARX7cEU0udAEdd9reAdaGDAVBm7bbDSdzvZTqf9WJ/GZmP2OVKAT0/mtQTK3QGIM9WmsCRoRZdQlRaJgXhC2AGT3NXi6aZwvrcIQrlDCHqijaCeDs01fGXIbjw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DI3LGmz+l+l9o87agasdNke8tqk3P0wcBRoksZz7qPTBegnnNK/v4nsdXRgTDYV60alSg2J4dAdRQQQxKbsNva6aKdRKei6bpHyRwry5f7HZBxgI3XtW/b3SvgWCFT3lR0ocRX96Vm5y4YgV4dWfPdXzUKbOxINkjjrcvrBUB2Ef04fCjfy7QJcuqehvAij1HlKlMzfLtzV8D0rpERjG9IYnqg8nncs0FEdBMsMEVHCZ1cwurz6Sjtd+MmAq+ssTmKyVBzjHeJKqahha6PjqcC/Q/S55yXWe+fqwJhW5f446udo/FHOoumYjzFQOcvCzFGrHn3hHd6EZ6FTSIK9Mjw==
- References: <20190721015238.2127-1-kbrown@cornell.edu>
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().
---
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 193192762..fe4ee6971 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 2fd9133c4..65cfa7e7c 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)
--
2.21.0