Re: [PATCH] Feature test macros overhaul: Cygwin signal.h
On Jun 13 15:01, Yaakov Selkowitz wrote: > This should match newlib's . > > Signed-off-by: Yaakov Selkowitz > --- > winsup/cygwin/include/cygwin/signal.h | 26 +- > 1 file changed, 25 insertions(+), 1 deletion(-) ACK Thanks, Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat signature.asc Description: PGP signature
Re: [PATCH] readdir() with mount point dentry, return mount point INO
On Jun 13 11:12, Joe Lowe wrote: > > This patch fixes a minor compatibility issue w/ cygwin mount point handling > in readdir(), compared to equivalent behavior of Linux and MacOS. > dentry.d_ino should indicate the INO of the mount point itself, not the > target volume root folder. > > Changed return type from readdir_check_reparse_point to uint8_t, to avoid > unnecessarily being implicitly cast to and from a signed int. > > Renamed a related local variable "attr" to "oattr" that was eclipsing a > member variable with the same name. Pushed. Can you please send patches in `git format-patch' format? Those are nicer to apply. Thanks, Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat signature.asc Description: PGP signature
[PATCH] Export XSI sigpause
There are two common sigpause variants, both of which take an int argument. If you request _XOPEN_SOURCE or _GNU_SOURCE, you get the System V version, which removes the given signal from the process's signal mask; otherwise you get the BSD version, which sets the process's signal mask to the given value. Signed-off-by: Yaakov Selkowitz --- newlib/libc/include/sys/signal.h | 14 +- winsup/cygwin/common.din | 1 + winsup/cygwin/include/cygwin/version.h | 3 ++- winsup/cygwin/signal.cc| 12 winsup/doc/posix.xml | 10 -- 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/newlib/libc/include/sys/signal.h b/newlib/libc/include/sys/signal.h index a56f18a1b..da064cd5f 100644 --- a/newlib/libc/include/sys/signal.h +++ b/newlib/libc/include/sys/signal.h @@ -200,7 +200,19 @@ int _EXFUN(sigwait, (const sigset_t *set, int *sig)); #endif /* !__CYGWIN__ && !__rtems__ */ #endif /* __POSIX_VISIBLE */ -#if __BSD_VISIBLE +/* There are two common sigpause variants, both of which take an int argument. + If you request _XOPEN_SOURCE or _GNU_SOURCE, you get the System V version, + which removes the given signal from the process's signal mask; otherwise + you get the BSD version, which sets the process's signal mask to the given + value. */ +#if __XSI_VISIBLE && !defined(__INSIDE_CYGWIN__) +# ifdef __GNUC__ +int _EXFUN(sigpause, (int)) __asm__ (__ASMNAME ("__xpg_sigpause")); +# else +int _EXFUN(__xpg_sigpause, (int)); +# define sigpause __xpg_sigpause +# endif +#elif __BSD_VISIBLE int _EXFUN(sigpause, (int)); #endif diff --git a/winsup/cygwin/common.din b/winsup/cygwin/common.din index 6620700c2..75fe05c1f 100644 --- a/winsup/cygwin/common.din +++ b/winsup/cygwin/common.din @@ -102,6 +102,7 @@ __wrap__ZdlPv NOSIGFE # void operator delete(void *p) throw() __wrap__ZdlPvRKSt9nothrow_t NOSIGFE # void operator delete(void *p, const std::nothrow_t &nt) throw() __xdrrec_getrec SIGFE __xdrrec_setnonblock SIGFE +__xpg_sigpause SIGFE __xpg_strerror_r SIGFE _exit SIGFE _feinitialise NOSIGFE diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 7baca6158..c0254a8e0 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -475,12 +475,13 @@ details. */ 308: Export dladdr. 309: Export getloadavg. 310: Export reallocarray. + 311: Export __xpg_sigpause. Note that we forgot to bump the api for ualarm, strtoll, strtoull, sigaltstack, sethostname. */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 310 +#define CYGWIN_VERSION_API_MINOR 311 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible changes are made to the shared diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index f371a231b..fbd2b241e 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -524,6 +524,18 @@ sigpause (int signal_mask) } extern "C" int +__xpg_sigpause (int sig) +{ + int res; + sigset_t signal_mask; + sigprocmask (0, NULL, &signal_mask); + sigdelset (&signal_mask, sig); + res = handle_sigsuspend (signal_mask); + syscall_printf ("%R = __xpg_sigpause(%y)", res, sig); + return res; +} + +extern "C" int pause (void) { int res = handle_sigsuspend (_my_tls.sigmask); diff --git a/winsup/doc/posix.xml b/winsup/doc/posix.xml index 5c9f65637..ced7e383d 100644 --- a/winsup/doc/posix.xml +++ b/winsup/doc/posix.xml @@ -877,7 +877,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008). signal signbit(see chapter "Implementation Notes") signgam -sigpause +sigpause (see chapter "Implementation Notes") sigpending sigprocmask sigqueue @@ -925,7 +925,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008). strdup strerror strerror_l -strerror_r +strerror_r (see chapter "Implementation Notes") strfmon strfmon_l strftime @@ -1668,6 +1668,12 @@ depending on whether _BSD_SOURCE or _GNU_SOURCE is defined when compiling.basename is available in both POSIX and GNU flavors, depending on whether libgen.h is included or not. +sigpause is available in both BSD and SysV/XSI +flavors, depending on whether _XOPEN_SOURCE is defined when compiling. + +strerror_r is available in both POSIX and GNU +flavors, depending on whether _GNU_SOURCE is defined when compiling. + dladdr always sets the Dl_info members dli_sname and dli_saddr to NULL, indicating no symbol matching addr could be found. -- 2.12.3
Re: [PATCH] Export XSI sigpause
On Jun 14 10:45, Yaakov Selkowitz wrote: > There are two common sigpause variants, both of which take an int argument. > If you request _XOPEN_SOURCE or _GNU_SOURCE, you get the System V version, > which removes the given signal from the process's signal mask; otherwise > you get the BSD version, which sets the process's signal mask to the given > value. > > Signed-off-by: Yaakov Selkowitz > --- > newlib/libc/include/sys/signal.h | 14 +- > winsup/cygwin/common.din | 1 + > winsup/cygwin/include/cygwin/version.h | 3 ++- > winsup/cygwin/signal.cc| 12 > winsup/doc/posix.xml | 10 -- > 5 files changed, 36 insertions(+), 4 deletions(-) ACK, looks good. Please add this to the cygwin release notes file, too (in a 2nd commit). Thanks, Corinna -- Corinna Vinschen Cygwin Maintainer Red Hat signature.asc Description: PGP signature
[PATCH] Compatibility improvement to reparse point handling, v3
3rd pass at reparse point handling patch. Changes to this version of the patch. 1. Refactored, smaller, less code impact. 2. readdir() and stat() consistency changes now also handle native file (non-directory) symbolic links. readir() returns DT_REG to match lstat() indicating a normal file. Joe L. >From 736979422efb815f4b2906642d522c51d98ba230 Mon Sep 17 00:00:00 2001 From: Joe_Lowe Date: Wed, 14 Jun 2017 13:01:28 -0700 Subject: [PATCH] Compatibility improvements to reparse point handling. --- winsup/cygwin/fhandler_disk_file.cc | 63 +++-- winsup/cygwin/path.cc | 59 +++--- winsup/cygwin/path.h| 1 + 3 files changed, 87 insertions(+), 36 deletions(-) diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 01a9afe15..f8adcaa4c 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -161,15 +161,19 @@ path_conv::isgood_inode (ino_t ino) const return true; } -/* Check reparse point for type. IO_REPARSE_TAG_MOUNT_POINT types are - either volume mount points, which are treated as directories, or they - are directory mount points, which are treated as symlinks. - IO_REPARSE_TAG_SYMLINK types are always symlinks. We don't know - anything about other reparse points, so they are treated as unknown. */ -static inline uint8_t -readdir_check_reparse_point (POBJECT_ATTRIBUTES attr) +/* Check reparse point to determine if it should be treated as a posix symlink + or as a normal file/directory. Mount points are treated as normal directories + to match behavior of other systems. Unknown reparse tags are used for + things other than links (HSM, compression, dedup), and generally should be + treated as a normal file/directory. Native symlinks and mount points are + treated as posix symlinks, depending on the prefix of the target name. + This logic needs to agree with equivalent logic in path.cc + symlink_info::check_reparse_point() . + */ +static inline bool +readdir_check_reparse_point (POBJECT_ATTRIBUTES attr, bool remote) { - uint8_t ret = DT_UNKNOWN; + bool ret = false; IO_STATUS_BLOCK io; HANDLE reph; UNICODE_STRING subst; @@ -185,20 +189,29 @@ readdir_check_reparse_point (POBJECT_ATTRIBUTES attr) &io, FSCTL_GET_REPARSE_POINT, NULL, 0, (LPVOID) rp, MAXIMUM_REPARSE_DATA_BUFFER_SIZE))) { - if (rp->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) + if (!remote && rp->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) { RtlInitCountedUnicodeString (&subst, (WCHAR *)((char *)rp->MountPointReparseBuffer.PathBuffer + rp->MountPointReparseBuffer.SubstituteNameOffset), rp->MountPointReparseBuffer.SubstituteNameLength); - /* Only volume mountpoints are treated as directories. */ - if (RtlEqualUnicodePathPrefix (&subst, &ro_u_volume, TRUE)) - ret = DT_DIR; - else - ret = DT_LNK; + if (check_reparse_point_target (&subst)) + ret = true; } else if (rp->ReparseTag == IO_REPARSE_TAG_SYMLINK) - ret = DT_LNK; + { + if (rp->SymbolicLinkReparseBuffer.Flags & SYMLINK_FLAG_RELATIVE) + ret = true; + else + { + RtlInitCountedUnicodeString (&subst, + (WCHAR *)((char *)rp->SymbolicLinkReparseBuffer.PathBuffer + + rp->SymbolicLinkReparseBuffer.SubstituteNameOffset), + rp->SymbolicLinkReparseBuffer.SubstituteNameLength); + if (check_reparse_point_target (&subst)) + ret = true; + } + } NtClose (reph); } } @@ -1995,8 +2008,7 @@ fhandler_disk_file::readdir_helper (DIR *dir, dirent *de, DWORD w32_err, /* Set d_type if type can be determined from file attributes. For .lnk symlinks, d_type will be reset below. Reparse points can be NTFS symlinks, even if they have the FILE_ATTRIBUTE_DIRECTORY flag set. */ - if (attr && - !(attr & (~FILE_ATTRIBUTE_VALID_FLAGS | FILE_ATTRIBUTE_REPARSE_POINT))) + if (attr && !(attr & ~FILE_ATTRIBUTE_VALID_FLAGS)) { if (attr & FILE_ATTRIBUTE_DIRECTORY) de->d_type = DT_DIR; @@ -2005,19 +2017,22 @@ fhandler_disk_file::readdir_helper (DIR *dir, dirent *de, DWORD w32_err, de->d_type = DT_REG; } - /* Check for directory reparse point. These may be treated as a posix - symlink, or as mount point, so need to figure out whether to return - a directory or link type. In all cases, returning the INO of the - reparse point (not of the target) matches behavior of posix systems. + /* Check for reparse points that can be treated as posix symlinks. + Mountpoi
[PATCH] cygwin: export strverscmp, add versionsort
Signed-off-by: Yaakov Selkowitz --- This depends on the newlib strverscmp patch. winsup/cygwin/common.din | 2 ++ winsup/cygwin/include/cygwin/version.h | 3 ++- winsup/cygwin/include/sys/dirent.h | 1 + winsup/cygwin/release/2.8.1| 2 ++ winsup/cygwin/scandir.cc | 6 ++ winsup/doc/posix.xml | 2 ++ 6 files changed, 15 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/common.din b/winsup/cygwin/common.din index 75fe05c1f..93316532c 100644 --- a/winsup/cygwin/common.din +++ b/winsup/cygwin/common.din @@ -1396,6 +1396,7 @@ strtoull NOSIGFE strtoull_l NOSIGFE strtoumax = strtoull NOSIGFE strupr NOSIGFE +strverscmp NOSIGFE strxfrm NOSIGFE strxfrm_l NOSIGFE swab NOSIGFE @@ -1492,6 +1493,7 @@ vasprintf SIGFE vdprintf SIGFE verr SIGFE verrx SIGFE +versionsort NOSIGFE vfiprintf SIGFE vfork SIGFE vfprintf SIGFE diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index c0254a8e0..bde358f72 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -476,12 +476,13 @@ details. */ 309: Export getloadavg. 310: Export reallocarray. 311: Export __xpg_sigpause. + 312: Export strverscmp, versionsort. Note that we forgot to bump the api for ualarm, strtoll, strtoull, sigaltstack, sethostname. */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 311 +#define CYGWIN_VERSION_API_MINOR 312 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible changes are made to the shared diff --git a/winsup/cygwin/include/sys/dirent.h b/winsup/cygwin/include/sys/dirent.h index 771f71620..049e87ad0 100644 --- a/winsup/cygwin/include/sys/dirent.h +++ b/winsup/cygwin/include/sys/dirent.h @@ -89,6 +89,7 @@ int alphasort (const struct dirent **__a, const struct dirent **__b); int scandirat (int __dirfd, const char *__dir, struct dirent ***__namelist, int (*select) (const struct dirent *), int (*compar) (const struct dirent **, const struct dirent **)); +int versionsort (const struct dirent **__a, const struct dirent **__b); #endif #if __BSD_VISIBLE diff --git a/winsup/cygwin/release/2.8.1 b/winsup/cygwin/release/2.8.1 index 1ebe7d839..d03f29647 100644 --- a/winsup/cygwin/release/2.8.1 +++ b/winsup/cygwin/release/2.8.1 @@ -5,6 +5,8 @@ What's new: - New API: reallocarray +- New API: strverscmp, versionsort. + What changed: - diff --git a/winsup/cygwin/scandir.cc b/winsup/cygwin/scandir.cc index 1c324c196..d6ac64907 100644 --- a/winsup/cygwin/scandir.cc +++ b/winsup/cygwin/scandir.cc @@ -20,6 +20,12 @@ alphasort (const struct dirent **a, const struct dirent **b) } extern "C" int +versionsort (const struct dirent **a, const struct dirent **b) +{ + return strverscmp ((*a)->d_name, (*b)->d_name); +} + +extern "C" int scandir (const char *dir, struct dirent ***namelist, int (*select) (const struct dirent *), diff --git a/winsup/doc/posix.xml b/winsup/doc/posix.xml index ced7e383d..7e28427b4 100644 --- a/winsup/doc/posix.xml +++ b/winsup/doc/posix.xml @@ -1367,6 +1367,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008). strtoll_l strtoul_l strtoull_l +strverscmp sysinfo tdestroy timegm @@ -1377,6 +1378,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008). vasnprintf vasprintf vasprintf_r +versionsort wcsftime_l wcstod_l wcstof_l -- 2.12.3