work around gcc bug in signal.h
I had already written this patch, and was in the process of testing it, before cgf voted it down. I'm still posting it for the record, as it would allow us to be source-compatible with Linux while we wait for the gcc bug to be fixed. For that matter, even if this patch is not applied, we might still want to consider simplifying things in siginfo_t - an anonymous union containing a single anonymous struct containing a single anonymous union seems wasteful, and we can prune two of those scopes whether or not we also name the outer union. 2010-04-27 Eric Blake * include/cygwin/signal.h (siginfo_t, sigaction): Work around gcc bug with member initialization of anonymous union members. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org --- winsup/cygwin/ChangeLog |5 +++ winsup/cygwin/include/cygwin/signal.h | 62 ++-- 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/winsup/cygwin/include/cygwin/signal.h b/winsup/cygwin/include/cygwin/signal.h index 25d501d..4fcfd33 100644 --- a/winsup/cygwin/include/cygwin/signal.h +++ b/winsup/cygwin/include/cygwin/signal.h @@ -1,6 +1,6 @@ /* signal.h - Copyright 2004, 2005, 2006 Red Hat, Inc. + Copyright 2004, 2005, 2006, 2010 Red Hat, Inc. This file is part of Cygwin. @@ -97,40 +97,46 @@ typedef struct uid_t si_uid;/* sender's uid */ int si_errno;/* errno associated with signal */ - __extension__ union + /* GCC bug 10676: we must use macros instead of anonymous unions, + to allow member initialization syntax to work. */ + union { __uint32_t __pad[32]; /* plan for future growth */ -struct _sigcommune _si_commune;/* cygwin ipc */ -__extension__ union +struct _sigcommune __si_commune; /* cygwin ipc */ +union { /* timers */ struct { - union - { - struct - { - timer_t si_tid; /* timer id */ - unsigned int si_overrun;/* overrun count */ - }; - sigval_t si_sigval; /* signal value */ - sigval_t si_value;/* signal value */ - }; - }; -}; + timer_t __si_tid; /* timer id */ + unsigned int __si_overrun; /* overrun count */ + } __timer; + sigval_t __si_sigval;/* signal value */ + sigval_t __si_value; /* signal value */ +} __value; /* SIGCHLD */ -__extension__ struct +struct { - int si_status; /* exit code */ - clock_t si_utime;/* user time */ - clock_t si_stime;/* system time */ -}; + int __si_status; /* exit code */ + clock_t __si_utime; /* user time */ + clock_t __si_stime; /* system time */ +} __child; /* core dumping signals */ -void *si_addr; /* faulting address */ - }; +void *__si_addr; /* faulting address */ + } __si; } siginfo_t; +#define _si_commune__si.__si_commune +#define si_tid __si.__value.__timer.__si_tid +#define si_overrun __si.__value.__timer.__si_overrun +#define si_sigval __si.__value.__si_sigval +#define si_value __si.__value.__si_value +#define si_status __si.__child.__si_status +#define si_utime __si.__child.__si_utime +#define si_stime __si.__child.__si_stime +#define si_addr__si.__si_addr + #pragma pack(pop) enum @@ -194,14 +200,16 @@ typedef void (*_sig_func_ptr)(int); struct sigaction { - __extension__ union + union { -_sig_func_ptr sa_handler; /* SIG_DFL, SIG_IGN, or pointer to a function */ -void (*sa_sigaction) ( int, siginfo_t *, void * ); - }; +_sig_func_ptr __sa_handler;/* SIG_DFL, SIG_IGN, or pointer to a function */ +void (*__sa_sigaction) ( int, siginfo_t *, void * ); + } __sa; sigset_t sa_mask; int sa_flags; }; +#define sa_handler __sa.__sa_handler +#define sa_sigaction __sa.__sa_sigaction #define SA_NOCLDSTOP 1 /* Do not generate SIGCHLD when children stop */ -- 1.7.0.4 signature.asc Description: OpenPGP digital signature
add mkostemp
Sed wants to use the glibc invention of mkostemp as enhanced by gnulib, in order to control the use of O_TEXT vs. O_BINARY vs. 0 (for native mount) mode[1]. glibc added this interface for other reasons as well - it is also useful to specify O_CLOEXEC, O_APPEND, and/or O_SYNC on some temporary files. In glibc, the flags argument explicitly excludes O_ACCMODE bits, since temp files are already specified as O_RDWR, so I copied that pattern. (man-pages 3.23 documents mkostemp since glibc 2.7, but fails to document mkostemps, even though it was added at the same time as mkstemps in glibc 2.11). [1] http://lists.gnu.org/archive/html/bug-coreutils/2010-07/msg00114.html Okay to commit, along with a corresponding patch to doc/new-features.sgml and a cygwin-specific patch to newlib's stdlib.h? 2010-07-19 Eric Blake * mktemp.cc (_gettemp): Add flags argument. All callers updated. (mkostemp, mkostemps): New functions. * cygwin.din (mkostemp, mkostemps): Export. * posix.sgml: Document them. * include/cygwin/version.h: Bump version. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org winsup/cygwin/ChangeLog|8 winsup/cygwin/cygwin.din |2 ++ winsup/cygwin/include/cygwin/version.h |3 ++- winsup/cygwin/mktemp.cc| 28 +--- winsup/cygwin/posix.sgml |2 ++ 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index f0ecd19..d9a67d7 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din index fa5c77d..9253d2c 100644 --- a/winsup/cygwin/cygwin.din +++ b/winsup/cygwin/cygwin.din @@ -995,6 +995,8 @@ mknod SIGFE _mknod = mknod SIGFE _mknod32 = mknod32 SIGFE mknodat SIGFE +mkostemp SIGFE +mkostemps SIGFE mkstemp SIGFE _mkstemp = mkstemp SIGFE mkstemps SIGFE diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 3a95e51..9924e42 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -388,12 +388,13 @@ details. */ 226: Export __locale_mb_cur_max. 227: Add pseudo_reloc_start, pseudo_reloc_end, image_base to per_process. 228: CW_STRERROR added. + 229: Add mkostemp, mkostemps. */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 228 +#define CYGWIN_VERSION_API_MINOR 229 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible diff --git a/winsup/cygwin/mktemp.cc b/winsup/cygwin/mktemp.cc index b8a1381..7770c3b 100644 --- a/winsup/cygwin/mktemp.cc +++ b/winsup/cygwin/mktemp.cc @@ -10,7 +10,7 @@ See the copyright at the bottom of this file. */ #include #include -static int _gettemp(char *, int *, int, size_t); +static int _gettemp(char *, int *, int, size_t, int); static uint32_t arc4random (); static const char padchar[] = @@ -20,30 +20,44 @@ extern "C" int mkstemp(char *path) { int fd; - return _gettemp(path, &fd, 0, 0) ? fd : -1; + return _gettemp(path, &fd, 0, 0, O_BINARY) ? fd : -1; } extern "C" char * mkdtemp(char *path) { - return _gettemp(path, NULL, 1, 0) ? path : NULL; + return _gettemp(path, NULL, 1, 0, 0) ? path : NULL; } extern "C" int mkstemps(char *path, int len) { int fd; - return _gettemp(path, &fd, 0, len) ? fd : -1; + return _gettemp(path, &fd, 0, len, O_BINARY) ? fd : -1; +} + +extern "C" int +mkostemp(char *path, int flags) +{ + int fd; + return _gettemp(path, &fd, 0, 0, flags & ~O_ACCMODE) ? fd : -1; +} + +extern "C" int +mkostemps(char *path, int len, int flags) +{ + int fd; + return _gettemp(path, &fd, 0, len, flags & ~O_ACCMODE) ? fd : -1; } extern "C" char * mktemp(char *path) { - return _gettemp(path, NULL, 0, 0) ? path : (char *) NULL; + return _gettemp(path, NULL, 0, 0, 0) ? path : (char *) NULL; } static int -_gettemp(char *path, int *doopen, int domkdir, size_t suffixlen) +_gettemp(char *path, int *doopen, int domkdir, size_t suffixlen, int flags) { char *start, *trv, *suffp; char *pad; @@ -105,7 +119,7 @@ _gettemp(char *path, int *doopen, int domkdir, size_t suffixlen) { if (doopen) { - if ((*doopen = open (path, O_CREAT | O_EXCL | O_RDWR | O_BINARY, + if ((*doopen = open (path, O_CREAT | O_EXCL | O_RDWR | flags, S_IRUSR | S_IWUSR)) >= 0) return 1; if (errno != EEXIST) diff --git a/winsup/cygwin/posix.sgml b/winsup/cygwin/posix.sgml index 6a3bc22..fdd7589 100644 --- a/winsup/cygwin/posix.sgml +++ b/win
Re: add mkostemp
On 07/19/2010 10:45 AM, Corinna Vinschen wrote: >> Okay to commit, along with a corresponding patch to doc/new-features.sgml >> and a cygwin-specific patch to newlib's stdlib.h? > > Yep. Thanks for the patch. I CCed the newlib list. The change to > newlib's stdlib.h is preapproved (#ifndef __STRICT_ANSI__ just like > mkstemp et al). For the record, here's the (pre-approved) patches for newlib and cygwin documentation that I'm pushing in tandem with the original cygwin patch. It also fixes a couple of minor problems I noticed while in the area - cygwin's cat has been binary-only for some time now, and newlib's stdlib.h was not robust to a user file that used #define warning prior to including the system header. > > Btw., would you mind to enhance newlib's libc/stdio/mktemp.c in the same > manner (_ELIX_LEVEL >= 4)? The mkostemp[s] additions are guarded by the same levels as mkstemps, since all three interfaces are equally non-portable. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org From 6659d25bad3c852afab62536814ab253437e9ff6 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 19 Jul 2010 11:38:33 -0600 Subject: [PATCH] Document mkostemp. * textbinary.sgml (textbin-devel): Document temp file behavior. * new-features.sgml (ov-new1.7.6): Document mkostemp[s]. --- winsup/doc/ChangeLog |5 + winsup/doc/new-features.sgml |4 winsup/doc/textbinary.sgml |7 ++- 3 files changed, 15 insertions(+), 1 deletions(-) diff --git a/winsup/doc/ChangeLog b/winsup/doc/ChangeLog index ca4b196..442b231 100644 --- a/winsup/doc/ChangeLog +++ b/winsup/doc/ChangeLog @@ -1,3 +1,8 @@ +2010-07-19 Eric Blake + + * textbinary.sgml (textbin-devel): Document temp file behavior. + * new-features.sgml (ov-new1.7.6): Document mkostemp[s]. + 2010-06-27 Yaakov Selkowitz * Makefile.in: Use "xmlto pdf" instead of docbook2pdf. diff --git a/winsup/doc/new-features.sgml b/winsup/doc/new-features.sgml index 97c2809..8cef1f9 100644 --- a/winsup/doc/new-features.sgml +++ b/winsup/doc/new-features.sgml @@ -30,6 +30,10 @@ strings. locale(1) prints these values just as on Linux. nl_langinfo(3) allows to fetch them. + +New interfaces mkostemp(3) and mkostemps(3) are added. + + diff --git a/winsup/doc/textbinary.sgml b/winsup/doc/textbinary.sgml index 98aa2b1..7f4aae5 100644 --- a/winsup/doc/textbinary.sgml +++ b/winsup/doc/textbinary.sgml @@ -23,7 +23,7 @@ standard input and output) as text. All other programs (such as would use binary mode. In practice with Cygwin, programs that deal explicitly with object files specify binary mode (this is the case of od, which is helpful to diagnose CR problems). Most -other programs (such as cat, cmp, +other programs (such as sed, cmp, tr) use the default mode. @@ -113,6 +113,11 @@ specified with the flag O_BINARY and text mode with O_TEXT. These symbols are defined in fcntl.h. +The mkstemp() and mkstemps() +calls force binary mode. Use mkostemp() or +mkostemps() with the same flags +as open() for more control on temporary files. + In the fopen() and popen() function calls, binary mode can be specified by adding a b to the mode string. Text mode is specified by adding a t -- 1.7.1 From 50d0ac35a7506d2ec6f8daae175fec0f5f5d06c9 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 19 Jul 2010 11:23:15 -0600 Subject: [PATCH] Add mkostemp[s]. * libc/stdio/mktemp.c (_gettemp): Add parameter, all callers changed. (mkostemp, _mkostemp_r, mkostemps, _mkostemps_r): New interfaces, for ELIX level 4. * libc/include/stdlib.h (mktemp): Avoid namespace issues. (mkostemp, mkostemps): Declare. --- newlib/ChangeLog |9 +++ newlib/libc/include/stdlib.h |8 ++- newlib/libc/stdio/mktemp.c | 122 +- 3 files changed, 112 insertions(+), 27 deletions(-) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 18591ce..35a7cef 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,12 @@ +2010-07-19 Eric Blake + + * libc/stdio/mktemp.c (_gettemp): Add parameter, all callers + changed. + (mkostemp, _mkostemp_r, mkostemps, _mkostemps_r): New interfaces, + for ELIX level 4. + * libc/include/stdlib.h (mktemp): Avoid namespace issues. + (mkostemp, mkostemps): Declare. + 2010-07-13 Corinna Vinschen * libc/include/signal.h (sighandler_t): Only define if _POSIX_SOURCE diff --git a/newlib/libc/include/stdlib.h b/newlib/libc/include/stdlib.h index 453bb50..0bd2c7d 100644 --- a/newlib/libc/include/stdlib.h +++ b/newlib/libc/include/stdlib.h @@ -103,14 +103,18 @@ size_t_EXFUN(_wcstombs_r,(struct _reent *, char *, const wchar_t *, size_t, _mb #ifndef __STRICT_ANSI__ #ifndef _REENT_ONLY char * _EXFUN(mkdtemp,(char *)); +int_EXFUN(mkostemp,(char *, int)); +int_EXFUN(mkostem
provide __xpg_strerror_r
Our strerror_r is lousy (it doesn't even match glibc's behavior); see my request to the newlib list. But even if newlib swaps over to a POSIX-compliant strerror_r, I argue that for Linux compatibility (not to mention backwards compatibility with existing programs), we need to continue to provide strerror_r with the glibc signature (and I will make sure of that when writing the newlib patch to whatever the consensus is there). Meanwhile, gnulib really wants to use the POSIX interface; on glibc systems, it uses the __xpg_strerror_r interface (undeclared, but that's what you get with a leading double-underscore interface), when _POSIX_C_VERSION is high enough and _GNU_SOURCE is not in effect. Since __xpg_strerror_r is undeclared, we don't have to care about tweaking newlib's string.h for this patch (gnulib does a link-test probe for its existence). 2011-02-05 Eric Blake * errno.cc (__xpg_strerror_r): New function. * cygwin.din: Export it. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din index 2e7e647..780179a 100644 --- a/winsup/cygwin/cygwin.din +++ b/winsup/cygwin/cygwin.din @@ -1933,6 +1933,7 @@ xdrrec_skiprecord SIGFE __xdrrec_getrec SIGFE __xdrrec_setnonblock SIGFE xdrstdio_create SIGFE +__xpg_strerror_r SIGFE y0 NOSIGFE y0f NOSIGFE y1 NOSIGFE diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc index a9860f4..91c381f 100644 --- a/winsup/cygwin/errno.cc +++ b/winsup/cygwin/errno.cc @@ -368,16 +368,23 @@ strerror (int errnum) return errstr; } -#if 0 +/* Newlib provides the glibc strerror_r interface, but like Linux, we + also provide the POSIX interface. POSIX leaves a lot of leeway, + but recommends that buf always be populated, and that both EINVAL + and ERANGE be returned when appropriate. */ extern "C" int -strerror_r (int errnum, char *buf, size_t n) +__xpg_strerror_r (int errnum, char *buf, size_t n) { char *errstr = strerror_worker (errnum); + int result = 0; if (!errstr) -return EINVAL; +{ + __small_sprintf (errstr = _my_tls.locals.strerror_buf, + "Unknown error %u", (unsigned) errnum); + result = EINVAL; +} + strncpy (buf, errstr, n); if (strlen (errstr) >= n) -return ERANGE; - strcpy (buf, errstr); - return 0; +result = ERANGE; + return result; } -#endif diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index c757827..7246e8e 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -399,12 +399,13 @@ details. */ 233: Add TIOCGPGRP, TIOCSPGRP. Export llround, llroundf. 234: Export program_invocation_name, program_invocation_short_name. 235: Export madvise. + 236: Export __xpg_strerror_r. */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 235 +#define CYGWIN_VERSION_API_MINOR 236 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible signature.asc Description: OpenPGP digital signature
Re: provide __xpg_strerror_r
On 02/05/2011 01:28 PM, Christopher Faylor wrote: > On Sat, Feb 05, 2011 at 01:04:16PM -0700, Eric Blake wrote: >> Our strerror_r is lousy (it doesn't even match glibc's behavior); see my >> request to the newlib list. > > We really should just implement strerror_r in errno.cc. It doesn't make > sense to have two different implementations You mean, implement the POSIX interface for strerror_r in errno.cc, and ditch glibc compatibility? But, backwards compatibility demands that we have two interfaces - the glibc one that returns char* for satisfying the link demands of existing applications, and the POSIX one that returns int, so we really are stuck with providing two forms of strerror_r if we intend to comply with POSIX. We already provide our own strerror() (it provides a better experience for out-of-range values that the newlib interface), but we're currently using the newlib strerror_r() (in spite of its truncation flaw). How should I rework this patch? -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: provide __xpg_strerror_r
On 02/06/2011 02:54 AM, Corinna Vinschen wrote: >> We already provide our own strerror() (it provides a better experience >> for out-of-range values that the newlib interface), but we're currently >> using the newlib strerror_r() (in spite of its truncation flaw). >> >> How should I rework this patch? > > It would be better if we implement strerror_r locally, in two versions, > just as on Linux. I think the best approach is to implement this in > newlib first (I replied to your mail there) and then, given that we use > the newlib string.h, copy the method over to Cygwin to match our current > strerror more closely. Here's the cygwin side of things, to match newlib's changes. Surprisingly, strerror_r turned out to be identical even when based on different root strerror(), so I left that inside #if 0, but it's easy enough to kill the #if 0 if you don't want cygwin to use any of newlib's strerror*. --- winsup/cygwin/ChangeLog|9 +++ winsup/cygwin/cygwin.din |1 + winsup/cygwin/errno.cc | 84 +--- winsup/cygwin/include/cygwin/version.h | 3 +- 4 files changed, 68 insertions(+), 29 deletions(-) 2011-02-09 Eric Blake * errno.cc (__xpg_strerror_r): New function. (strerror_r): Update comments to match newlib's fixes. (strerror): Set errno on failure. (_sys_errlist): Cause EINVAL failure for reserved values. * cygwin.din: Export new function. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din index 2e7e647..780179a 100644 --- a/winsup/cygwin/cygwin.din +++ b/winsup/cygwin/cygwin.din @@ -1933,6 +1933,7 @@ xdrrec_skiprecord SIGFE __xdrrec_getrec SIGFE __xdrrec_setnonblock SIGFE xdrstdio_create SIGFE +__xpg_strerror_r SIGFE y0 NOSIGFE y0f NOSIGFE y1 NOSIGFE diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc index a9860f4..0e9c863 100644 --- a/winsup/cygwin/errno.cc +++ b/winsup/cygwin/errno.cc @@ -199,9 +199,9 @@ const char *_sys_errlist[] NO_COPY_INIT = /* EL2HLT 44 */ "Level 2 halted", /* EDEADLK 45 */ "Resource deadlock avoided", /* ENOLCK 46 */ "No locks available", - "error 47", - "error 48", - "error 49", + NULL, + NULL, + NULL, /* EBADE 50 */ "Invalid exchange", /* EBADR 51 */ "Invalid request descriptor", /* EXFULL 52 */ "Exchange full", @@ -210,8 +210,8 @@ const char *_sys_errlist[] NO_COPY_INIT = /* EBADSLT 55 */ "Invalid slot", /* EDEADLOCK 56 */ "File locking deadlock error", /* EBFONT 57 */ "Bad font file format", - "error 58", - "error 59", + NULL, + NULL, /* ENOSTR 60 */ "Device not a stream", /* ENODATA 61 */ "No data available", /* ETIME 62 */ "Timer expired", @@ -224,13 +224,13 @@ const char *_sys_errlist[] NO_COPY_INIT = /* ESRMNT 69 */ "Srmount error", /* ECOMM 70 */ "Communication error on send", /* EPROTO 71 */ "Protocol error", - "error 72", - "error 73", + NULL, + NULL, /* EMULTIHOP 74 */ "Multihop attempted", /* ELBIN 75 */ "Inode is remote (not really error)", /* EDOTDOT 76 */ "RFS specific error", /* EBADMSG 77 */ "Bad message", - "error 78", + NULL, /* EFTYPE 79 */ "Inappropriate file type or format", /* ENOTUNIQ 80 */"Name not unique on network", /* EBADFD 81 */ "File descriptor in bad state", @@ -245,17 +245,17 @@ const char *_sys_errlist[] NO_COPY_INIT = /* ENOTEMPTY 90*/"Directory not empty", /* ENAMETOOLONG 91 */"File name too long", /* ELOOP 92 */ "Too many levels of symbolic links", - "error 93", - "error 94", + NULL, + NULL, /* EOPNOTSUPP 95 */ "Operation not supported", /* EPFNOSUPPORT 96 */"Protocol fam
Re: provide __xpg_strerror_r
On 02/10/2011 02:55 AM, Corinna Vinschen wrote: > On Feb 10 10:50, Corinna Vinschen wrote: >> On Feb 9 21:15, Christopher Faylor wrote: >>> On Wed, Feb 09, 2011 at 05:20:59PM -0700, Eric Blake wrote: >>>> +/* Newlib's provides declarations for two strerror_r >>>> + variants, according to preprocessor feature macros. It does the >>>> + right thing for GNU strerror_r, but its __xpg_strerror_r mishandles >>>> + a case of EINVAL when coupled with our strerror() override.*/ >>>> #if 0 >>> >>> Can't we get rid of this now? >> >> I agree. We should simply implement strerror_r by ourselves, even if >> it's identical to newlib's strerror_r. In the long run it's less >> puzzeling to have all the strerror variants in one place. > > Oh, and: http://cygwin.com/ml/cygwin-patches/2011-q1/msg00031.html Pushed, and squashed into minor version 236. I've also updated new-features.sgml. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: provide __xpg_strerror_r
On 02/10/2011 12:58 PM, Christopher Faylor wrote: > On Thu, Feb 10, 2011 at 10:37:45AM -0700, Eric Blake wrote: >> Pushed, and squashed into minor version 236. I've also updated >> new-features.sgml. > > Thanks Eric. Shoot - I pushed too early; I'm pushing this follow-up patch to fix the temporary build breakage that I introduced (now that strerror_r defaults to the POSIX signature, errno.cc has to take efforts to ensure that it doesn't conflict when implementing the GNU signature). diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc index 33a1038..8ee2a75 100644 --- a/winsup/cygwin/errno.cc +++ b/winsup/cygwin/errno.cc @@ -12,12 +12,14 @@ details. */ #define _sys_nerr FOO_sys_nerr #define sys_nerr FOOsys_nerr #define _sys_errlist FOO_sys_errlist +#define strerror_r FOO_strerror_r #include "winsup.h" #include "cygtls.h" #include "ntdll.h" #undef _sys_nerr #undef sys_nerr #undef _sys_errlist +#undef strerror_r /* Table to map Windows error codes to Errno values. */ /* FIXME: Doing things this way is a little slow. It's trivial to change -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: src/winsup/doc ChangeLog new-features.sgml
On 02/15/2011 08:32 AM, corinna wrote: > * new-features.sgml (ov-new1.7.8): Document /proc/sys. > > Patches: > http://sourceware.org/cgi-bin/cvsweb.cgi/src/winsup/doc/ChangeLog.diff?cvsroot=src&r1=1.328&r2=1.329 > http://sourceware.org/cgi-bin/cvsweb.cgi/src/winsup/doc/new-features.sgml.diff?cvsroot=src&r1=1.64&r2=1.65 > File system access via block devices works. For instance > +(note the trailing backslash!) > + > +bash$ cd /proc/sys/Device/HarddiskVolumeShadowCopy1/ That's a trailing slash, not backslash. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: [PATCH] False positive from access("/proc/registry/...", F_OK)
On 05/04/2011 02:09 PM, Christian Franke wrote: > Done, tested and attached. > > Christian > > { > + /* Key does not exist or open failed with EACCESS, > + enumerate subkey and value names of parent key. */ EACCES, not EACCESS. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
__xpg_strerror_r should not clobber strerror buffer
POSIX says that no other function in the standard should clobber the strerror buffer. Our strerror_r is a GNU extension, so it can get away with clobbering the buffer (but if we wanted to fix it, we would have to separate _my_tls.locals.strerror_buf into two different buffers). perror() is still broken, but that needs to be fixed in newlib. But __xpg_strerror_r, which is our POSIX strerror_r variant, has to be fixed in cygwin. Meanwhile, glibc just patched strerror this week to print negative errnum as a negative 32-bit int, rather than as a positive unsigned long; cygwin should do likewise. 2011-05-21 Eric Blake * errno.cc (strerror): Print unknown errno as int. (__xpg_strerror_r): Likewise, and don't clobber strerror buffer. Index: errno.cc === RCS file: /cvs/src/src/winsup/cygwin/errno.cc,v retrieving revision 1.82 diff -u -p -r1.82 errno.cc --- errno.cc18 May 2011 01:25:41 - 1.82 +++ errno.cc22 May 2011 01:22:17 - @@ -382,8 +382,8 @@ strerror (int errnum) char *errstr = strerror_worker (errnum); if (!errstr) { - __small_sprintf (errstr = _my_tls.locals.strerror_buf, "Unknown error %u", - (unsigned) errnum); + __small_sprintf (errstr = _my_tls.locals.strerror_buf, "Unknown error %d", + errnum); errno = _impure_ptr->_errno = EINVAL; } return errstr; @@ -409,10 +409,10 @@ __xpg_strerror_r (int errnum, char *buf, return ERANGE; int result = 0; char *error = strerror_worker (errnum); + char tmp[sizeof "Unknown error -2147483648"]; if (!error) { - __small_sprintf (error = _my_tls.locals.strerror_buf, "Unknown error %u", - (unsigned) errnum); + __small_sprintf (error = tmp, "Unknown error %d", errnum); result = EINVAL; } if (strlen (error) >= n) -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: __xpg_strerror_r should not clobber strerror buffer
On 05/21/2011 07:35 PM, Christopher Faylor wrote: > On Sat, May 21, 2011 at 07:26:37PM -0600, Eric Blake wrote: >> POSIX says that no other function in the standard should clobber the >> strerror buffer. Our strerror_r is a GNU extension, so it can get away >> with clobbering the buffer (but if we wanted to fix it, we would have to >> separate _my_tls.locals.strerror_buf into two different buffers). >> perror() is still broken, but that needs to be fixed in newlib. But >> __xpg_strerror_r, which is our POSIX strerror_r variant, has to be fixed >> in cygwin. >> >> Meanwhile, glibc just patched strerror this week to print negative >> errnum as a negative 32-bit int, rather than as a positive unsigned >> long; cygwin should do likewise. >> >> 2011-05-21 Eric Blake >> >> * errno.cc (strerror): Print unknown errno as int. >> (__xpg_strerror_r): Likewise, and don't clobber strerror buffer. > > Looks good. Please check in. Pushed. Just for the record, I'm having a problem self-building cygwin right now, from what looks like mingw issues: /home/eblake/src/winsup/utils/mingw gcc-4 -B./ -shared -Wl,--image-base,0x6FBC -Wl,--entry,_DllMainCRTStartup@12 mthr.o mthr_init.o mingwthrd.def -Lmingwex -o mingwm10.dll mingwex/libmingwex.a(strtodnrp.o): In function `strtod': /home/eblake/src/build/i686-pc-cygwin/winsup/mingw/mingwex/../../../../../winsup/mingw/include/stdlib.h:315: multiple definition of `_strtod' ... /usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld: warning: cannot find entry symbol _DllMainCRTStartup@12; defaulting to 6fbc1000 ertr01.o:(.rdata+0x0): undefined reference to `__pei386_runtime_relocator' collect2: ld returned 1 exit status make[3]: *** [mingwm10.dll] Error 1 make[3]: Leaving directory `/home/eblake/src/build/i686-pc-cygwin/winsup/mingw' How do we go about getting that resolved? -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: __xpg_strerror_r should not clobber strerror buffer
On 05/23/2011 02:45 PM, Eric Blake wrote: > On 05/21/2011 07:35 PM, Christopher Faylor wrote: >> On Sat, May 21, 2011 at 07:26:37PM -0600, Eric Blake wrote: >>> POSIX says that no other function in the standard should clobber the >>> strerror buffer. Our strerror_r is a GNU extension, so it can get away >>> with clobbering the buffer (but if we wanted to fix it, we would have to >>> separate _my_tls.locals.strerror_buf into two different buffers). Shoot. This introduced an off-by-one buffer overrun. I'm pushing this followup. Meanwhile, do we want a second buffer, so that the GNU strerror_r won't clobber the strerror buffer? +++ b/winsup/cygwin/ChangeLog @@ -2,6 +2,7 @@ * errno.cc (strerror): Print unknown errno as int. (__xpg_strerror_r): Likewise, and don't clobber strerror buffer. + * cygtls.h (strerror_buf): Resize to allow '-'. 2011-05-23 Corinna Vinschen diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h index 4d4306b..f911a6c 100644 --- a/winsup/cygwin/cygtls.h +++ b/winsup/cygwin/cygtls.h @@ -109,7 +109,7 @@ struct _local_storage } select; /* strerror */ - char strerror_buf[sizeof ("Unknown error 4294967295")]; + char strerror_buf[sizeof ("Unknown error -2147483648")]; /* times.cc */ char timezone_buf[20]; -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
fix perror POSIX compliance
This depends on the newlib patch: http://sourceware.org/ml/newlib/2011/msg00215.html In fact, if that patch goes in, then this one is required to avoid a link failure; this one can probably go in first but makes no difference to perror without the newlib patch. winsup/cygwin/ChangeLog|6 +++ winsup/cygwin/cygtls.h |1 + winsup/cygwin/errno.cc | 43 --- winsup/cygwin/tlsoffsets.h | 82 ++-- 4 files changed, 78 insertions(+), 54 deletions(-) 2011-05-23 Eric Blake * cygtls.h (strerror_r_buf): New buffer. * errno.cc (strerror): Move guts... (_strerror_r): ...to new function demanded by newlib. (strerror_r): Don't clobber strerror buffer. (_user_strerror): Drop unused declaration. * tlsoffsets.h: Regenerate. diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h index 6359e7c..a1642b1 100644 --- a/winsup/cygwin/cygtls.h +++ b/winsup/cygwin/cygtls.h @@ -110,6 +110,7 @@ struct _local_storage /* strerror errno.cc */ char strerror_buf[sizeof ("Unknown error -2147483648")]; + char strerror_r_buf[sizeof ("Unknown error -2147483648")]; /* times.cc */ char timezone_buf[20]; diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc index aa311b7..f3b925e 100644 --- a/winsup/cygwin/errno.cc +++ b/winsup/cygwin/errno.cc @@ -360,8 +360,6 @@ seterrno (const char *file, int line) seterrno_from_win_error (file, line, GetLastError ()); } -extern char *_user_strerror _PARAMS ((int)); - static char * strerror_worker (int errnum) { @@ -373,22 +371,38 @@ strerror_worker (int errnum) return res; } -/* strerror: convert from errno values to error strings. Newlib's - strerror_r returns "" for unknown values, so we override it to - provide a nicer thread-safe result string and set errno. */ +/* Newlib requires this override for perror and friends to avoid + clobbering strerror() buffer, without having to differentiate + between strerror_r signatures. This function is intentionally not + exported, so that only newlib can use it. */ extern "C" char * -strerror (int errnum) +_strerror_r (struct _reent *, int errnum, int internal, int *errptr) { char *errstr = strerror_worker (errnum); if (!errstr) { - __small_sprintf (errstr = _my_tls.locals.strerror_buf, "Unknown error %d", - errnum); - errno = _impure_ptr->_errno = EINVAL; + errstr = internal ? _my_tls.locals.strerror_r_buf +: _my_tls.locals.strerror_buf; + __small_sprintf (errstr, "Unknown error %d", errnum); + if (errptr) +*errptr = EINVAL; } return errstr; } +/* strerror: convert from errno values to error strings. Newlib's + strerror_r returns "" for unknown values, so we override it to + provide a nicer thread-safe result string and set errno. */ +extern "C" char * +strerror (int errnum) +{ + int error = 0; + char *result = _strerror_r (NULL, errnum, 0, &error); + if (error) +set_errno (error); + return result; +} + /* Newlib's provides declarations for two strerror_r variants, according to preprocessor feature macros. However, it returns "" instead of "Unknown error ...", so we override both @@ -396,10 +410,13 @@ strerror (int errnum) extern "C" char * strerror_r (int errnum, char *buf, size_t n) { - char *error = strerror (errnum); - if (strlen (error) >= n) -return error; - return strcpy (buf, error); + int error = 0; + char *errstr = _strerror_r (NULL, errnum, 1, &error); + if (error) +set_errno (error); + if (strlen (errstr) >= n) +return errstr; + return strcpy (buf, errstr); } extern "C" int diff --git a/winsup/cygwin/tlsoffsets.h b/winsup/cygwin/tlsoffsets.h index 4e459df..3ef7963 100644 --- a/winsup/cygwin/tlsoffsets.h +++ b/winsup/cygwin/tlsoffsets.h @@ -1,6 +1,6 @@ //;# autogenerated: Do not edit. -//; $tls::sizeof__cygtls = 3984; +//; $tls::sizeof__cygtls = 4012; ... // rest of generated file patch elided -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: fix perror POSIX compliance
On 05/24/2011 04:09 AM, Corinna Vinschen wrote: > On May 23 17:28, Eric Blake wrote: >> This depends on the newlib patch: >> http://sourceware.org/ml/newlib/2011/msg00215.html >> >> In fact, if that patch goes in, then this one is required to avoid a >> link failure; this one can probably go in first but makes no difference >> to perror without the newlib patch. > > You can apply this together with the newlib patch. But please > make sure that you also tested the newlib-only implementation. Yep, tested both, and now pushed. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: pthread_sigmask bug
On 07/09/2011 12:58 AM, Corinna Vinschen wrote: > On Jul 8 17:16, Eric Blake wrote: >> The current implementation of pthread_sigmask violates POSIX: > > PTC? winsup/cygwin/ChangeLog |6 ++ winsup/cygwin/signal.cc | 10 ++ 2 files changed, 12 insertions(+), 4 deletions(-) 2011-07-09 Eric Blake * signal.cc (handle_sigprocmask): Return error rather than setting errno, for pthread_sigmask. (sigprocmask): Adjust caller. diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index 9c920d0..4c472fd 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -174,7 +174,10 @@ usleep (useconds_t useconds) extern "C" int sigprocmask (int how, const sigset_t *set, sigset_t *oldset) { - return handle_sigprocmask (how, set, oldset, _my_tls.sigmask); + int res = handle_sigprocmask (how, set, oldset, _my_tls.sigmask); + if (res) +set_errno (res); + return res ? -1 : 0; } int __stdcall @@ -184,13 +187,12 @@ handle_sigprocmask (int how, const sigset_t *set, sigset_t *oldset, sigset_t& op if (how != SIG_BLOCK && how != SIG_UNBLOCK && how != SIG_SETMASK) { syscall_printf ("Invalid how value %d", how); - set_errno (EINVAL); - return -1; + return EINVAL; } myfault efault; if (efault.faulted (EFAULT)) -return -1; +return EFAULT; if (oldset) *oldset = opmask; -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: Extend faq.using to discuss fork failures
On 08/25/2011 08:08 PM, Ryan Johnson wrote: Based on the feedback on cygwin-dev, I've put together a revised pair of faq.using entries: one listing briefly the symptoms of fork failures and what to do about it, and the other giving some details about why fork fails (sometimes in spite of everything we do to compensate). + +DLL injection by BLODA. Badly-behaved applications which +inject dlls into other processes often manage to clobber important +sections of the child's address space, leading to base address +collisions which rebasing cannot fix. I would suggest adding an tag around BLODA, to point users to the list of known bad software. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org
Re: [PATCH] Allow usage of union wait for wait() functions and macros
On 10/05/2011 04:57 AM, Christian Franke wrote: The file include/sys/wait.h provides union wait but neither the wait() functions nor the W*() macros allow to actually use it. Compilation of cdrkit 1.1.11 fails because the configure check assumes that union wait is the status parameter type if its declaration exists. The attached patch fixes this. It uses GCC extensions for C and overloading for C++. Works also with the old Cygwin gcc-3. +/* Will be redefined in sys/wait.h. */ +#define __wait_status_to_int(w) (w) + /* A status looks like: <2 bytes info> <2 bytes code> As long as you're touching this code, fix this incorrect comment. A status is 16 bits, and looks like: <1 byte info> <1 byte code> -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org
Re: ptsname_r
On 11/07/2011 01:46 PM, Eric Blake wrote: Thanks. Also, even with your patches of today, ptsname() is still not thread-safe; should we be sticking that in a thread-local buffer rather than in static storage, similar to how other functions like strerror() are thread-safe? I didn't tackle that, Also, should we have an efault handler in syscalls.cc ptsname_r(), similar to ttyname_r(), so as to gracefully reject invalid buffers rather than faulting? but I had this additional code in my sandbox right before your commit hit CVS; should I add a ChangeLog and make it a formal patch submission? diff --git a/winsup/cygwin/include/cygwin/stdlib.h b/winsup/cygwin/include/cygwin/stdlib.h index d2dfe4c..20358ef 100644 --- a/winsup/cygwin/include/cygwin/stdlib.h +++ b/winsup/cygwin/include/cygwin/stdlib.h @@ -1,6 +1,6 @@ /* stdlib.h - Copyright 2005, 2006, 2007, 2008, 2009 Red Hat Inc. + Copyright 2005, 2006, 2007, 2008, 2009, 2011 Red Hat Inc. This file is part of Cygwin. diff --git a/winsup/cygwin/libc/bsdlib.cc b/winsup/cygwin/libc/bsdlib.cc index 3b6e7e4..c4398d3 100644 --- a/winsup/cygwin/libc/bsdlib.cc +++ b/winsup/cygwin/libc/bsdlib.cc @@ -108,7 +108,7 @@ openpty (int *amaster, int *aslave, char *name, const struct termios *termp, { grantpt (master); unlockpt (master); - strcpy (pts, ptsname (master)); + ptsname_r (master, pts, sizeof pts); revoke (pts); if ((slave = open (pts, O_RDWR | O_NOCTTY)) >= 0) { diff --git a/winsup/cygwin/posix.sgml b/winsup/cygwin/posix.sgml index ef27fde..5c510ed 100644 --- a/winsup/cygwin/posix.sgml +++ b/winsup/cygwin/posix.sgml @@ -1131,6 +1131,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008). pow10f ppoll pthread_getattr_np +ptsname_r removexattr setxattr strchrnul diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 514d458..68dec59 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -2913,16 +2913,24 @@ ptsname (int fd) extern "C" int ptsname_r (int fd, char *buf, size_t buflen) { - if (!buf) + int ret = 0; + myfault efault; + if (efault.faulted ()) +ret = EFAULT; + else { - set_errno (EINVAL); - return EINVAL; + cygheap_fdget cfd (fd, true); + if (cfd < 0) + ret = EBADF; + else if (!buf) +ret = EINVAL; + else + ret = cfd->ptsname_r (buf, buflen); } - - cygheap_fdget cfd (fd); - if (cfd < 0) -return 0; - return cfd->ptsname_r (buf, buflen); + if (ret) +set_errno (ret); + debug_printf ("returning %d pts: %s", ret, ret ? "NULL" : buf); + return ret; } static int __stdcall -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org
Re: [PATCH] Add get_current_dir_name(3)
On 01/01/2012 12:13 AM, Yaakov (Cygwin/X) wrote: >> > You have to check st_dev here too don't you? > Of course. Revised patch for winsup/cygwin attached. > > +extern "C" char * > +get_current_dir_name (void) > +{ > + char *pwd = getenv ("PWD"); > + char *cwd = getcwd (NULL, 0); > + > + if (pwd) > +{ > + struct __stat64 pwdbuf, cwdbuf; > + stat64 (pwd, &pwdbuf); > + stat64 (cwd, &cwdbuf); > + if ((pwdbuf.st_dev == cwdbuf.st_dev) && (pwdbuf.st_ino == > cwdbuf.st_ino)) > +{ > + cwd = (char *) malloc (strlen (pwd) + 1); Memory leak. You need to free(cwd) before reassigning it. And why are you using malloc(strlen())/strcpy(), when you could just use strdup()? -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: [PATCH] Add scandirat(3)
On 02/21/2012 03:44 PM, Yaakov (Cygwin/X) wrote: > scandirat(3) was added in glibc-2.15[1] and has supposedly been proposed > for addition to POSIX.1[2]. Patch attached. I haven't yet seen anyone propose it for POSIX, but it would indeed be a welcome addition there. Also it would be a welcome addition to have pathconfat(), although this hasn't yet happened on the Linux side of things, let alone any POSIX proposal. At any rate, +1 for having this in cygwin. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
fix tcgetsid return type
Detected by gnulib's unit tests. POSIX requires tcgetsid to return pid_t, not int. 2012-02-27 Eric Blake * include/sys/termios.h (tcgetsid): Fix return type. * termios.cc (tcgetsid): Likewise. * fhandler_termios.cc (fhandler_termios::tcgetsid): Likewise. * fhandler.h (fhandler_base): Likewise. * fhandler.cc (fhandler_base::tcgetsid): Likewise. diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index ef25a07..c3bca4f 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -1464,7 +1464,7 @@ fhandler_base::tcgetpgrp () return -1; } -int +pid_t fhandler_base::tcgetsid () { set_errno (ENOTTY); diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 605f59b..3b186bd 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -383,7 +383,7 @@ public: virtual int tcgetattr (struct termios *t); virtual int tcsetpgrp (const pid_t pid); virtual int tcgetpgrp (); - virtual int tcgetsid (); + virtual pid_t tcgetsid (); virtual bool is_tty () const { return false; } virtual bool ispipe () const { return false; } virtual pid_t get_popen_pid () const {return 0;} @@ -1155,7 +1155,7 @@ class fhandler_termios: public fhandler_base virtual void __release_output_mutex (const char *fn, int ln) {} void echo_erase (int force = 0); virtual _off64_t lseek (_off64_t, int); - int tcgetsid (); + pid_t tcgetsid (); fhandler_termios (void *) {} diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc index c218fde..36017dc 100644 --- a/winsup/cygwin/fhandler_termios.cc +++ b/winsup/cygwin/fhandler_termios.cc @@ -1,7 +1,7 @@ /* fhandler_termios.cc Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009, - 2010, 2011 Red Hat, Inc. + 2010, 2011, 2012 Red Hat, Inc. This file is part of Cygwin. @@ -401,7 +401,7 @@ fhandler_termios::sigflush () tcflush (TCIFLUSH); } -int +pid_t fhandler_termios::tcgetsid () { if (myself->ctty != -1 && myself->ctty == tc ()->ntty) diff --git a/winsup/cygwin/include/sys/termios.h b/winsup/cygwin/include/sys/termios.h index a0d1b24..a87f9de 100644 --- a/winsup/cygwin/include/sys/termios.h +++ b/winsup/cygwin/include/sys/termios.h @@ -1,7 +1,7 @@ /* sys/termios.h Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, - 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. + 2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc. This file is part of Cygwin. @@ -14,6 +14,8 @@ details. */ #ifndef_SYS_TERMIOS_H #define _SYS_TERMIOS_H +#include + #defineTIOCMGET0x5415 #defineTIOCMBIS0x5416 #defineTIOCMBIC0x5417 @@ -328,7 +330,7 @@ int tcsendbreak (int, int); int tcdrain (int); int tcflush (int, int); int tcflow (int, int); -int tcgetsid (int); +pid_t tcgetsid (int); void cfmakeraw (struct termios *); speed_t cfgetispeed(const struct termios *); speed_t cfgetospeed(const struct termios *); diff --git a/winsup/cygwin/termios.cc b/winsup/cygwin/termios.cc index 3096513..0fb0de2 100644 --- a/winsup/cygwin/termios.cc +++ b/winsup/cygwin/termios.cc @@ -1,7 +1,7 @@ /* termios.cc: termios for WIN32. Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. + 2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc. Written by Doug Evans and Steve Chamberlain of Cygnus Support d...@cygnus.com, s...@cygnus.com @@ -207,7 +207,7 @@ tcgetpgrp (int fd) return res; } -extern "C" int +extern "C" pid_t tcgetsid (int fd) { int res; -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: fix tcgetsid return type
On 02/27/2012 04:57 PM, Christopher Faylor wrote: > On Mon, Feb 27, 2012 at 04:25:36PM -0700, Eric Blake wrote: >> Detected by gnulib's unit tests. POSIX requires tcgetsid to return >> pid_t, not int. >> >> 2012-02-27 Eric Blake >> >> * include/sys/termios.h (tcgetsid): Fix return type. >> * termios.cc (tcgetsid): Likewise. >> * fhandler_termios.cc (fhandler_termios::tcgetsid): Likewise. >> * fhandler.h (fhandler_base): Likewise. >> * fhandler.cc (fhandler_base::tcgetsid): Likewise. > > Looks good. Please check in. Done. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: avoid calling strlen() twice in readlink()
On 03/08/2012 06:37 AM, Václav Zeman wrote: > Hi. > > Here is a tiny patch to avoid calling strlen() twice in readlink(). > > > - ssize_t len = min (buflen, strlen (pathbuf.get_win32 ())); > + size_t pathbuf_len = strlen (pathbuf.get_win32 ()); > + size_t len = MIN (buflen, pathbuf_len); >memcpy (buf, pathbuf.get_win32 (), len); For that matter, is calling pathbuf.get_win32() twice worth factoring out? -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: /dev/clipboard pasting with small read() buffer
On 08/16/2012 08:20 AM, Thomas Wolff wrote: >>> MB_CUR_MAX does not work because its value is 1 at this point >> So what about MB_LEN_MAX then? There's no problem using a multiplier, >> but a symbolic constant is always better than a numerical constant. > I've now used _MB_LEN_MAX from newlib.h, rather than MB_LEN_MAX from > limits.h (note the "_" distinction :) ), > because the latter, by its preceding comment, reserves the option to be > changed into a dynamic function in the future, which could then possibly > have the same problems as MB_CUR_MAX. POSIX requires MB_LEN_MAX to be a constant, only MB_CUR_MAX can be dynamic. We cannot change MB_LEN_MAX to be dynamic in the future. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
fix off-by-one in dup2
Solves the segfault here: http://cygwin.com/ml/cygwin/2013-09/msg00397.html but does not address the fact that we are still screwy with regards to rlimit. == Ultimately, based on my understanding of POSIX and glibc, my goal is to have a number of changes (this patch only scratches the surface; there's more to go): dtable.h tracks soft and hard limits, inherited over fork and preserved across exec hard limit starts at OPEN_MAX_MAX and can only be reduced soft limit starts at hard limit, and can be reduced to _POSIX_OPEN_MAX (8) dtable.size starts at MAX(32, fork/exec size) getdtablesize() and sysconf(_SC_OPEN_MAX) always returns the soft limit, as in glibc and permitted by POSIX (_SC_OPEN_MAX is the only sysconf variable that can be runtime dynamic) dtable.size is decoupled from soft limit, and is guaranteed to be <= hard limit. It can grow up to current soft limit; but soft limit can later be reduced lower than dtable.size (glibc does this); on fork and exec, we are careful to still allow fds beyond the current soft limit. getrlimit(RLIMIT_NOFILE, &r) => returns soft and hard limits from dtable rather than hard limit as a constant and soft limit as current dtable.size setrlimit(RLIMIT_NOFILE, &r) => cannot set hard limit to unlimited; soft limit of unlimited is translated to current hard limit; hard limit cannot be increased (EPERM) or reduced below dtable.size (EINVAL); soft limit can be reduced arbitrarily (including below OPEN_MAX of 256) setdtablesize() => guarantees that dtable.size is at least that large (must be <= soft limit), but does not lower dtable.size or change limits = 2013-09-25 Eric Blake dup2: fix off-by-one crash * dtable.cc (dup3): Fix off-by-one. (find_unused_handle): Reduce time spent expanding during dup. * syscalls.cc (setdtablesize): Report error on invalid value. diff --git i/winsup/cygwin/dtable.cc w/winsup/cygwin/dtable.cc index 2501a26..c2982a8 100644 --- i/winsup/cygwin/dtable.cc +++ w/winsup/cygwin/dtable.cc @@ -233,7 +233,7 @@ dtable::find_unused_handle (int start) if (fds[i] == NULL) return i; } - while (extend (NOFILE_INCR)); + while (extend (MAX (NOFILE_INCR, start - size))); return -1; } @@ -754,7 +754,7 @@ dtable::dup3 (int oldfd, int newfd, int flags) if (!not_open (newfd)) close (newfd); - else if ((size_t) newfd > size + else if ((size_t) newfd >= size && find_unused_handle (newfd) < 0) /* couldn't extend fdtab */ { diff --git i/winsup/cygwin/syscalls.cc w/winsup/cygwin/syscalls.cc index e1886e6..8c1c70a 100644 --- i/winsup/cygwin/syscalls.cc +++ w/winsup/cygwin/syscalls.cc @@ -2578,6 +2578,9 @@ system (const char *cmdstring) extern "C" int setdtablesize (int size) { + if (size < 0) +return -1; + if (size <= (int)cygheap->fdtab.size || cygheap->fdtab.extend (size - cygheap->fdtab.size)) return 0; -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: fix off-by-one in dup2
On 10/15/2013 08:06 AM, Christopher Faylor wrote: > On Wed, Sep 25, 2013 at 05:26:25PM -0600, Eric Blake wrote: >> Solves the segfault here: http://cygwin.com/ml/cygwin/2013-09/msg00397.html >> but does not address the fact that we are still screwy with regards to >> rlimit. > > Corinna reminded me about this. > > Sorry for the delay in responding. I was investigating if setdtablesize > should set an errno on error but it is difficult to say if it should > since it seems not to be a POSIX or Linux. So, I guess we can just say > that it should set EINVAL. Would you mind making that minor change and > checking this in? Yikes, I still haven't done this (and was reminded by today's announcement to test snapshots). I'll try to get to it pronto. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: fix off-by-one in dup2
On 12/04/2013 10:51 AM, Christopher Faylor wrote: >>>> One question, though. Assuming start is == size, then the current code >>>> in CVS extends the fd table by only 1. If that happens often, the >>>> current code would have to call ccalloc/memcpy/cfree a lot. Wouldn't >>>> it in fact be better to extend always by at least NOFILE_INCR, and to >>>> extend by (1 + start - size) only if start is > size + NOFILE_INCR? >>>> Something like >>>> >>>> size_t extendby = (start >= size + NOFILE_INCR) ? 1 + start - size : >>>> NOFILE_INCR; >>>> Always increasing by a minimum of NOFILE_INCR is wrong in one case - we should never increase beyond OPEN_MAX_MAX (currently 3200). dup2(0, 3199) should succeed (unless it fails with EMFILE due to rlimit, but we already know that our handling of setrlimit(RLIMIT_NOFILE) is still a bit awkward); but dup2(0, 3200) must always fail with EBADF. I think the code in CVS is still wrong: we want to increase to the larger of the value specified by the user or NOFILE_INCR to minimize repeated calloc, but we also need to cap the increase to be at most OPEN_MAX_MAX descriptors, to avoid having a table larger than what the rest of our code base will support. Not having NOFILE_INCR free slots after a user allocation is not fatal; it means that the first allocation to a large number will not have tail padding, but the next allocation to fd+1 will allocate NOFILE_INCR slots rather than just one. My original idea of MAX(NOFILE_INCR, start - size) expresses that. >> >> That might be helpful. Tcsh, for instance, always dup's it's std >> descriptors to the new fds 15-19. If it does so in this order, it would >> have to call extend 5 times. > > dtable.h:#define NOFILE_INCR32 > > It shouldn't extend in that scenario. The table starts with 32 > elements. Rather, the table starts with 256 elements; which is why dup2 wouldn't crash until dup'ing to 256 or greater before I started touching this. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
namespace safety with attributes
As pointed out here: https://cygwin.com/ml/cygwin/2014-07/msg00371.html any use of __attribute__ in a header that can be included by a user should be namespace-safe, by decorating the attribute arguments with __ (while gcc does a lousy job at documenting it, ALL attributes have a __ counterpart, precisely so that public headers can use attributes without risk of collision with macros belonging to user namespace). 2014-07-31 Eric Blake * include/pthread.h: Decorate attribute names with __, for namespace safety. * include/cygwin/core_dump.h: Likewise. * include/cygwin/cygwin_dll.h: Likewise. * include/sys/cygwin.h: Likewise. * include/sys/strace.h: Likewise. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org Index: include/pthread.h === RCS file: /cvs/src/src/winsup/cygwin/include/pthread.h,v retrieving revision 1.41 diff -u -p -r1.41 pthread.h --- include/pthread.h 16 Jul 2014 10:21:18 - 1.41 +++ include/pthread.h 31 Jul 2014 16:04:05 - @@ -76,7 +76,7 @@ int pthread_attr_getschedpolicy (const p int pthread_attr_getscope (const pthread_attr_t *, int *); int pthread_attr_getstack (const pthread_attr_t *, void **, size_t *); int pthread_attr_getstackaddr (const pthread_attr_t *, void **) -__attribute__ ((deprecated)); +__attribute__ ((__deprecated__)); int pthread_attr_init (pthread_attr_t *); int pthread_attr_setdetachstate (pthread_attr_t *, int); int pthread_attr_setguardsize (pthread_attr_t *, size_t); @@ -88,7 +88,7 @@ int pthread_attr_setscope (pthread_attr_ #ifdef _POSIX_THREAD_ATTR_STACKADDR int pthread_attr_setstack (pthread_attr_t *, void *, size_t); int pthread_attr_setstackaddr (pthread_attr_t *, void *) -__attribute__ ((deprecated)); +__attribute__ ((__deprecated__)); #endif #ifdef _POSIX_THREAD_ATTR_STACKSIZE @@ -137,7 +137,7 @@ int pthread_create (pthread_t *, const p void *(*)(void *), void *); int pthread_detach (pthread_t); int pthread_equal (pthread_t, pthread_t); -void pthread_exit (void *) __attribute__ ((noreturn)); +void pthread_exit (void *) __attribute__ ((__noreturn__)); int pthread_getcpuclockid (pthread_t, clockid_t *); int pthread_getschedparam (pthread_t, int *, struct sched_param *); void *pthread_getspecific (pthread_key_t); Index: include/cygwin/core_dump.h === RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/core_dump.h,v retrieving revision 1.2 diff -u -p -r1.2 core_dump.h --- include/cygwin/core_dump.h 11 Sep 2001 20:01:01 - 1.2 +++ include/cygwin/core_dump.h 31 Jul 2014 16:04:05 - @@ -1,6 +1,6 @@ /* core_dump.h - Copyright 1999, 2000, 2001 Red Hat, Inc. + Copyright 1999, 2000, 2001, 2014 Red Hat, Inc. Written by Egor Duda @@ -27,7 +27,7 @@ struct win32_core_process_info char command_line[1]; } #ifdef __GNUC__ - __attribute__ ((packed)) + __attribute__ ((__packed__)) #endif ; @@ -38,7 +38,7 @@ struct win32_core_thread_info CONTEXT thread_context; } #ifdef __GNUC__ - __attribute__ ((packed)) + __attribute__ ((__packed__)) #endif ; @@ -49,7 +49,7 @@ struct win32_core_module_info char module_name[1]; } #ifdef __GNUC__ - __attribute__ ((packed)) + __attribute__ ((__packed__)) #endif ; @@ -64,7 +64,7 @@ struct win32_pstatus } data ; } #ifdef __GNUC__ - __attribute__ ((packed)) + __attribute__ ((__packed__)) #endif ; Index: include/cygwin/cygwin_dll.h === RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/cygwin_dll.h,v retrieving revision 1.12 diff -u -p -r1.12 cygwin_dll.h --- include/cygwin/cygwin_dll.h 23 Apr 2013 09:44:35 - 1.12 +++ include/cygwin/cygwin_dll.h 31 Jul 2014 16:04:05 - @@ -1,6 +1,6 @@ /* cygwin_dll.h - Copyright 1998, 1999, 2000, 2001, 2009, 2011, 2012, 2013 Red Hat, Inc. + Copyright 1998, 1999, 2000, 2001, 2009, 2011, 2012, 2013, 2014 Red Hat, Inc. This file is part of Cygwin. @@ -35,9 +35,9 @@ static DWORD storedReason; \ static void* storedPtr; \ int __dynamically_loaded; \ \ -static int __dllMain (int a __attribute__ ((unused)), \ - char **b __attribute__ ((unused)), \ - char **c __attribute__ ((unused))) \ +static int __dllMain (int a __attribute__ ((__unused__)), \ + char **b __attribute__ ((__unused__)), \ + char **c __attribute__ ((__unused__))) \ { \ return Entry (storedHandle, storedReason, storedPtr); \ } \ Index: include/sys/cygwin.h === RCS file: /cvs/src/src/winsup/cygwin/include/sys/cygwin.h,v retrieving revision 1.108 diff -u -p -r1.108 cygwin.h --- include/sys/cygwin.h 15 May
docs: improve package maintainer instructions
I noticed that the main link on the cygwin.com left navbar (https://cygwin.com/setup.html#submitting) has outdated instructions; rather than duplicate things, I'd rather have a link to the more up-to-date page (https://sourceware.org/cygwin-apps/package-upload.html). Okay to push? 2014-08-02 Eric Blake * setup.html: Modernize, point to package-upload.html -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org ? setup.patch Index: setup.html === RCS file: /cvs/cygwin/htdocs/setup.html,v retrieving revision 1.130 diff -u -p -r1.130 setup.html --- setup.html 8 May 2014 18:16:33 - 1.130 +++ setup.html 2 Aug 2014 13:24:21 - @@ -25,15 +25,20 @@ Submitting a package Package file naming -Package naming scheme: use the vendor's version plus a release suffix for ports of existing packages (i.e. bash 2.04 becomes 2.04-1, 2.04-2, etc., until bash 2.05 is ported, which would be 2.05-1, etc). Some packages also use a YYMMDD format for their versions, e.g. binutils-20010901-1.tar.bz2. The first release of a package should have a -1 release suffix. +Package naming scheme: use the vendor's version plus a release + suffix for ports of existing packages (i.e. findutils 4.5.12 becomes + 4.5.12-1, 4.5.12-2, etc., until findutils 4.5.13 is ported, which + would be 4.5.13-1, etc). Some packages also use a YYMMDD format for + their versions, e.g. terminfo-5.9-20140524-1.tar.xz. The first release + of a package should have a -1 release suffix. A complete package currently consists of three files: a binary tar file a source tar file a setup.hint file -Binary tar files are named "package-version-release.tar.bz2". They generally contain the executable files that will be installed on a user's system plus any auxiliary files needed by the package. See the package contents section below for more details on the contents of a binary tar file. -Source tar files are named "package-version-release-src.tar.bz2". Source tar files should contain the source files, patches and scripts needed to rebuild the package. While installing these files is optional, the inclusion of a source tar file is part of the totality that makes up a Cygwin package and so, these files are not optional. In some cases, there may be multiple packages generated from the same source; for instance, one might have a "boffo" package and its associated shared library in "libboffo7", where both are generated from the same -src tarball. See the package contents section below for more details on the contents of a -src tar file, and the setup.hint section for information on the "external-source:" option. +Binary tar files are named "package-version-release.tar.xz". They generally contain the executable files that will be installed on a user's system plus any auxiliary files needed by the package. See the package contents section below for more details on the contents of a binary tar file. +Source tar files are named "package-version-release-src.tar.xz". Source tar files should contain the source files, patches and scripts needed to rebuild the package. While installing these files is optional, the inclusion of a source tar file is part of the totality that makes up a Cygwin package and so, these files are not optional. In some cases, there may be multiple packages generated from the same source; for instance, one might have a "boffo" package and its associated shared library in "libboffo7", where both are generated from the same -src tarball. See the package contents section below for more details on the contents of a -src tar file, and the setup.hint section for information on the "external-source:" option. The setup.hint file is discussed below. Automatic setup.ini generation on sourceware.org A script runs on sourceware.org which collects information from (currently) the release directory in the ftp download area. Information from subdirectories of these directories is parsed to automatically generate the default http://sourceware.org/cygwin-apps/setup.html#setup.ini";>setup.ini file which is used by the Cygwin setup program for installation control. If you are responsible for maintaining a Cygwin package, it is important that you understand how this process works. @@ -45,14 +50,14 @@ release/boffo/<boffo files> release/boffo/boffo-devel/ release/boffo/boffo-devel/<boffo-devel file> -Each directory contains source and binary tar files which have been been compressed using bzip2. The required format of these filenames is: package-version-release[-src].tar.bz2 . The contents of these files is discussed below. +Each directory contains source and binary tar files which have been been compressed using xz. The required format of these filenames is: package-version-release[-s
Re: docs: improve package maintainer instructions
On 08/04/2014 03:14 AM, Corinna Vinschen wrote: > I'm fine with the changes, barring Yaakov's nits. I fixed those. > > However, while we're at it shouldn't we change from "cygport is the > accepted way to make Cygwin packages" to "cygport is the required way to > make new Cygwin packages and the (strongly) recommended way for package > updates"? I for one think it's time to switch to a single packaging > method. After all, you don't have rpm packages in Debian or apt > packages in Fedora. This will also greatly simplify to set up an > automated build system for Cygwin packages at one point. Agreed; so here's what I added in before pushing my patch: @@ -283,9 +288,12 @@ etc... Ensure that your package handles being installed on binary and text mounts correctly. -While you could make a package satisfying these requirements by hand, the -accepted way to make Cygwin packages is using the cygport tool, which -automatically handles most of the above issues for you. +While older packages exist which satisfy these requirements by hand, the +only accepted way to make a new Cygwin package is using the cygport tool, which +automatically handles most of the above issues for you. It is also +strongly recommended to convert existing packages to cygport when +updating them; ask on the cygwin-apps list if you need help +converting an existing package to use cygport. Making a package with cygport -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: [PATCH] Hide sethostname() in unistd.h
On 06/17/2015 02:57 PM, Yaakov Selkowitz wrote: > On Wed, 2015-06-17 at 22:25 +0200, Christian Franke wrote: >> Busybox does not use autoconf or similar. It requires manual platform >> specific configuration which does not yet support a missing >> sethostname(). After adding HAVE_SETHOSTNAME manually and some other >> minor additions, busybox (which many commands enabled) compiles and >> works reasonably. >> Would ITP make sense ? > > TBH I'm not sure. Presuming you're discussing the single-executable > build (so as not to clobber coreutils etc.), there is still the question > of (not) matching the heavily-patched coreutils wrt .exe handling etc. > What do you think the use case would be? Portability testing is one thing - I often compare how bash/dash/zsh/mksh handle a shell construct, and adding busybox sh into the mix adds another perspective. But yeah, I don't see busybox becoming the default source of these apps, so much as an alternative implementation. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: [PATCH] cygwin: update child info magic
On 02/12/2016 01:05 PM, Yaakov Selkowitz wrote: >> Off the top of my head, I don't know. Usually only a change to >> child_info.h should affect CHILD_INFO_MAGIC. Unless the preprocessed >> output of gcc differs for some reason. > > It turns out it does. Anything that is substituted by preprocessor is > placed on its own line with gcc-5, e.g. with NULL and _SYMSTR: Does the use of -P during preprocessing, to inhibit line markers, force gcc to quit adding extra lines? In my quick testing with Fedora's gcc 5.3.1: $ printf '#include \nstart NULL end\n' \ | gcc -E- | sed -n '/start/,$ p' start # 2 "" 3 4 ((void *)0) # 2 "" end $ printf '#include \nstart NULL end\n' \ | gcc -E -P - | sed -n '/start/,$ p' start ((void *)0) end > -extern child_info_spawn *spawn_info asm ("_" "child_proc_info"); > -extern child_info_fork *fork_info asm ("_" "child_proc_info"); > +extern child_info_spawn *spawn_info asm ( > +"_" If it were merely a case of more vs. less whitespace, we could postprocess (turn all newlines and space sequences into a single space); but this is a case of introducing whitespace, making the problem trickier, if -P doesn't work. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: [PATCH] cygwin: update child info magic
On 02/12/2016 01:31 PM, Corinna Vinschen wrote: >> >> extern "C" { >> extern child_info *child_proc_info; >> -extern child_info_spawn *spawn_info asm ("_" "child_proc_info"); >> -extern child_info_fork *fork_info asm ("_" "child_proc_info"); >> +extern child_info_spawn *spawn_info asm ( >> +"_" >> +"child_proc_info"); >> +extern child_info_fork *fork_info asm ( >> + "_" >> + "child_proc_info"); >> } > > Is that deliberate or a bug? Deliberate. gcc 5 now adds additional #line directives around every macro expansion that came from a different file, so that you can more easily track which files were involved in macro expansion. The output here is show with #line directives filtered out, but it is a gcc feature. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: [PATCH] ccwrap: fix build with non-english locale set
On 02/29/2016 06:19 AM, patrick bendorf wrote: > after some discussion on irc and the list i'm resubmitting a simpler > version of the patch. > setting the locale on cygwin to 'C.UTF-8' is not needed, so i'm always > setting it to 'C' which is sufficient for the build process and the most > simple fix. > > /winsup/ > * ccwrap: change locale to 'C' as ccwrap searches for literal strings > "search starts here" and "End of search list" which may be localized. > --- > winsup/ccwrap | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/winsup/ccwrap b/winsup/ccwrap > index 7580e7a..0c6a170 100755 > --- a/winsup/ccwrap > +++ b/winsup/ccwrap > @@ -12,6 +12,7 @@ if ($ARGV[0] ne '++') { > $cxx = 1; > } > die "$0: $ccorcxx environment variable does not exist\n" unless exists > $ENV{$ccorcxx}; > +$ENV{'LANG'} = 'C'; This won't work if I have LC_ALL set in my environment. If you want to force the locale, you want to set LC_ALL (highest priority), not LANG (lowest priority). -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: [PATCH] Re: Cygwin select() issues and improvements
On 03/17/2016 03:29 AM, John Hood wrote: > On 3/14/2016 6:12 AM, Corinna Vinschen wrote: >> Hi John, >> >> On Mar 13 17:37, john hood wrote: >>> On 3/4/16 3:58 AM, Corinna Vinschen wrote: >>>> John, >>>> >>>> >>>> Ping? I'd be interested to get your patches into Cygwin. select >>>> really needs some kicking :) >>> Sorry to be so slow responding. Here's a rebased, squashed, >>> changelog-ified patch, >> Thank you. Uhm... I just don't understand why you squashed them into a >> single big patch. Multiple independent smaller patches are better to >> handle, especially when looking for potential bugs later. >> >> Would you mind terribly to split them again? > i just looked at this, but I'm going to leave the patch as a single > patch. The patches in the original series are not completely > independent of each other, it has a bug or two in the middle, and also > some reversed edits. The endpoint is known tested and working, but some > of the intermediate commits aren't that well tested. It *is* too big as > a single commit-- but I think that's better than the original patch > series from my development work, which I never intended to submit as-is > anyway. But that's where 'git rebase' is your friend. Just because your original series wasn't perfect doesn't mean you can avoid cleaning things up and posting an improved version. The goal of patch submissions is to make the reviewer's job easier, even if it makes it longer for you to post the perfect patch series. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: Declaration of crypt
On 06/09/2016 08:07 AM, Ken Brown wrote: > On 6/9/2016 8:32 AM, Corinna Vinschen wrote: >> Can you please define crypt, encrypt and setkey explicitely in unistd.h >> per POSIX, rather than including crypt.h? This would not only be target >> independent, it would also be more correct. As a side effect I will >> have to come up with a new version of the crypt package, because our >> crypt.h is using a wrong prototypes for setkey (const is missing). > > setkey is supposed to be in stdlib.h rather than unistd.h, so I've done > that. > > One minor question about encrypt: The Posix prototype has 'char > block[64]' as the first argument, but Cygwin's crypt.h simply has 'char > *block'. FreeBSD and glibc also use 'char *block', so I did the same. The two are identical, according to C rules. Using [64] rather than * gives a bit more indication about the size of the array that must be passed, but doesn't change the compiler behavior. > Or would you rather follow Posix here? > >> Thanks a lot and sorry again, > > No problem. Revised patch attached. > > Ken > -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
[PATCH] Fix 32-bit SSIZE_MAX
POSIX requires that SSIZE_MAX have the same type as ssize_t, but on 32-bit, we were defining it as a long even though ssize_t resolves to an int. It also requires that SSIZE_MAX be usable via preprocessor #if, so we can't cheat and use a cast. If this were newlib, I'd have had to hack _intsup.h to probe the qualities of size_t (via gcc's __SIZE_TYPE__), similar to how we already probe the qualities of int8_t and friends, then cross our fingers that ssize_t happens to have the same rank (most systems do, but POSIX permits a system where they differ such as size_t being long while ssize_t is int). Unfortunately gcc gives us neither __SSIZE_TYPE__ nor __SSIZE_MAX__. On the other hand, our limits.h is specific to cygwin, we can just shortcut to the correct results rather than being generic to all possible ABI. Signed-off-by: Eric Blake --- winsup/cygwin/include/limits.h | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/include/limits.h b/winsup/cygwin/include/limits.h index 2083e3e..cf3c8d0 100644 --- a/winsup/cygwin/include/limits.h +++ b/winsup/cygwin/include/limits.h @@ -128,9 +128,17 @@ details. */ #undef ULLONG_MAX #define ULLONG_MAX (LLONG_MAX * 2ULL + 1) -/* Maximum size of ssize_t */ +/* Maximum size of ssize_t. Sadly, gcc doesn't give us __SSIZE_MAX__ + the way it does for __SIZE_MAX__. On the other hand, we happen to + know that for Cygwin, ssize_t is 'int' on 32-bit and 'long' on + 64-bit, and this particular header is specific to Cygwin, so we + don't have to jump through hoops. */ #undef SSIZE_MAX +#if __WORDSIZE == 64 #define SSIZE_MAX (__LONG_MAX__) +#else +#define SSIZE_MAX (__INT_MAX__) +#endif /* Runtime Invariant Values */ -- 2.5.5
Re: [PATCH] Fix 32-bit SSIZE_MAX
On 07/14/2016 09:09 AM, Corinna Vinschen wrote: > On Jul 13 15:02, Eric Blake wrote: >> POSIX requires that SSIZE_MAX have the same type as ssize_t, but >> on 32-bit, we were defining it as a long even though ssize_t >> resolves to an int. It also requires that SSIZE_MAX be usable >> via preprocessor #if, so we can't cheat and use a cast. >> >> If this were newlib, I'd have had to hack _intsup.h to probe the >> qualities of size_t (via gcc's __SIZE_TYPE__), similar to how we >> already probe the qualities of int8_t and friends, then cross our >> fingers that ssize_t happens to have the same rank (most systems >> do, but POSIX permits a system where they differ such as size_t >> being long while ssize_t is int). Unfortunately gcc gives us >> neither __SSIZE_TYPE__ nor __SSIZE_MAX__. On the other hand, our >> limits.h is specific to cygwin, we can just shortcut to the >> correct results rather than being generic to all possible ABI. >> >> Signed-off-by: Eric Blake >> --- >> winsup/cygwin/include/limits.h | 10 +- > Looks good, please apply. And I remembered to update the release notes, too. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: Return the correct value for sysconf(_SC_PAGESIZE)
On 11/16/2016 07:56 AM, Erik Bray wrote: >> There is no good reason to use the non-POSIXy page size. It doesn't >> help you in the least for any pagesize-related functionality. Mmap >> as well as malloc and friends only work with _SC_PAGESIZE sized pages. >> >> It sounds as if you're looking for a solution for which there's no >> problem... > > > FWIW the background here is that I'm working on porting psutil [1] to > Cygwin, and trying to accomplish as much as *possible* through the > POSIX interfaces without having to fall back on the Windows API. It's > actually a great exercise in what is and isn't possible with Cygwin :) > > In this case I was trying to compute process memory usage from > /proc//statm which gives values in page counts, so I need the > page size (the actual page size) to compute the values in bytes. If /proc//statm is reporting memory in multiples that are not the POSIX _SC_PAGESIZE, that is a bug in the statm file emulation that should be fixed there. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
[PATCH] headers: avoid bareword attributes
Always use the __-decorated form of an attribute name in public headers, as the bareword form is in the user's namespace, and we don't want compilation to break just because the user defines the bareword to mean something else. Signed-off-by: Eric Blake --- winsup/cygwin/include/cygwin/config.h | 2 +- winsup/cygwin/include/cygwin/signal.h | 2 +- winsup/cygwin/include/pthread.h | 4 ++-- winsup/cygwin/include/sys/ucontext.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/winsup/cygwin/include/cygwin/config.h b/winsup/cygwin/include/cygwin/config.h index dad6a350b..aede45f77 100644 --- a/winsup/cygwin/include/cygwin/config.h +++ b/winsup/cygwin/include/cygwin/config.h @@ -41,7 +41,7 @@ extern "C" { #else #include "../tlsoffsets.h" #endif -__attribute__((gnu_inline)) +__attribute__((__gnu_inline__)) extern inline struct _reent *__getreent (void) { register char *ret; diff --git a/winsup/cygwin/include/cygwin/signal.h b/winsup/cygwin/include/cygwin/signal.h index a8c852ddb..630afc817 100644 --- a/winsup/cygwin/include/cygwin/signal.h +++ b/winsup/cygwin/include/cygwin/signal.h @@ -46,7 +46,7 @@ struct _fpstate __uint32_t padding[24]; }; -struct __attribute__ ((aligned (16))) __mcontext +struct __attribute__ ((__aligned__ (16))) __mcontext { __uint64_t p1home; __uint64_t p2home; diff --git a/winsup/cygwin/include/pthread.h b/winsup/cygwin/include/pthread.h index 9e8eb6f2b..6d3bfd0eb 100644 --- a/winsup/cygwin/include/pthread.h +++ b/winsup/cygwin/include/pthread.h @@ -223,8 +223,8 @@ void pthread_testcancel (void); #if __GNU_VISIBLE int pthread_getattr_np (pthread_t, pthread_attr_t *); -int pthread_getname_np (pthread_t, char *, size_t) __attribute__((nonnull(2))); -int pthread_setname_np (pthread_t, const char *) __attribute__((nonnull(2))); +int pthread_getname_np (pthread_t, char *, size_t) __attribute__((__nonnull__(2))); +int pthread_setname_np (pthread_t, const char *) __attribute__((__nonnull__(2))); int pthread_sigqueue (pthread_t *, int, const union sigval); int pthread_yield (void); #endif diff --git a/winsup/cygwin/include/sys/ucontext.h b/winsup/cygwin/include/sys/ucontext.h index 8795476fc..58dc3874a 100644 --- a/winsup/cygwin/include/sys/ucontext.h +++ b/winsup/cygwin/include/sys/ucontext.h @@ -13,7 +13,7 @@ details. */ typedef struct __mcontext mcontext_t; -typedef __attribute__ ((aligned (16))) struct __ucontext { +typedef __attribute__ ((__aligned__ (16))) struct __ucontext { mcontext_t uc_mcontext; struct __ucontext *uc_link; sigset_tuc_sigmask; -- 2.13.5
Re: renameat2
On 08/18/2017 08:21 AM, Ken Brown wrote: > Linux has a system call 'renameat2' which is like renameat but has an > extra 'flags' argument. In particular, one can pass the > RENAME_NOREPLACE flag to cause the rename to fail with EEXIST if the > target of the rename exists. See > > http://man7.org/linux/man-pages/man2/rename.2.html > > macOS has a similar functionality, provided by the function > 'renameatx_np' with the flag RENAME_EXCL. > > > Define the RENAME_* flags in as defined on Linux in > , but support only RENAME_NOREPLACE. > --- > +++ b/winsup/cygwin/include/cygwin/fs.h > @@ -19,4 +19,9 @@ details. */ > #define BLKPBSZGET 0x127b > #define BLKGETSIZE64 0x00041268 > > +/* Flags for renameat2, from /usr/include/linux/fs.h. */ > +#define RENAME_NOREPLACE (1 << 0) > +#define RENAME_EXCHANGE (1 << 1) > +#define RENAME_WHITEOUT (1 << 2) Please only define RENAME_NOREPLACE for now; that way, software can probe what is defined to know what will work (defining a flag that will always be an error is not as useful as leaving it undefined - and while we may add RENAME_EXCHANGE support, I don't see how we can ever do RENAME_WHITEOUT). > + > #endif > diff --git a/winsup/cygwin/include/cygwin/version.h > b/winsup/cygwin/include/cygwin/version.h > index efd4ac017..7640abfad 100644 > --- a/winsup/cygwin/include/cygwin/version.h > +++ b/winsup/cygwin/include/cygwin/version.h > @@ -481,12 +481,14 @@ details. */ >314: Export explicit_bzero. >315: Export pthread_mutex_timedlock. >316: Export pthread_rwlock_timedrdlock, pthread_rwlock_timedwrlock. > + 317: Export renameat2. Add RENAME_NOREPLACE, RENAME_EXCHANGE, > + RENAME_WHITEOUT. This needs tweaks to match. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org signature.asc Description: OpenPGP digital signature
Re: [PATCH] winsup/doc/etc.postinstall.cygwin-doc.sh fix shell variable typo
On 12/20/2017 05:01 PM, Brian Inglis wrote: --- winsup/doc/etc.postinstall.cygwin-doc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winsup/doc/etc.postinstall.cygwin-doc.sh b/winsup/doc/etc.postinstall.cygwin-doc.sh index 2873d9395..935bd94e1 100755 --- a/winsup/doc/etc.postinstall.cygwin-doc.sh +++ b/winsup/doc/etc.postinstall.cygwin-doc.sh @@ -52,7 +52,7 @@ fi # create User Guide and API PDF and HTML shortcuts while read target name desc do - [ -r $t ] && $mks $CYGWINFORALL -P -n "Cygwin/$name" -d "$desc" -- $target + [ -r $target ] && $mks $CYGWINFORALL -P -n "Cygwin/$name" -d "$desc" -- $target Wrong. Needs to be [ -r "$target" ] to be properly quoted. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [PATCH] Cygwin: add secure_getenv
On 2/19/19 10:58 AM, Yaakov Selkowitz wrote: >>> "Secure execution is required if one of the following conditions was >>> true when the program run by the calling process was loaded: [...]" >>> >>> Do we ever have this situation? We don't have any capability to make >>> real and effective user ID different at process startup. But from that >>> description it seems secure_getenv does not trigger secure mode if the >>> process calls seteuid() or setreuid() later in the process. It says it may also be triggered by some Linux security modules (for which I'll assume that can include states that were not present at startup). The main reason it was invented was to ensure that a setgid application CANNOT be negatively impacted by LD_PRELOAD and friends prior to main(), because all of the startup code in the dynamic loader was switched to use secure_getenv() for any place where the loader can normally be influenced by the environment. But the wording sounds vague enough about what other situations may be considered as security that it is easy enough to just state that you should always be prepared for a NULL return when using the function. That said, while it is ideal to avoid squashing to NULL in situations that are not security boundaries (as with your STC displaying HOME even after seteuid() on Linux), I'm also okay if we filter too aggressively (the way gnulib's fallback implementation does when neither __secure_getenv() nor issetugid() available). >> So I wonder if secure_getenv isn't just a synonym for getenv >> in our case. > > Or could it be the STC? glibc's test is a bit more complicated: > > https://sourceware.org/git/?p=glibc.git;a=blob;f=stdlib/tst-secure-getenv.c;hb=HEAD > > And, looking now, FWIW gnulib's implementation is practically similar: > > https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/secure_getenv.c;hb=HEAD Gnulib argued that for native windows, being a synonym for getenv() is okay because you have to opt in to running as administrator, and that there is no native setuid/setgid binaries where you can otherwise gain privileges by influencing the environment presented to a binary. Of course, if Cygwin is able to emulate setgid binaries where native Windows can't, then we need secure_getenv() to reflect that emulation. > > So if there is something wrong with the patch, then AFAIK gnulib is > wrong too. Eric? The patch may be overly strict (returning NULL where it doesn't have to), but that does not make it wrong in my eyes. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH] Cygwin: add secure_getenv
On 2/19/19 11:21 AM, Corinna Vinschen wrote: >> That said, while it is ideal to avoid squashing to NULL in situations >> that are not security boundaries (as with your STC displaying HOME even >> after seteuid() on Linux), I'm also okay if we filter too aggressively >> (the way gnulib's fallback implementation does when neither >> __secure_getenv() nor issetugid() available). > > In fact, gnulib's implementation would chose the > >if (issetugid ()) > return NULL; >return getenv (name); > > branch on Cygwin right now, just as on BSDs. If that's the right thing > to do for BSD, it's not... *really* wrong for Cygwin either, regardless > what Linux is doing. > > That in turn means Yaakov's patch is perfeclty fine since it's equivalent > to the above gnulib code. > > Agreed? Yes. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH] default ps -W process start time to system boot time when inaccessible, 0, -1
On 3/23/19 1:41 PM, Achim Gratz wrote: > Corinna Vinschen writes: >>> replacing one lie with another that is less easy to spot doesn't sound >>> the right thing to do. How about ps if reported "N/A" or something to >>> that effect instead? >> >> 1 Jan 1970 may also be a good hint... > > Well, that was the point: I can deduce just from that date that ps > didn't actually get data for the start time. If it starts replacing > this with the start time of the system instead, it might take a while > for me to see what is going on. On the other hand, the lie is pretty realistic - the program can't have been running longer than your computer has been powered on, and all such affected programs will have the same timestamp. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org signature.asc Description: OpenPGP digital signature
Re: [PATCH v2] Cygwin: rmdir: fail if last component is a symlink, as on Linux
On 9/24/19 12:55 PM, Ken Brown wrote: > If the last component of the directory name is a symlink followed by a > slash, rmdir should fail, even if the symlink resolves to an existing > empty directory. > > mkdir was similarly fixed in 2009 in commit > 52dba6a5c45e8d8ba1e237a15213311dc11d91fb. Modify a comment to clarify > the purpose of that commit. > > Addresses https://cygwin.com/ml/cygwin/2019-09/msg00221.html. > --- > winsup/cygwin/dir.cc | 27 +++ > 1 file changed, 23 insertions(+), 4 deletions(-) > > diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc > index b757851d5..0e0535891 100644 > --- a/winsup/cygwin/dir.cc > +++ b/winsup/cygwin/dir.cc > @@ -305,15 +305,14 @@ mkdir (const char *dir, mode_t mode) > >__try > { > - /* POSIX says mkdir("symlink-to-missing/") should create the > - directory "missing", but Linux rejects it with EEXIST. Copy > - Linux behavior for now. */ > - >if (!*dir) > { > set_errno (ENOENT); > __leave; > } > + /* Following Linux, do not resolve the last component of DIR if > + it is a symlink, even if DIR has a trailing slash. Achieve > + this by stripping trailing slashes or backslashes. */ Maybe even "Following Linux, and intentionally ignoring POSIX, do not..." > + > + /* Following Linux, do not resolve the last component of DIR if > + it is a symlink, even if DIR has a trailing slash. Achieve > + this by stripping trailing slashes or backslashes. */ > + if (isdirsep (dir[strlen (dir) - 1])) > + { > + /* This converts // to /, but since both give ENOTEMPTY, > + we're okay. */ > + char *buf; > + char *p = stpcpy (buf = tp.c_get (), dir) - 1; > + dir = buf; > + while (p > dir && isdirsep (*p)) > + *p-- = '\0'; > + } >if (!(fh = build_fh_name (dir, PC_SYM_NOFOLLOW))) > __leave; /* errno already set */; > Looks okay to me. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org signature.asc Description: OpenPGP digital signature
Re: [PATCH v2] Cygwin: rmdir: fail if last component is a symlink, as on Linux
On 9/24/19 2:28 PM, Ken Brown wrote: >> >> Looks okay to me. > > Thanks. Does the "intentionally ignoring POSIX" part apply to rmdir also? I > didn't find it easy to decipher POSIX. > > Even for mkdir, POSIX says, "If path names a symbolic link, mkdir() shall > fail > and set errno to [EEXIST]." See > https://pubs.opengroup.org/onlinepubs/9699919799/functions/mkdir.html#tag_16_325. > > But I'm not clear on how POSIX decides whether "path names a symbolic link" > in > the case where the last component is a symlink followed by a slash. POSIX says that "/path/to/symlink" names a symlink, but "/path/to/symlink/" (attempts to) name the directory at the contents of the symlink. In mkdir("/path/to/symlink/", if symlink is dangling, then the official result is to create an empty directory at the target of the symlink, so that symlink is no longer dangling. In rmdir("/path/to/symlink/"), if an empty directory exists at that location, the directory must be removed leaving symlink dangling. The POSIX rules are self-consistent and match what Solaris does, but it is surprising action-at-a-distance. Linux kernel developers have repeatedly stated that they are unwilling to implement that behavior, and would much rather have mkdir("/path/to/symlink/") fail with EEXIST (the dangling symlink exists, and we can't create a directory to replace it, nor will we create a directory to make the symlink non-dangling), and similarly rmdir("/path/to/symlink/") fail because symlink is not a directory, even though symlink/ resolves to a directory. So even though we are knowingly violating POSIX, having both functions be consistent with Linux is reasonable. (I still hope that POSIX will relax its stance to allow both Solaris AND Linux behaviors, but that's not going to happen any time soon...) -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org signature.asc Description: OpenPGP digital signature
Re: [PATCH v2 0/3] Support opening a symlink with O_PATH | O_NOFOLLOW
On 1/13/20 10:53 AM, Ken Brown wrote: On 1/13/2020 10:28 AM, Corinna Vinschen wrote: Hi Ken, On Dec 29 17:56, Ken Brown wrote: Currently, opening a symlink with O_NOFOLLOW fails with ELOOP. Following Linux, the first patch in this series allows the call to succeed if O_PATH is also specified. O_PATH (since Linux 2.6.39) Obtain a file descriptor that can be used for two purposes: to indicate a location in the filesystem tree and to perform opera‐ tions that act purely at the file descriptor level. The file itself is not opened, and other file operations (e.g., read(2), write(2), fchmod(2), fchown(2), fgetxattr(2), ioctl(2), mmap(2)) ^ fail with the error EBADF. ^ ^ On BSD systems, you are able to run lchmod to change permissions on a symlink (with effect on who is able to follow that symlink during pathname resolution); Linux does not support that, and POSIX does not mandate support for that, so fchmodat() is allowed to fail on symlinks even while fchownat() is required to work on symlinks. That'd from the current F31 man pages. Am I missing something? Good question. Let me ask in return, did *I* now miss something? I don't think so. I think we agree, although maybe I didn't express myself clearly enough for that to be obvious. What confused me was the following paragraph further down in the open(2) man page (still discussing O_PATH): If pathname is a symbolic link and the O_NOFOLLOW flag is also specified, then the call returns a file descriptor referring to the symbolic link. This file descriptor can be used as the dirfd argument in calls to fchownat(2), fstatat(2), linkat(2), ^^^ and readlinkat(2) with an empty pathname to have the calls operate on the symbolic link. I don't know why they include fchownat here, since the resulting call would fail with EBADF. So I didn't implement that in my patch series. I'm not sure if the question here is about fchownat() (where you CAN change owner of a symlink on Linux, same as with lchown()) or about fchmodat() (where you would attempt to change permissions of a symlink, as on BSD, but where Linux lacks lchmod()). Another wrinkle is that for the longest time, the Linux kernel did not make it possible to correctly implement fchmodat(AT_SYMLINK_NOFOLLOW); it is only with the recent introduction of the fchmodat2() syscall that this has become possible (https://patchwork.kernel.org/patch/9596301/) -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v2 0/3] Support opening a symlink with O_PATH | O_NOFOLLOW
On 1/13/20 11:44 AM, Ken Brown wrote: I don't think so. I think we agree, although maybe I didn't express myself clearly enough for that to be obvious. What confused me was the following paragraph further down in the open(2) man page (still discussing O_PATH): If pathname is a symbolic link and the O_NOFOLLOW flag is also specified, then the call returns a file descriptor referring to the symbolic link. This file descriptor can be used as the dirfd argument in calls to fchownat(2), fstatat(2), linkat(2), ^^^ and readlinkat(2) with an empty pathname to have the calls operate on the symbolic link. I don't know why they include fchownat here, since the resulting call would fail with EBADF. So I didn't implement that in my patch series. I'm not sure if the question here is about fchownat() (where you CAN change owner of a symlink on Linux, same as with lchown()) Yes, the question is about fchownat. Are you saying you can change the owner even if the symlink was opened with O_PATH? Without actually writing a test program on Linux, I'm not sure. Logically, I'd expect that changing the owner of a symlink is a metadata operation that affects the containing directory rather than the contents of the file, but that access to the directory entry is what O_PATH is supposed to provide, and therefore it seems like fchownat() on an empty filename should work the same as lchownat(). But if it fails in Linux, then we don't have to do any better. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Patch: Re: Bug in stat()?
Is this the right list for this patch? I feel like I was writing to /dev/null with the main cygwin list, as no one has responded to this thread. Original Message From: Eric Blake <[EMAIL PROTECTED]> Subject: Patch: Re: Bug in stat()? To: [EMAIL PROTECTED] CC: Eric Blake <[EMAIL PROTECTED]> Eric Blake wrote: > > I am running into weird behavior with stat(). I am getting the same > st_ino number for two distinct directories. When using the jikes > compiler on the GNU Classpath project (the upstream source of libjava in > gcc), jikes is keying off of the inode number to determine where to > write .class files. Because the inode number is a duplicate, jikes is > making the wrong choice, and then failing to compile. > After some poking around, I see that stat() fills in st_ino using a hash function on the absolute file name (since Windows does not understand the concept of inodes). I confirmed that there is a bug in the hashing function - it is not a strong enough hash. The culprit is in winsup/cygwin/path.cc, in hash_path_name(). My updated demonstration follows. Notice that it is sensitive to the directory you run it in; while there are certainly other directories that would show this problem, the bug does not surface in all directories. $ cygpath -aw `pwd` d:\cygwin\home\eblake\cp\lib $ cat blah.java #include #include int main(int argc, char** argv) { /* Print results obtained from cygwin */ struct stat status; int result; result = stat("./java", &status); printf("./java (%d): %x, %x\n", result, status.st_dev, status.st_ino); result = stat("./java/net", &status); printf("net (%d): %x, %x\n", result, status.st_dev, status.st_ino); result = stat("./java/nio", &status); printf("nio (%d): %x, %x\n", result, status.st_dev, status.st_ino); /* morph from "./java" to "./java/net" */ unsigned int hash = 0x210fd907; printf("%x\n", hash); int ch = '\\'; hash += ch + (ch << 17); hash ^= hash >> 2; printf("%x\n", hash); ch = 'n'; hash += ch + (ch << 17); hash ^= hash >> 2; printf("%x\n", hash); ch = 'e'; hash += ch + (ch << 17); hash ^= hash >> 2; printf("%x\n", hash); ch = 't'; hash += ch + (ch << 17); hash ^= hash >> 2; printf("%x\n\n", hash); /* morph from "./java" to "./java/nio" */ hash = 0x210fd907; printf("%x\n", hash); ch = '\\'; hash += ch + (ch << 17); hash ^= hash >> 2; printf("%x\n", hash); ch = 'n'; hash += ch + (ch << 17); hash ^= hash >> 2; printf("%x\n", hash); ch = 'i'; hash += ch + (ch << 17); hash ^= hash >> 2; printf("%x\n", hash); ch = 'o'; hash += ch + (ch << 17); hash ^= hash >> 2; printf("%x\n", hash); return 0; } $ ./blah.exe ./java (0): 1000, 210fd907 net (0): 1000, 20a2ae8b nio (0): 1000, 20a2ae8b 210fd907 29b62f3b 2036a443 29408d82 20a2ae8b 210fd907 29b62f3b 2036a443 294a8d87 20a2ae8b Notice that from the inode hash of ./java, with cwd of d:\cygwin\home\eblake\cp\lib, I was able to match the inode hash of both ./java/net and ./java/nio using the two lines hash += ch + (ch << 17); hash ^= hash >> 2; from path.cc. The two hashes are different after "\\ne" and "\\ni", but converge again when appending 't' and 'o' respectively. I'm not a hashing expert, but I suggest that you try the hashing algorithm used in the Java programming language for java.lang.String.hashCode(), as shown in my patch below. I think it is a stronger hash, and I know that it would solve my problem, with less computation per character. 2002-04-30 Eric Blake <[EMAIL PROTECTED]> * path.cc (hash_path_name): Improve hash function strength. $ diff -u path.cc.bak path.cc --- path.cc.bak Tue Apr 30 16:32:52 2002 +++ path.cc Tue Apr 30 16:40:14 2002 @@ -3136,7 +3136,7 @@ hash = cygheap->cwd.get_hash (); if (name[0] == '.' && name[1] == '\0') return hash; - hash += hash_path_name (hash, "\\"); + hash = (hash << 5) - hash + '\\'; } } @@ -3146,8 +3146,7 @@ do { int ch = cyg_tolower(*name); - hash += ch + (ch << 17); - hash ^= hash >> 2; + hash = (hash << 5) - hash + ch; } while (*++name != '\0' && !(*name == '\\' && (!name[1] || (name[1] == '.' && !name[2]; -- This signature intentionally left boring. Eric Blake [EMAIL PROTECTED] BYU student, free software programmer
Re: patch to allow touch to work on HPFS (and others, maybe??)
Corinna Vinschen redhat.com> writes: > > Hey, why do you give up so quickly? If it's not the one way, it might > be another one. For us unknowing folks which have no OS/2 box with > HPFS to mount, would you mind to run the below application on your NT > box and paste the output into the reply? I'm curious to see the result. If it helps, here's my quick results on a ClearCase drive m:, and a Windows view to a Solaris filesystem on drive u: (I think it is using NFS). $ scan m: rootdir: m:\ Volume Name: Serial Number : 36984713 Max Filenamelength : 255 Filesystemname : Flags: FILE_CASE_SENSITIVE_SEARCH : TRUE FILE_CASE_PRESERVED_NAMES : TRUE FILE_UNICODE_ON_DISK: FALSE FILE_PERSISTENT_ACLS: FALSE FILE_FILE_COMPRESSION : FALSE FILE_VOLUME_QUOTAS : FALSE FILE_SUPPORTS_SPARSE_FILES : FALSE FILE_SUPPORTS_REPARSE_POINTS: FALSE FILE_SUPPORTS_REMOTE_STORAGE: FALSE FILE_VOLUME_IS_COMPRESSED : FALSE FILE_SUPPORTS_OBJECT_IDS: FALSE FILE_SUPPORTS_ENCRYPTION: FALSE FILE_NAMED_STREAMS : FALSE FILE_READ_ONLY_VOLUME : FALSE $ scan u: rootdir: u:\ Volume Name: Serial Number : 316278793 Max Filenamelength : 255 Filesystemname : Flags: FILE_CASE_SENSITIVE_SEARCH : TRUE FILE_CASE_PRESERVED_NAMES : TRUE FILE_UNICODE_ON_DISK: FALSE FILE_PERSISTENT_ACLS: TRUE FILE_FILE_COMPRESSION : FALSE FILE_VOLUME_QUOTAS : FALSE FILE_SUPPORTS_SPARSE_FILES : FALSE FILE_SUPPORTS_REPARSE_POINTS: FALSE FILE_SUPPORTS_REMOTE_STORAGE: FALSE FILE_VOLUME_IS_COMPRESSED : FALSE FILE_SUPPORTS_OBJECT_IDS: FALSE FILE_SUPPORTS_ENCRYPTION: FALSE FILE_NAMED_STREAMS : FALSE FILE_READ_ONLY_VOLUME : FALSE
Re: patch to allow touch to work on HPFS (and others, maybe??)
node: 2778027738457179228 Links: 1 Access: (0755/drwxr-xr-x) Uid: (22382/ eblake) Gid: (10513/Domain Users) Access: 2005-02-10 15:40:19.0 -0700 Modify: 2005-02-10 15:40:19.0 -0700 Change: 2005-02-10 15:40:19.0 -0700 $ rlogin perth # a Solaris box, where my $HOME is the same as u:\ above % df -T . FilesystemType 1K-blocks Used Available Use% Mounted on hirise:/vol/vol2/home/advtech3 nfs83886080 74451144 9434936 89% /home/advtech3 % rm -rf foo bar % touch foo % stat foo File: `foo' Size: 0 Blocks: 0 IO Block: 8192 regular empty file Device: 3e808beh/65538238d Inode: 4348428 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 542/ eblake) Gid: ( 542/ eblake) Access: 2005-02-10 16:12:34.546699000 -0700 Modify: 2005-02-10 16:12:34.546699000 -0700 Change: 2005-02-10 16:12:34.546699000 -0700 % touch foo % stat foo File: `foo' Size: 0 Blocks: 0 IO Block: 8192 regular empty file Device: 3e808beh/65538238d Inode: 4348428 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 542/ eblake) Gid: ( 542/ eblake) Access: 2005-02-10 16:12:39.65271 -0700 Modify: 2005-02-10 16:12:39.65271 -0700 Change: 2005-02-10 16:12:39.65271 -0700 % mkdir bar % stat bar File: `bar' Size: 4096Blocks: 8 IO Block: 8192 directory Device: 3e808beh/65538238d Inode: 4348430 Links: 2 Access: (2775/drwxrwsr-x) Uid: ( 542/ eblake) Gid: ( 542/ eblake) Access: 2005-02-10 16:12:44.773717000 -0700 Modify: 2005-02-10 16:12:44.773717000 -0700 Change: 2005-02-10 16:12:44.773717000 -0700 % touch bar % stat bar File: `bar' Size: 4096Blocks: 8 IO Block: 8192 directory Device: 3e808beh/65538238d Inode: 4348430 Links: 2 Access: (2775/drwxrwsr-x) Uid: ( 542/ eblake) Gid: ( 542/ eblake) Access: 2005-02-10 16:12:49.289725000 -0700 Modify: 2005-02-10 16:12:49.289725000 -0700 Change: 2005-02-10 16:12:49.289725000 -0700 -- Eric Blake
Re: patch to allow touch to work on HPFS (and others, maybe??)
Corinna Vinschen redhat.com> writes: > > That could be a result of the Cygwin internals. I assume that the > CreateFile call requesting any write access fails on both filesystems. > If you have a look into utimes, you see that Cygwin ignores this case: > > h = CreateFile() > if ((h == INVALID_HANDLE_VALUE) > if (win32.isdir ()) > { > /* What we can do with directories more? */ > res = 0; > } > [...] > > Can you add a __seterrno () before the `res = 0;' line and see what > Win32 error is produced by CreateFile (*iff* my assumption is correct)? No error is produced, so it is not the cygwin internals that are failing to touch directory times. Opening a directory on either the ClearCase or the NFS mount point using CreateFile() generates a valid handle, and SetFileTimes returns 0 with GetLastError() returning 0; completely bypassing the win32.isdir () check. As far as I can tell, there is no way to detect that the SetFileTimes is a no-op on directories located in non-NTFS filesystems, short of reading the file times before and after the SetFileTimes call (which is not worth the effort). Besides, detecting that SetFileTimes was a no-op is useless if there is no alternative way to force Windows to set the times on such a directory.
Re: patch to allow touch to work on HPFS (and others, maybe??)
Corinna Vinschen redhat.com> writes: > > I guess trying my approach isn't the worst one, though. We should > use that as a start point for further experimenting, IMHO. I'll check > that in. > Checking win32.has_acls() and using GENERIC_WRITE caused a regression in utimes (). The new upstream automake-1.9.5 tarball contains a read-only file (mode 0444). Before the 20050211 snapshot, when utimes() is still using FILE_WRITE_ATTRIBUTES, tar does just fine at adjusting the timestamp of that file when unpacking to an NFS-mounted directory. However, with the current code, when I tried to unpack, tar is no longer able to touch the timestamps of the read-only file because GENERIC_WRITE requires write access for at least one of user, group, and other, even though touching the timestamp does not. $ tar xjvf automake-1.9.5.tar.bz2 ... automake-1.9.5/m4/amversion.m4 tar: automake-1.9.5/m4/amversion.m4: Cannot utime: Permission denied ... tar: Error exit delayed from previous errors $ echo $? 2
patch for devices.in
Found this when reviewing the change to add /dev/full 2005-02-23 Eric Blake <[EMAIL PROTECTED]> (tiny change) * devices.in (parsedisk): Fix typo. Index: cygwin/devices.in === RCS file: /cvs/src/src/winsup/cygwin/devices.in,v retrieving revision 1.7 diff -u -r1.7 devices.in --- cygwin/devices.in 23 Feb 2005 12:30:31 - 1.7 +++ cygwin/devices.in 23 Feb 2005 17:02:44 - @@ -140,7 +140,7 @@ else { base = DEV_SD1_MAJOR; - drive -= 'q' - 'q'; + drive -= 'q' - 'a'; } parse (base, part + (drive * 16)); }
exceeding PATH_MAX
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 The attached program is a derivative of the configure-time test used in coreutils to see if getcwd is broken. Many systems support relative pathnames whose absolute name is longer than PATH_MAX, and on some of them, getcwd fails in that case. But I understand that cygwin currently treats PATH_MAX as the maximum length of the absolute Windows pathname that corresponds to the POSIX name, whether relative or absolute, since Windows 95 and the ASCII versions of Windows syscalls refuse to work on path names longer than 260 bytes. This means that even with relative paths, it is impossible to creat() or mkdir() a path that would exceed the name limitations of Windows. Therefore, on cygwin, getcwd() currently can't fail on a current working directory longer than PATH_MAX, since it is trivially provable that since such a directory can't be created, it can't be the current working directory; but the configure test was failing to detect that. The problem here is that the test program shows that mkdir is failing with EINVAL (22); when looking at POSIX, http://www.opengroup.org/onlinepubs/009695399/functions/mkdir.html, mkdir is not documented as returning EINVAL, but is allowed to return ENAMETOOLONG (91). Likewise, many other functions are documented as allowing ENAMETOOLONG when the pathname exceeds implementation limitations. Furthermore, if I replace mkdir/errno with CreateDirectory/GetLastError, Windows is returning ERROR_FILENAME_EXCED_RANGE, which is a good candidate for mapping cleanly to ENAMETOOLONG. On NT systems, and using the Unicode versions of Windows syscalls, Windows supports up to 32k for pathnames, with component names up to 255 bytes, by using the \\?\ prefix. Cygwin could actually support the XSI-recommended minimum PATH_MAX of 1024, rather than the POSIX-required minimum of 256, and support it on the Posix name rather than the Windows name as is currently done. That would also let cygwin support relative pathnames whose absolute name is greater than PATH_MAX, up to the 32k limit of the absolute path name, as is done on many other systems. The XSI-recommended NAME_MAX of 255 is a bit problematic - on managed mounts, it is possible for an 85-char POSIX name to occupy 255 Windows characters, but at least that is still greater than the POSIX recommended minimum NAME_MAX of 14. However, changing cygwin to support filenames greater than 260 on systems that support it would be a big patch to cygwin, and I don't have an assignment in place. One other comment - limits.h defines PATH_MAX as 259 (#define PATH_MAX (260 - 1 /*NUL*/)) instead of the Windows API MAX_PATH of 260. But POSIX states that PATH_MAX includes the trailing NUL, so there is no reason for cygwin to short-change the length by a byte. This patch fixes the smaller issues: 2005-03-26 Eric Blake <[EMAIL PROTECTED]> * errno.cc (FILENAME_EXCED_RANGE): Map to ENAMETOOLONG. * include/limits.h (NAME_MAX): New define. (PATH_MAX): POSIX allows PATH_MAX to include trailing NUL. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.0 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCRYQ984KuGfSFAYARAg9PAJ9IBnJU99Mk7dLMMciIt9xSvEwk5gCfaXML snkvzBf+BcDbXS+CG5SFmnk= =OvLe -END PGP SIGNATURE- #include #include #include #include #include #include #include #include #include #ifndef AT_FDCWD # define AT_FDCWD 0 #endif #ifdef ENAMETOOLONG # define is_ENAMETOOLONG(x) ((x) == ENAMETOOLONG) #else # define is_ENAMETOOLONG(x) 0 #endif /* The length of this name must be 8. */ #define DIR_NAME "confdir3" #define DIR_NAME_LEN 8 #define DIR_NAME_SIZE (DIR_NAME_LEN + 1) /* The length of "../". */ #define DOTDOTSLASH_LEN 3 /* Leftover bytes in the buffer, to work around library or OS bugs. */ #define BUF_SLOP 20 int main (void) { char buf[PATH_MAX * (DIR_NAME_SIZE / DOTDOTSLASH_LEN + 1) + DIR_NAME_SIZE + BUF_SLOP]; char *cwd = getcwd (buf, PATH_MAX); size_t initial_cwd_len; size_t cwd_len; int fail = 0; size_t n_chdirs = 0; if (cwd == NULL) exit (1); cwd_len = initial_cwd_len = strlen (cwd); while (1) { size_t dotdot_max = PATH_MAX * (DIR_NAME_SIZE / DOTDOTSLASH_LEN); char *c = NULL; cwd_len += DIR_NAME_SIZE; /* If mkdir or chdir fails, be pessimistic and consider that as a failure, too. */ if (mkdir (DIR_NAME, S_IRWXU) < 0) { printf ("mkdir failed: %d\n", errno); fail = 2; break; } if (chdir (DIR_NAME) < 0) { printf ("chdir failed: %d\n", errno); fail = 2; break; } if (PATH_MAX <= cwd_len && cwd_len < PATH_MAX + DI
Re: exceeding PATH_MAX
Christopher Faylor cygwin.com> writes: > >2005-03-26 Eric Blake byu.net> > > > > * errno.cc (FILENAME_EXCED_RANGE): Map to ENAMETOOLONG. > > This is apparently fixing the symptom rather than the problem. Cygwin > is supposed to be detecting if the name is too long before it gets to > the windows api. Well, cygwin did not detect it, as proved by this portion of the strace from the test program I attached: 66 1661823 [main] getcwd 6048 cwdstuff::get: (C:\cygwin\tmp\getcwd.test\confd ir3\confdir3\confdir3\confdir3\confdir3\confdir3\confdir3\confdir3\confdir3\conf dir3\confdir3\confdir3\confdir3\confdir3\confdir3\confdir3\confdir3\confdir3\con fdir3\confdir3\confdir3\confdir3\confdir3\confdir3) = cwdstuff::get (0x22E280, 2 60, 0, 0), errno 0 129 1661952 [main] getcwd 6048 alloc_sd: uid 22382, gid 10513, attribute 41C0 69 1662021 [main] getcwd 6048 cygpsid::debug_print: alloc_sd: owner SID = S-1 -5-21-2062245864-1860583678-1057817870-12382 64 1662085 [main] getcwd 6048 cygpsid::debug_print: alloc_sd: group SID = S-1 -5-21-2062245864-1860583678-1057817870-513 67 1662152 [main] getcwd 6048 alloc_sd: ACL-Size: 160 172 1662324 [main] getcwd 6048 alloc_sd: Created SD-Size: 236 111 1662435 [main] getcwd 6048 seterrno_from_win_error: /netrel/src/cygwin-1.5 .13-1/winsup/cygwin/dir.cc:262 windows error 206 75 1662510 [main] getcwd 6048 geterrno_from_win_error: windows error 206 == e rrno 22 61 1662571 [main] getcwd 6048 geterrno_from_win_error: windows error 206 == e rrno 22 61 1662632 [main] getcwd 6048 mkdir: -1 = mkdir (confdir3, 448) It looks like the failure comes when the current working directory has length 241, and the program requests a mkdir of an 8 character relative path. mkdir defers to Windows CreateDirectory, which notices that the new directory would have length 250; CreateDirectory is documented with a maximum of 248 (MAX_PATH minus an 8.3 filename), so it returns an error. From there, cygwin is mapping the windows error into EINVAL even though POSIX specifies ENAMETOOLONG. I don't see any reason why this mapping should not be applied, even if you also patch mkdir to error out early rather than calling CreateDirectory.
Re: [Patch]: mkdir -p and network drives
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > Sigh. We need a bash maintainer. > We need to have // working for mkdir -p to work, from what I > understand of the code snippet that was sent to the list. `mkdir -p' only uses chdir(), mkdir(), and stat() calls. For //server/share/newdir, the strace sequence would be (with Paul Eggert's patch): chdir("//") - success mkdir("server") - fail (hopefully EEXIST, but don't give up yet) stat("server") - success (and S_ISDIR better be true) chdir("server") - success mkdir("share") - fail (again, hopefully with EEXIST) stat("share") - success (and S_ISDIR is true) chdir("share") - success mkdir("newdir") - success It is the stat calls where the decision is made whether the mkdir failed because the directory was already there vs. couldn't be created, done in that order to avoid races. I intend on releasing coreutils-5.3.0-6 as soon as a snapshot has your minimal working //server as a directory, such that the above strace works. As to the accessibility of // and //server, your first cut should make them mode 444 (dr--r--r--) for now. That way, you do not have to support readdir() (which only makes sense if you have search permssion), but you do support pathname resolution, and forbid adding or deleting servers or shares as though they were files. If readdir() is added (and bash patched, obviously), then change the accessibility to 555. Also, what should //.. resolve to, / or //? And if it resolves to /, should // be an entry in the readdir() of /? I would argue that //.. should resolve to //, meaning we just have two distinct roots in the directory tree. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.0 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCe++r84KuGfSFAYARAo7fAJ97YdifZyUBImxFNpTCOZ60UC+9wACgw76U PSjw9LYS5eelqE1FdnKuU5Y= =D774 -END PGP SIGNATURE-
Re: [Patch]: mkdir -p and network drives
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > I thought that Eric Blake implied that // *had* to be translated to /, > as per POSIX. I wonder how many programs out there translate a > standalone '//' to '/'. No, POSIX requires that / be untouched, // be implementation-defined (hint - - define it on cygwin to stay untouched), and /// translate to /. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.0 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCe+/S84KuGfSFAYARAhb2AKCgqcwkbuXxzLrb2lbrfNk7va3ekgCgkl5U xCilioyN45W4FmvOYEc0Yno= =D3xl -END PGP SIGNATURE-
Re: [Patch]: mkdir -p and network drives
Pierre A. Humblet phumblet.no-ip.org> writes: > > Here is a patch to allow mkdir -p to easily work with network > drives and to allow future enumeration of computers and of > network drives by ls -l. > > It works by defining a new FH_NETDRIVE virtual handler for > names such as // and //machine. > This also makes chdir work without additional change. I've just downloaded the 20050508 snapshot to play with this, and it still needs some work before coreutils-5.3.0-6 can be released. But it is an improvement! First, `ls -ld // //machine' show that these directories are mode 111 (searchable, but not readable). Yet opendir("//") and opendir("//machine") succeed, although POSIX requires that opendir(2) fail with EACCESS if the directory to be opened is not readable. Second, the sequence chdir("//"), mkdir("machine") creates machine in the current directory. $ cd //eblake/share $ ls $ ~/coreutils-cvs/src/mkdir -p //eblake/share/dir $ ls -F dir/ eblake/ share/ A relevant portion of the strace is included below. Basically, mkdir ("//machine") (or chdir("//"), mkdir("machine")) needs to fail with EEXIST (because it is always assumed that //machine already exists) or with EACCESS (because there is no write access in //), rather than create a directory by that name somewhere else. 69 4745479 [main] mkdir 10204 chdir: dir '//' 62 4745541 [main] mkdir 10204 normalize_posix_path: src // 66 4745607 [main] mkdir 10204 normalize_posix_path: // = normalize_posix_path (//) 62 4745669 [main] mkdir 10204 mount_info::conv_to_win32_path: conv_to_win32_p ath (//) 61 4745730 [main] mkdir 10204 set_flags: flags: binary (0x2) 74 4745804 [main] mkdir 10204 mount_info::conv_to_win32_path: src_path //, ds t \\, flags 0x2, rc 0 77 4745881 [main] mkdir 10204 build_fh_pc: fh 0x61831710 67 4745948 [main] mkdir 10204 chdir: 0 = chdir() cygheap->cwd.posix '//' nati ve '\\' 67 4746015 [main] mkdir 10204 normalize_posix_path: src eblake 61 4746076 [main] mkdir 10204 cwdstuff::get: posix // 60 4746136 [main] mkdir 10204 cwdstuff::get: (//) = cwdstuff::get (0x22EAC0, 260, 1, 0), errno 2 132 4746268 [main] mkdir 10204 normalize_posix_path: //eblake = normalize_posi x_path (eblake) 67 4746335 [main] mkdir 10204 mount_info::conv_to_win32_path: conv_to_win32_p ath (//eblake) 67 4746402 [main] mkdir 10204 set_flags: flags: binary (0x2) 61 4746463 [main] mkdir 10204 mount_info::conv_to_win32_path: src_path //ebla ke, dst \\eblake, flags 0x2, rc 0 64 4746527 [main] mkdir 10204 build_fh_pc: fh 0x61831710 68 4746595 [main] mkdir 10204 cwdstuff::get: posix // 72 4746667 [main] mkdir 10204 cwdstuff::get: (\\) = cwdstuff::get (0x22E4E0, 260, 0, 0), errno 2 1561 4748228 [main] mkdir 10204 mkdir: 0 = mkdir (eblake, 511)
Re: [Patch]: mkdir -p and network drives
> I added read-only filesystem checking to path_conv::check so the latest > snapshot seems to work fine with the latest coreutils (trixie is a > system in my home network which exports shares): Almost. With the 20050513 snapshot and coreutils-5.3.0-6, I am still getting: $ cd //eblake/share $ ls $ mkdir //eblake/share/dir $ ls dir share So you solved the mkdir("//server"), but not the mkdir("//server/share"), from creating a subdirectory in the most recent non-virtual current directory. > The "rmdir //" should really say "directory not empty" but that's a fix > for another day. Why change it? POSIX specifies EROFS if the directory to be removed is on a read-only filesystem, which sounds like the right error for rmdir("//") to me. -- Eric Blake
Re: [Patch]: mkdir -p and network drives
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Wrong list. Redirecting. According to Vance Turner on 5/18/2005 11:06 PM: > I usually don't write you guys, I follow the thread to see how development > is going. > > Just a note. The ls command is't quite right. > > Ls -lRC wil not recursively list the files and directories in verbose mode. > The l flag seems to be ignored. Per POSIX, http://www.opengroup.org/onlinepubs/009695399/utilities/ls.html, -C and -l are mutually exclusive, and the last one specified wins. You are right that the -l flag is ignored in your example, but it is not a bug. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.0 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCjIVH84KuGfSFAYARAs53AJ9yVbtYsTOixPy09xEmMoJnA4InDQCg2XqZ UVT2dXJWEg5kLgrnZ22cqm4= =b5ty -END PGP SIGNATURE-
bug in stdint.h
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Found a typo in /usr/include/stdint.h: 2005-05-23 Eric Blake <[EMAIL PROTECTED]> * include/stdint.h (INTMAX_C, UINTMAX_C): Fix definition. Index: include/stdint.h === RCS file: /cvs/src/src/winsup/cygwin/include/stdint.h,v retrieving revision 1.5 diff -u -p -r1.5 stdint.h - --- include/stdint.h29 Oct 2003 08:43:10 - 1.5 +++ include/stdint.h23 May 2005 11:58:49 - @@ -176,7 +176,7 @@ typedef unsigned long long uintmax_t; /* Macros for greatest-width integer constant expressions */ - -#define INTMAX_C(x) x ## L - -#define UINTMAX_C(x) x ## UL +#define INTMAX_C(x) x ## LL +#define UINTMAX_C(x) x ## ULL #endif /* _STDINT_H */ - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.0 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCkcWm84KuGfSFAYARAkouAJ92IO6+m9chFepjeWBOFSwVgOvx+ACgr5z4 7h8RS3a0K2PdAgP4OUfj4Tk= =rZ9K -END PGP SIGNATURE-
question on limits.h
My reading of POSIX says that LLONG_MIN and friends must always be defined, and not just when the version of C is new enough: http://www.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html At any rate, I was surprised when I noticed that coreutils was redefining ULLONG_MAX because it couldn't find it in limits.h. 2005-05-27 Eric Blake <[EMAIL PROTECTED]> (LLONG_MIN, LLONG_MAX, ULLONG_MAX): Always define. Index: cygwin/include/limits.h === RCS file: /cvs/src/src/winsup/cygwin/include/limits.h,v retrieving revision 1.15 diff -u -r1.15 limits.h --- cygwin/include/limits.h 19 May 2005 19:45:28 - 1.15 +++ cygwin/include/limits.h 27 May 2005 14:15:47 - @@ -107,7 +107,6 @@ #define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1) #endif -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* Minimum and maximum values a `signed long long int' can hold. */ #undef LLONG_MIN #define LLONG_MIN (-LLONG_MAX-1) @@ -117,7 +116,6 @@ /* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */ #undef ULLONG_MAX #define ULLONG_MAX (LLONG_MAX * 2ULL + 1) -#endif /* Maximum number of iovcnt in a writev (an arbitrary number) */ #undef IOV_MAX
cygcheck exit status
As mentioned on cygwin (hopefully I'm not falling afoul of trivial patch size, since I don't have assignment; and hopefully gmane didn't kill this): 2005-07-05 Eric Blake <[EMAIL PROTECTED]> * cygcheck.cc (track_down, cygcheck): Return true on success. (main): Reflect cygcheck failures in exit status. Index: winsup/utils/cygcheck.cc === RCS file: /cvs/src/src/winsup/utils/cygcheck.cc,v retrieving revision 1.74 diff -u -b -p -r1.74 cygcheck.cc --- winsup/utils/cygcheck.cc30 May 2005 15:49:31 - 1.74 +++ winsup/utils/cygcheck.cc5 Jul 2005 20:46:38 - @@ -364,7 +364,7 @@ struct ImpDirectory }; -static void track_down (char *file, char *suffix, int lvl); +static bool track_down (char *file, char *suffix, int lvl); #define CYGPREFIX (sizeof ("%%% Cygwin ") - 1) static void @@ -554,26 +554,27 @@ dll_info (const char *path, HANDLE fh, i cygwin_info (fh); } -static void +// Return true on success, false if error printed +static bool track_down (char *file, char *suffix, int lvl) { if (file == NULL) { display_error ("track_down: NULL passed for file", true, false); - return; + return false; } if (suffix == NULL) { display_error ("track_down: NULL passed for suffix", false, false); - return; + return false; } char *path = find_on_path (file, suffix, 0, 1); if (!path) { printf ("Error: could not find %s\n", file); - return; + return false; } Did *d = already_did (file); @@ -589,7 +590,7 @@ track_down (char *file, char *suffix, in printf ("%s", path); printf (" (recursive)\n"); } - return; + return true; case DID_INACTIVE: if (verbose) { @@ -598,7 +599,7 @@ track_down (char *file, char *suffix, in printf ("%s", path); printf (" (already done)\n"); } - return; + return true; default: break; } @@ -609,7 +610,7 @@ track_down (char *file, char *suffix, in if (!path) { printf ("%s not found\n", file); - return; + return false; } printf ("%s", path); @@ -620,7 +621,7 @@ track_down (char *file, char *suffix, in if (fh == INVALID_HANDLE_VALUE) { printf (" - Cannot open\n"); - return; + return false; } d->state = DID_ACTIVE; @@ -629,6 +630,7 @@ track_down (char *file, char *suffix, in d->state = DID_INACTIVE; if (!CloseHandle (fh)) display_error ("track_down: CloseHandle()"); + return true; } static void @@ -653,14 +655,15 @@ ls (char *f) display_error ("ls: CloseHandle()"); } -static void +// Return true on success, false if error printed +static bool cygcheck (char *app) { char *papp = find_on_path (app, (char *) ".exe", 1, 0); if (!papp) { printf ("Error: could not find %s\n", app); - return; + return false; } char *s = strdup (papp); char *sl = 0, *t; @@ -675,7 +678,7 @@ cygcheck (char *app) paths[0] = s; } did = 0; - track_down (papp, (char *) ".exe", 0); + return track_down (papp, (char *) ".exe", 0); } @@ -1590,6 +1593,7 @@ int main (int argc, char **argv) { int i; + bool ok = true; load_cygwin (argc, argv); (void) putenv("POSIXLY_CORRECT=1"); @@ -1677,7 +1681,7 @@ main (int argc, char **argv) { if (i) puts (""); - cygcheck (argv[i]); + ok &= cygcheck (argv[i]); } if (sysinfo) @@ -1693,5 +1697,5 @@ main (int argc, char **argv) puts ("Use -h to see help about each section"); } - return 0; + return ok ? EXIT_SUCCESS : EXIT_FAILURE; }
Re: cygcheck exit status
Christopher Faylor cygwin.com> writes: > > On Tue, Jul 05, 2005 at 08:49:06PM +0000, Eric Blake wrote: > > -1677,7 +1681,7 main (int argc, char **argv) > > { > >if (i) > > puts (""); > >- cygcheck (argv[i]); > >+ ok &= cygcheck (argv[i]); > > Why are you anding the result here? Why not just set ok = cygcheck (...)? Because it's in a for loop, and when the first file fails but second succeeds, you still want the overall command to exit with failure.
Re: cygcheck exit status
Igor Pechtchanski cs.nyu.edu> writes: > > Because it's in a for loop, and when the first file fails but second > > succeeds, you still want the overall command to exit with failure. > > That's the correct intent, but shouldn't it be &&= instead of &=, > technically? There's no such thing as &&=. And even if there was, you wouldn't want to use it, because it would short-circuit running cygcheck(). The whole point of the boolean collector is to run the test on every file, but to remember if any of the tests failed. Maybe thinking of a short-circuit in the reverse direction will help you understand: ok = cygcheck (argv[i]) && ok; But since ok is a simple boolean, short-circuiting doesn't save us any side effects, so we can use: ok = cygcheck (argv[i]) & ok; And since & is commutative, it has the same outcome as: ok = ok & cygcheck (argv[i]); Hence my shorthand (coreutils uses this idiom a lot, too): ok &= cygcheck (argv[i]); [By deMorgan's law, I could have also reversed the sense of the collector: bool failed = false; for (int i; ...) failed |= test_that_returns_true_on_failure(); return failed ? EXIT_FAILURE : EXIT_SUCCESS; But I hate thinking in negative logic, hence my definition of cygcheck to return true on success.] -- Eric Blake
cygcheck .exe magic
I was annoyed that "cygcheck bash" worked but "cygcheck /bin/bash" did not. 2005-07-19 Eric Blake <[EMAIL PROTECTED]> * cygcheck.cc (find_on_path): Perform .exe magic on non-PATH search. -- Eric Blake Index: winsup/utils/cygcheck.cc === RCS file: /cvs/src/src/winsup/utils/cygcheck.cc,v retrieving revision 1.75 diff -p -r1.75 cygcheck.cc *** winsup/utils/cygcheck.cc5 Jul 2005 21:41:37 - 1.75 --- winsup/utils/cygcheck.cc19 Jul 2005 19:24:27 - *** *** 12,17 --- 12,18 #include #include #include + #include #include #include #include *** find_on_path (char *file, char *default_ *** 218,224 } if (strchr (file, ':') || strchr (file, '\\') || strchr (file, '/')) ! return cygpath (file, NULL); if (strchr (file, '.')) default_extension = (char *) ""; --- 219,237 } if (strchr (file, ':') || strchr (file, '\\') || strchr (file, '/')) ! { ! struct stat stshort, stlong; ! char *shortname = cygpath (file, NULL); ! strcat (strcpy (tmp, shortname), default_extension); ! /* if short name doesn't exist, or if short name and extension name are ! same file, append the extension */ ! if (stat (shortname, &stshort) ! || (! stat (tmp, &stlong) && stshort.st_ino == stlong.st_ino)) ! strcpy (rv, tmp); ! else ! strcpy (rv, shortname); ! return rv; ! } if (strchr (file, '.')) default_extension = (char *) "";
Re: cygcheck .exe magic
Christopher Faylor cygwin.com> writes: > > Are you sure this is right? cygcheck.exe isn't a cygwin program so I'd wonder > about the use of the inodes returned from windows stat() call. > You have a point; revised patch attached. The original worked for me in testing, but only because I was short-circuiting when the first stat failed, and appending the .exe happened to be the right thing to do. Since this is not a cygwin app, there is no .exe magic in stat() to counteract, and all we really need to do is see if appending the suffix makes stat succeed. 2005-07-19 Eric Blake byu.net> * cygcheck.cc (find_on_path): Perform .exe magic on non-PATH search. Index: winsup/utils/cygcheck.cc === RCS file: /cvs/src/src/winsup/utils/cygcheck.cc,v retrieving revision 1.75 diff -p -r1.75 cygcheck.cc *** winsup/utils/cygcheck.cc5 Jul 2005 21:41:37 - 1.75 --- winsup/utils/cygcheck.cc19 Jul 2005 19:24:27 - *** *** 12,17 --- 12,18 #include #include #include + #include #include #include #include *** find_on_path (char *file, char *default_ *** 218,224 } if (strchr (file, ':') || strchr (file, '\\') || strchr (file, '/')) ! return cygpath (file, NULL); if (strchr (file, '.')) default_extension = (char *) ""; --- 219,235 } if (strchr (file, ':') || strchr (file, '\\') || strchr (file, '/')) ! { ! struct stat stshort, stlong; ! char *shortname = cygpath (file, NULL); ! strcat (strcpy (tmp, shortname), default_extension); ! /* Check if extension makes a difference. */ ! if (stat (shortname, &stshort) && ! stat (tmp, &stlong)) ! strcpy (rv, tmp); ! else ! strcpy (rv, shortname); ! return rv; ! } if (strchr (file, '.')) default_extension = (char *) "";
Re: Problem with sh/bash and snapshot cygwin1-20050825.dll
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 >> While you're at it, fix realpath(NULL, buf) to set buf[0]='\0', instead of >> leaving garbage there. > >http://cygwin.com/acronyms/#PTC Also, strdup() is faster than malloc()/strcpy(), since it calculates the path length only once instead of twice. >> Also, realpath("//..", buf) should be "//", not "/", since it is its own >> root (there is no way to make // a subdirectory of /). And when pwd is >> //, realpath("..", buf) is correctly "//", but realpath("../..", buf) is >> mistakenly "/". > >http://cygwin.com/acronyms/#PTC Unfortunately, I don't have copyright assignment (I've tried convincing my employer; I'll try again), and this would push me over my current contribution limits. 2005-08-26 Eric Blake <[EMAIL PROTECTED]> * path.cc (realpath): Truncate resolved when path is NULL. Use strdup when resolved is NULL. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDDxRe84KuGfSFAYARAnXaAJ0b9xkB+hhmp9GQk0S52vSlzbtqkwCdGlfE wjGOq/B2Iv2JyJ2HA81HZIc= =EXXF -END PGP SIGNATURE- Index: path.cc === RCS file: /cvs/src/src/winsup/cygwin/path.cc,v retrieving revision 1.388 diff -u -p -b -r1.388 path.cc --- path.cc 25 Aug 2005 21:18:26 - 1.388 +++ path.cc 26 Aug 2005 13:07:29 - @@ -50,6 +50,7 @@ details. */ #include "winsup.h" #include #include +#include #include #include #include @@ -3657,6 +3658,8 @@ realpath (const char *path, char *resolv /* Make sure the right errno is returned if path is NULL. */ if (!path) { + if (resolved) + resolved[0] = '\0'; set_errno (EINVAL); return NULL; } @@ -3677,11 +3680,7 @@ realpath (const char *path, char *resolv if (!real_path.error && real_path.exists ()) { if (!resolved) - { - resolved = (char *) malloc (strlen (real_path.normalized_path) + 1); - if (!resolved) - return NULL; -} + return strdup (real_path.normalized_path); return strcpy (resolved, real_path.normalized_path); }
fix ARG_MAX
Even though cygexec mountpoints can have a larger argument space, we might as well make ARG_MAX and sysconf(_SC_ARG_MAX) work correctly in the common case of non-cygexec mountpoints. POSIX defines ARG_MAX as the max number of bytes to an exec*() call, including the environment, and requires a minimum of 4k. This patch is slightly conservative, since the CreateProcess limitation of 32k does not include the environment, but any bigger number would be problemetic. This was discovered by the recent breakage in xargs 4.2.25-1, where 1M was too big. For further justification of this patch, see the thread at http://lists.gnu.org/archive/html/bug-findutils/2005-09/msg00039.html 2005-09-06 Eric Blake <[EMAIL PROTECTED]> * include/limits.h (ARG_MAX): New limit. * sysconf.cc (sysconf): _SC_ARG_MAX: Use it. Index: sysconf.cc === RCS file: /cvs/src/src/winsup/cygwin/sysconf.cc,v retrieving revision 1.40 diff -u -r1.40 sysconf.cc --- sysconf.cc 13 Apr 2005 16:41:33 - 1.40 +++ sysconf.cc 6 Sep 2005 15:32:41 - @@ -1,6 +1,6 @@ /* sysconf.cc - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc. + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc. This file is part of Cygwin. @@ -30,8 +30,10 @@ switch (in) { case _SC_ARG_MAX: - /* FIXME: what's the right value? _POSIX_ARG_MAX is only 4K */ - return 1048576; +/* Actually, for cygexec-mounted executables, it is much larger, but + as this is sysconf and not pathconf, we have no way to express + that larger limit. Stick with a value that is always safe. */ + return ARG_MAX; case _SC_OPEN_MAX: { long max = getdtablesize (); Index: include/limits.h === RCS file: /cvs/src/src/winsup/cygwin/include/limits.h,v retrieving revision 1.16 diff -u -r1.16 limits.h --- include/limits.h29 May 2005 10:05:56 - 1.16 +++ include/limits.h6 Sep 2005 15:32:41 - @@ -146,6 +146,14 @@ #undef OPEN_MAX #define OPEN_MAX 256 +/* Maximum # of bytes for arguments to exec functions, including environment. + Actually, the environment is not a limitation here, and executables that + live on cygexec mount points have a larger limit, but this is a reasonable + limit, also returned by sysconf(_SC_ARG_MAX), that covers Window's + CreateProcess limit. */ +#undef ARG_MAX +#define ARG_MAX (32 * 1024) + /* # of bytes in a pipe buf. This is the max # of bytes which can be written to a pipe in one atomic operation. */ #undef PIPE_BUF
PING: fix ARG_MAX
Eric Blake byu.net> writes: Just making sure this patch didn't fall through the cracks... > > 2005-09-06 Eric Blake byu.net> > > * include/limits.h (ARG_MAX): New limit. > * sysconf.cc (sysconf): _SC_ARG_MAX: Use it. Even with your recent patches to make cygwin programs receive longer command lines, whether or not they are not mounted cygexec, ARG_MAX should still reflect the worst case limit so that programs (like xargs) that use ARG_MAX will work reliably even when invoking non-cygwin programs that are really bound by the 32k limit. Maybe it is worth adding _PC_ARG_MAX as an extension to the standards for pathconf(), so that programs that are aware of cygwin's dependence on the path being executed determining the length of the max command line can use pathconf() instead of sysconf() to obtain a more accurate limit. Something like this: sysconf(_SC_ARG_MAX) --> 32k pathconf("notepad", _PC_ARG_MAX) --> 32k (performs PATH search if /, \ not in filename) pathconf("/bin/echo", _PC_ARG_MAX) --> 8M (or whatever limit can be determined) pathconf("nonesuch", _PC_ARG_MAX) --> -1, errno = ENOENT Then xargs could use this non-standard extension to allow larger command lines when the target utility is a known cygwin executable, rather than penalizing all cygwin programs to the safe 32k limit of ARG_MAX.
Re: PING: fix ARG_MAX
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Corinna Vinschen on 9/12/2005 9:22 AM: >>Even with your recent patches to make cygwin programs receive longer command >>lines, whether or not they are not mounted cygexec, ARG_MAX should still >>reflect >>the worst case limit so that programs (like xargs) that use ARG_MAX will work >>reliably even when invoking non-cygwin programs that are really bound by the >>32k >>limit. > > > I had a short talk with Chris and we both agree that it doesn't make > overly sense to go down to the lowest limit just to accomodate > non-Cygwin applications. Users of those apps can easily use xargs -s > so why penalize Cygwin apps? Well, for now, xargs in findutils-4.2.25-2 is already hardcoded to 32k max; attempting to use -s to get a larger value will fail, because of the POSIX rules placed on xargs. If, on the other hand, cygwin added pathconf(_PC_ARG_MAX) as a legal extension to POSIX, then xargs could use its preferred 128k default when calling cygwin apps, while using 32k for windows apps without even requiring users to supply -s; not to mention the fact that -s could then be used to obtain larger command lines than even the default 128k for cygwin apps. With that extension in place, sysconf(_SC_ARG_MAX) at 32k is not much of a limit for applications that know about cygwin's extension. Also, the argument brought up on the findutils mailing list was that beyond a certain size, the cost of processing each argument starts to outweigh the benefits of forking fewer tasks, to the point that the difference between a 32k ARG_MAX vs. a 1M ARG_MAX falls in the noise when the same amount of data is divided by xargs to as few runs as possible, so a 32k limit is not really penalizing cygwin apps. But since I have not provided a patch for pathconf(_PC_ARG_MAX), and I do not have copyright assignment, I will be understanding if 1.5.19 is released with _SC_ARG_MAX still broken in the corner cases. Just be aware that xargs will remain at its hardcoded 32k limit unless it can find a way to query cygwin whether a particular executable can be given a larger limit. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDJlES84KuGfSFAYARAu75AJ4r3Zd2U/eFTMzod39mpNn0M8aQigCgySob xk7QutMPTnN3wh/zUMnSMHM= =sw7M -END PGP SIGNATURE-
Re: PING: fix ARG_MAX
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Christopher Faylor on 9/19/2005 8:31 AM: > If this is really true, then the findutils configury should be > attempting some kind of timing which finds that magic point where it > should be ignoring _SC_ARG_MAX. It shouldn't be vaguely assuming that > it is in its best interests to ignore it because someone thinks that the > cost of processing each argument outweighs the benefits of forking fewer > tests. POSIX allows xargs to have a default size (currently, xargs defaults to 128k unless otherwise constrained by _SC_ARG_MAX), and that -s can change that size to anything within the range permitted by _SC_ARG_MAX. > > Given that cost of forking is much more expensive on cygwin than on > other systems I really don't see how you can use this argument anyway > and, IMO, it doesn't make much sense on standard UNIX either. If you > create more processes via fork you are invoking the OS and incurring > context switches. You're still processing the same number of arguments > but you're just going to the OS to handle them more often. I don't see > how that's ever a win. In isolation, no. But it is what else you are doing with the arguments - the text processing of xargs to parse it into chunks, and the invoked utility's processing of its argv, that also consumes time. Also, lots of data tends to imply more page faults, which can be as expensive as context switches anyways. > > I'm willing to be proven wrong by hard data but I think that you and the > findutils mailing list shouldn't be making assumptions without data to > back them up. Did you not read the thread on bug-findutils? Bob Proulx proposed a test that shows that there is NO MEASURABLE DIFFERENCE between a simple xargs beyond a certain -s: http://lists.gnu.org/archive/html/bug-findutils/2005-09/msg00038.html Then I repeated the test on cygwin, and found similar results: http://lists.gnu.org/archive/html/bug-findutils/2005-09/msg00039.html There comes a point, where even when all xargs is doing is invoking echo, that the cost of passing that much information through pipes does overtake the cost of forks. However, I am also keen on providing a more reasonable -s behavior in xargs. If cygwin were to have pathconf(filename, _PC_ARG_MAX), where a PATH search were done when filename does not contain '/', then pathconf could return 32k on Windows processes, and unlimited (or an actual known limit) for cygwin processes, so that xargs can then allow unlimited -s sizes for cygwin processes but cap windows processes at 32k and never encounter the E2BIG. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDMAPo84KuGfSFAYARAry+AKCrEPEhqsTIQwWKrLpNA2M1qC/dFACeLz9k aPTSZXTkUZCHUkoDNIiPdxA= =zS83 -END PGP SIGNATURE-
Re: PING: fix ARG_MAX
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Christopher Faylor on 9/20/2005 10:05 AM: > AFAICT, we're not talking about defaults. We're talking about the > optimum setting. > > Your change to xargs doesn't permit me to go beyond 32K. Personally, > I'd like to be able to override that. So would I. See below. > > I have a similar test which shows noticeable improvement when going from > 32K to 64K and miniscule-but-still-there improvements after that: Was this benchmark run on a modified xargs, or did you still suffer from the 32k limit? xargs truncates the -s arg down to what it is told is the system limit; use the undocumented xargs --show-limits to prove that you are getting the buffer size you are requesting. > > I am not really interested in providing a non-standard interface which > would ultimately end up being used just by xargs. That would mean that > we're adding an interface to cygwin so that a UNIX program could work > better with non-cygwin programs. I think I've been pretty consistent in > stating that I want to encumber cygwin as little as possible when it > comes to accommodating non-cygwin programs. POSIX allows extensions to sysconf and pathconf for a reason, but I can understand if you are reluctant to add _PC_ARG_MAX. > > If you want to keep the 32K limit, that's ok with me. I'd just ask that > you make it possible to override it. My current findutils release just bypasses the _SC_ARG_MAX check altogether with a hard-coded 32k upper limit to -s, without touching the code that defaults to 128k (since xargs automatically trims its default down to the results of its _SC_ARG_MAX check as needed). But my next release of findutils, after cygwin 1.5.19 is out (where all cygwin processes and not just cygexec mount points get the larger cygwin arg limits), will change the default from 128k to 32k, but use the normal _SC_ARG_MAX as the upper limit of -s. So maybe instead of having _SC_ARG_MAX return 1 meg, you should make it even larger, since cygwin processes really can pass more than 1 meg. > > But, then, I suspect that this wasn't overrideable when I was providing > xargs either so you can feel free to ignore my request. Correct, your earlier releases of xargs could not exceed your hardcoded ARG_MAX limitation either. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDMV8X84KuGfSFAYARAjH3AJsFVfYmqzWBcqQyYNYYdwfRQjnykACeMzvB GX41apLMG8QW9NyjslbhRjo= =22kM -END PGP SIGNATURE-
Re: d_ino deprecated in latest snapshot
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Christopher Faylor on 12/10/2005 4:25 PM: > > I'll make the change but have you completely given up on the concept of > "a patch" now? It seems like you could have tested this pretty easily > by just making changes to the header and then rectified the behavior > by submitting a patch. 2005-12-10 Eric Blake <[EMAIL PROTECTED]> * include/sys/dirent.h (struct dirent): Deprecate d_ino member. Index: cygwin/include/sys/dirent.h === RCS file: /cvs/src/src/winsup/cygwin/include/sys/dirent.h,v retrieving revision 1.8 diff -u -p -r1.8 dirent.h - --- cygwin/include/sys/dirent.h 5 Dec 2005 21:02:53 - 1.8 +++ cygwin/include/sys/dirent.h 10 Dec 2005 23:31:00 - @@ -1,6 +1,6 @@ /* Posix dirent.h for WIN32. - - Copyright 2001, 2002, 2003 Red Hat, Inc. + Copyright 2001, 2002, 2003, 2005 Red Hat, Inc. This software is a copyrighted work licensed under the terms of the Cygwin license. Please consult the file "CYGWIN_LICENSE" for @@ -31,7 +31,7 @@ struct dirent struct dirent { long d_version; - - ino_t d_ino; + ino_t __deprecated_d_ino; long d_fd; unsigned long __ino32; char d_name[256]; @@ -42,7 +42,7 @@ struct dirent long d_version; long d_reserved[2]; long d_fd; - - ino_t d_ino; + ino_t __deprecated_d_ino; char d_name[256]; }; #endif - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDm2Us84KuGfSFAYARArN0AJkBIjV9Bfa8SKIaPWua3vNg5zjkyACfbnIl 92NVWgVHnwItXoEHjCHq71M= =uozg -END PGP SIGNATURE-
Fix readdir version 2
2006-01-03 Eric Blake <[EMAIL PROTECTED]> * dir.cc (readdir_worker): Update saw_dot* flags in version 2. Index: cygwin/dir.cc === RCS file: /cvs/src/src/winsup/cygwin/dir.cc,v retrieving revision 1.99 diff -u -r1.99 dir.cc --- cygwin/dir.cc 19 Dec 2005 04:00:41 - 1.99 +++ cygwin/dir.cc 3 Jan 2006 15:29:32 - @@ -1,6 +1,6 @@ /* dir.cc: Posix directory-related routines - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2006 Red Hat, Inc. This file is part of Cygwin. @@ -105,6 +105,13 @@ { de->__invalid_d_ino = 0; de->__ino32 = 0; + if (de->d_name[0] == '.') + { + if (de->d_name[1] == '\0') + dir->__flags |= dirent_saw_dot; +else if (de->d_name[1] == '.' && de->d_name[2] == '\0') + dir->__flags |= dirent_saw_dot_dot; + } } else {
managed mounts and "
I found it annoying that managed mounts can handle non-printing characters, but not several of the remaining Windows' forbidden characters, such as double quotes. $ cd managed $ touch `printf '\a'` $ touch `printf '"'` touch: cannot touch `"': No such file or directory 2006-01-04 Eric Blake <[EMAIL PROTECTED]> * path.cc (dot_special_chars): Add ", <, >, and |. Index: path.cc === RCS file: /cvs/src/src/winsup/cygwin/path.cc,v retrieving revision 1.398 diff -u -r1.398 path.cc --- path.cc 27 Dec 2005 18:10:49 - 1.398 +++ path.cc 4 Jan 2006 15:58:41 - @@ -1,6 +1,6 @@ /* path.cc: path support. - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc. + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc. This file is part of Cygwin. @@ -1331,6 +1331,7 @@ "\021" "\022" "\023" "\024" "\025" "\026" "\027" "\030" "\031" "\032" "\033" "\034" "\035" "\036" "\037" ":""\\" "*""?""%" +"\"" "<"">""|" "A""B""C""D""E""F""G""H" "I""J""K""L""M""N""O""P" "Q""R""S""T""U""V""W""X" -- Eric Blake
export getsubopt
Since POSIX requires getsubopt, and newlib provides it, here goes (and let's hope this patch applies cleaner than my previous two): 2006-01-06 Eric Blake <[EMAIL PROTECTED]> * cygwin.din: Export getsubopt. * include/cygwin/version.h: Bump API minor version. Index: cygwin.din === RCS file: /cvs/src/src/winsup/cygwin/cygwin.din,v retrieving revision 1.151 diff -u -r1.151 cygwin.din --- cygwin.din 18 Nov 2005 17:48:23 - 1.151 +++ cygwin.din 6 Jan 2006 15:27:57 - @@ -321,6 +321,7 @@ getservent = cygwin_getservent SIGFE getsockname = cygwin_getsockname SIGFE getsockopt = cygwin_getsockopt SIGFE +getsubopt SIGFE getusershell SIGFE herror = cygwin_herror SIGFE hstrerror = cygwin_hstrerror NOSIGFE Index: include/cygwin/version.h === RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/version.h,v retrieving revision 1.219 diff -u -r1.219 version.h --- include/cygwin/version.h22 Dec 2005 16:45:15 - 1.219 +++ include/cygwin/version.h6 Jan 2006 15:27:57 - @@ -1,6 +1,6 @@ /* version.h -- Cygwin version numbers and accompanying documentation. - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc. + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc. This file is part of Cygwin. @@ -284,12 +284,13 @@ int, as per linux. 148: Add open(2) flags O_SYNC, O_RSYNC, O_DSYNC and O_DIRECT. 149: Add open(2) flag O_NOFOLLOW. + 150: Export getsubopt. */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 149 +#define CYGWIN_VERSION_API_MINOR 150 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible
Re: [Patch] regtool: Add load/unload commands and --binary option
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Yitzchak Scott-Thoennes on 3/3/2006 10:41 AM: > > as another example of non-traditional access to the registry. How > about /proc/registry//machinename/... to access the registry of other > computers on the network? Or is // not at the beginning a no-no? // is only special at the beginning. Anywhere else in a filename, POSIX requires /proc/registry/foo and /proc/registry//foo to name the same file. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFECjuR84KuGfSFAYARAo38AJwNlRpqrR339r9FqVc+0ZNLRNHOkwCgz4T0 l02999MPTlIgJCPO/UU6cQg= =mlnF -END PGP SIGNATURE-
fcntl debug
In an attempt to figure out why my third newlib freopen(NULL) patch still failed (and hence leading to today's fourth patch - man, I have really fat-fingered my efforts to get freopen(NULL) usable), I noticed that an strace of fcntl(F_GETFL) was not as helpful as I would like. 2006-03-22 Eric Blake <[EMAIL PROTECTED]> * fhandler.cc (fcntl): Print flags in hex. Index: winsup/cygwin/fhandler.cc === RCS file: /cvs/src/src/winsup/cygwin/fhandler.cc,v retrieving revision 1.250 diff -u -r1.250 fhandler.cc --- winsup/cygwin/fhandler.cc 22 Feb 2006 16:40:42 - 1.250 +++ winsup/cygwin/fhandler.cc 22 Mar 2006 15:05:08 - @@ -1,7 +1,7 @@ /* fhandler.cc. See console.cc for fhandler_console functions. Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005 Red Hat, Inc. + 2005, 2006 Red Hat, Inc. This file is part of Cygwin. @@ -1304,7 +1304,7 @@ break; case F_GETFL: res = get_flags (); - debug_printf ("GETFL: %d", res); + debug_printf ("GETFL: %p", res); break; case F_SETFL: {
limits.h missing constants
CVS gettext had a compilation warning due to a missing value for CHARCLASS_NAME_MAX. Cygwin regex currently only supports char-class names of up to 6 characters (for example, "[:xdigit:]"), but POSIX requires a minimum of 14 when locales are free to define their own char-class names. While I was at it, I noticed that several of the limits.h constants that are required to be the same across all platforms were missing or incorrect. And we might as well publicize our limit for declaring ELOOP on symlink chains, rather than keeping it hidden in path.h. 2006-04-15 Eric Blake <[EMAIL PROTECTED]> * include/limits.h (_POSIX_*, _POSIX2_*, _XOPEN_*): Define missing standard constants, and correct invalid ones. (CHARCLASS_NAME_MAX): Define. (SYMLOOP_MAX): Define. * path.h (MAX_LINK_DEPTH): Define in terms of SYMLOOP_MAX. * regex/regcomp.c (p_b_cclass): Limit length of char class name. cygwin.patch Description: Binary data
Re: limits.h missing constants
> 2006-04-15 Eric Blake <[EMAIL PROTECTED]> > > * include/limits.h (_POSIX_*, _POSIX2_*, _XOPEN_*): Define missing > standard constants, and correct invalid ones. > (CHARCLASS_NAME_MAX): Define. > (SYMLOOP_MAX): Define. > * path.h (MAX_LINK_DEPTH): Define in terms of SYMLOOP_MAX. > * regex/regcomp.c (p_b_cclass): Limit length of char class name. Oops - wrong version of the patch (path.h needs to include limits.h as in this corrected version, for SYMLOOP_MAX to work). Also, if you want to double-check my limits.h values, see http://www.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html#tag_13_24 -- Eric Blake cygwin.patch Description: Binary data
mkstemp vs. text mode
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Should we change mkstemp to always open in binary mode, regardless of the mount mode of the directory of the template name? Arguments for this is that mkstemp is often used by programs for binary data, where a text-mode /tmp mount point would corrupt that data if we defer to the mount point. Also, a temp file is an intermediate data storage location, similar to pipes, and we currently treat pipes as binary by default; a program copying data to a temp file, then from there to a final destination, only needs text mode on the final destination. Programs that really want a text-mode temp file can do setmode after the fact, but this is probably less common. This should still be a trivial patch. Meanwhile, I will start the process of getting an employee disclaimer for Red Hat (it took me almost a year to get one signed for FSF). 2006-04-17 Eric Blake <[EMAIL PROTECTED]> * mktemp.cc (_gettemp): Open temp files in binary mode. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFEQ4ee84KuGfSFAYARAkpIAKCYK1IRVHZ4dMkWUTgyzycxyMkBawCfXgz4 wCvt41FDUXLB67JFnv+vZgg= =LLV/ -END PGP SIGNATURE- Index: mktemp.cc === RCS file: /cvs/src/src/winsup/cygwin/mktemp.cc,v retrieving revision 1.2 diff -u -p -r1.2 mktemp.cc --- mktemp.cc 25 May 2005 03:43:58 - 1.2 +++ mktemp.cc 17 Apr 2006 12:15:39 - @@ -105,7 +105,8 @@ _gettemp(char *path, int *doopen, int do { if (doopen) { - if ((*doopen = open (path, O_CREAT | O_EXCL | O_RDWR, 0600)) >= 0) + if ((*doopen = open (path, O_CREAT | O_EXCL | O_RDWR | O_BINARY, + S_IRUSR | S_IWUSR)) >= 0) return 1; if (errno != EEXIST) return 0;
Fix UINT{8,16}_C
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to POSIX, UINT{8,16}_C should result in an integer constant with "the same type as would an expression that is an object of the corresponding type converted according to the integer promotions." And according to C, unsigned char promotes to signed int, when int is wider than char. Gnulib now tests for bugs in stdint.h, and these are the remaining two issues that makes cygwin's version non-compliant: 2006-07-02 Eric Blake <[EMAIL PROTECTED]> * include/stdint.h (UINT8_C, UINT16_C): Unsigned types smaller than int promote to signed int. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFEqDR/84KuGfSFAYARAnkuAJ9oKW4FEnOVPythNkGLs0Mw0+QQsgCbBwTy VCM75i+6nr3jYZXs3qrhLZw= =iYl2 -END PGP SIGNATURE- Index: cygwin/include/stdint.h === RCS file: /cvs/src/src/winsup/cygwin/include/stdint.h,v retrieving revision 1.6 diff -u -p -r1.6 stdint.h --- cygwin/include/stdint.h 23 May 2005 13:13:00 - 1.6 +++ cygwin/include/stdint.h 2 Jul 2006 21:01:39 - @@ -1,6 +1,6 @@ /* stdint.h - integer types - Copyright 2003 Red Hat, Inc. + Copyright 2003, 2006 Red Hat, Inc. This file is part of Cygwin. @@ -169,8 +169,8 @@ typedef unsigned long long uintmax_t; #define INT32_C(x) x ## L #define INT64_C(x) x ## LL -#define UINT8_C(x) x ## U -#define UINT16_C(x) x ## U +#define UINT8_C(x) x +#define UINT16_C(x) x #define UINT32_C(x) x ## UL #define UINT64_C(x) x ## ULL
Re: Fix UINT{8,16}_C
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Corinna Vinschen on 7/3/2006 3:41 AM: > > > I have checked the stdint.h headers on glibc 2.3.4 and 2.4, as well as > on Solaris 10, NetBSD, FreeBSD and OpenBSD. Only FreeBSD and OpenBSD > define them as just x, all others as x##U, one way or the other. And gnulib rejects Solaris 10 and glibc's versions as buggy as well: http://lists.gnu.org/archive/html/bug-gnulib/2006-06/msg00118.html > > ISO/IEC 9899:TC2 (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf) > has the following to say: > > 7.18.4.1 Macros for minimum-width integer constants > > The macro INTN_C(value) shall expand to an integer constant expression > corresponding to the type int_leastN_t. The problem is that there is no integer constant expression for unsigned char; instead, you get an integer constant expression for the type that unsigned char promotes to. Therefore, UINT8_C should give an int, not unsigned int. This snippet from gnulib is valid C code, but fails if you use the wrong type specifier: /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others. */ int check_UINT8_C: (-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1; int check_UINT16_C: (-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1; - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFEqQlJ84KuGfSFAYARAiZ6AJ96BYisYJGTcK89Nbc+LWzeaaOCTQCbBdy6 fvwEMp2hXBTtEsSaVSOg30w= =ddci -END PGP SIGNATURE-
Re: [ANNOUNCEMENT] Updated [experimental]: bash-3.1-7
> > That is being set by cygcheck, just before invoking external programs. It > > probably had something to do with forcing external programs to not > > rearrange > > option arguments (for example, "ls foo --all" treats --all as an option, > > but "POSIXLY_CORRECT=1 ls foo --all" treats --all as a filename). But I > > think > > it is possible to get along without doing it (repeating the example, "ls -- > > foo --all" treats --all as a filename), and I personally think that > > cygcheck > > should be patched to QUIT setting POSIXLY_CORRECT, so that we can tell the > > masochists apart from normal users. > > Ah, ok, so seeing it in cygcheck is a false positive. Didn't think that > cygcheck would tinker with my environment (maybe it should know it is > doing so and preserve the invocation value and print that?), so I didn't > think to actually 'echo $POSIXLY_CORRECT'. :-) > 2006-09-11 Eric Blake <[EMAIL PROTECTED]> * cygcheck.cc (main): Restore POSIXLY_CORRECT before displaying user's environment. cygwin.patch3 Description: Binary data
Re: [ANNOUNCEMENT] Updated [experimental]: bash-3.1-7
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Christopher Faylor on 9/12/2006 9:15 AM: >> 2006-09-11 Eric Blake <[EMAIL PROTECTED]> >> >> * cygcheck.cc (main): Restore POSIXLY_CORRECT before displaying >> user's environment. > > Applied. Not quite. The changelog changed, but cygcheck.cc is still pending :) http://cygwin.com/ml/cygwin-cvs/2006-q3/msg00158.html - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFCAAp84KuGfSFAYARAhuzAJ9l1pgZyV6MLVy7jmPoHvy+E8r7NACgh30t c8l9IU0n9tPaDQ/j2pNPa9o= =tL6t -END PGP SIGNATURE-
get TIOCGWINSZ from
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Linux: $ gcc -E - <<\EOF | tail -n 2 > #include > TIOCGWINSZ > EOF # 2 "" 2 0x5413 On cygwin, prior to this patch: $ gcc -E - <<\EOF | tail -n 2 > #include > TIOCGWINSZ > EOF # 2 "" 2 TIOCGWINSZ Should be safe to apply since neither TIOCGWINSZ nor are specified by POSIX, so we don't have to worry about namespace pollution. 2006-12-06 Eric Blake <[EMAIL PROTECTED]> * include/sys/ioctl.h: Pick up termios.h, for TIOCGWINSZ. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFdsT684KuGfSFAYARAiJSAKCEzDXdOwAFzVAQ4u5NcOnGg/IG+QCePQYh XL+447Fbaq1/CovSiaHWdvY= =mB+V -END PGP SIGNATURE- Index: cygwin/include/sys/ioctl.h === RCS file: /cvs/src/src/winsup/cygwin/include/sys/ioctl.h,v retrieving revision 1.8 diff -u -p -r1.8 ioctl.h --- cygwin/include/sys/ioctl.h 12 Aug 2005 02:39:13 - 1.8 +++ cygwin/include/sys/ioctl.h 6 Dec 2006 13:22:02 - @@ -1,6 +1,6 @@ /* sys/ioctl.h - Copyright 1998, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc. + Copyright 1998, 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc. This file is part of Cygwin. @@ -14,6 +14,7 @@ details. */ #define _SYS_IOCTL_H #include +#include __BEGIN_DECLS
Re: Increase st_blksize to 64k
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Corinna Vinschen on 1/3/2007 5:16 AM: > > Setting st_blksize to 64K might be a good idea for disk I/O if the value > is actually used by applications. Do you have a specific example or a > test result from a Cygwin application which shows the advantage of > setting st_blksize to this value? I assume there was some actual case > which led you to make this change ;) Did you read the original link? http://sourceware.org/ml/cygwin/2006-12/msg00911.html coreutils has the following, in src/system.h, used by cp, install, mv, du, ls, stat... /* Extract or fake data from a `struct stat'. ST_BLKSIZE: Preferred I/O blocksize for the file, in bytes. ST_NBLOCKS: Number of blocks in the file, including indirect blocks. ST_NBLOCKSIZE: Size of blocks used when calculating ST_NBLOCKS. */ #ifndef HAVE_STRUCT_STAT_ST_BLOCKS # define ST_BLKSIZE(statbuf) DEV_BSIZE # if defined _POSIX_SOURCE || !defined BSIZE /* fileblocks.c uses BSIZE. */ # define ST_NBLOCKS(statbuf) \ ((statbuf).st_size / ST_NBLOCKSIZE + ((statbuf).st_size % ST_NBLOCKSIZE != 0)) # else /* !_POSIX_SOURCE && BSIZE */ # define ST_NBLOCKS(statbuf) \ (S_ISREG ((statbuf).st_mode) \ || S_ISDIR ((statbuf).st_mode) \ ? st_blocks ((statbuf).st_size) : 0) # endif /* !_POSIX_SOURCE && BSIZE */ #else /* HAVE_STRUCT_STAT_ST_BLOCKS */ /* Some systems, like Sequents, return st_blksize of 0 on pipes. Also, when running `rsh hpux11-system cat any-file', cat would determine that the output stream had an st_blksize of 2147421096. Conversely st_blksize can be 2 GiB (or maybe even larger) with XFS on 64-bit hosts. Somewhat arbitrarily, limit the `optimal' block size to SIZE_MAX / 8 + 1. (Dividing SIZE_MAX by only 4 wouldn't suffice, since "cat" sometimes multiplies the result by 4.) If anyone knows of a system for which this limit is too small, please report it as a bug in this code. */ # define ST_BLKSIZE(statbuf) ((0 < (statbuf).st_blksize \ && (statbuf).st_blksize <= SIZE_MAX / 8 + 1) \ ? (statbuf).st_blksize : DEV_BSIZE) ... #ifndef ST_NBLOCKSIZE # ifdef S_BLKSIZE # define ST_NBLOCKSIZE S_BLKSIZE # else # define ST_NBLOCKSIZE 512 # endif #endif For example, in cp, the following usage appears: #if HAVE_STRUCT_STAT_ST_BLOCKS /* Use a heuristic to determine whether SRC_NAME contains any sparse blocks. If the file has fewer blocks than would normally be needed for a file of its size, then at least one of the blocks in the file is a hole. */ if (x->sparse_mode == SPARSE_AUTO && S_ISREG (src_open_sb.st_mode) && ST_NBLOCKS (src_open_sb) < src_open_sb.st_size / ST_NBLOCKSIZE) make_holes = true; #endif It sounds like we want to ensure that cygwin chooses ST_BLKSIZE at 64k (optimal I/O size) but ST_NBLOCKS/ST_NBLOCKSIZE at the disk granularity (512). - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFm62y84KuGfSFAYARAkOkAJ4iRSCq69/Vfa+rE1V/d4v3CBssMgCgl+Yc PXdwJeLfT0+XeXQL+XahBik= =WWJR -END PGP SIGNATURE-
compile warning in cygwin/stat.h
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 This patch: http://cygwin.com/ml/cygwin-cvs/2007-q1/msg00123.html breaks compilation of coreutils against the latest snapshot when using - -Wall -Werror, due to an unused expression on the left of a comma. 2007-03-13 Eric Blake <[EMAIL PROTECTED]> * include/cygwin/stat.h (S_TYPEISSHM, S_TYPEISSEM, S_TYPEISSHM): Avoid compiler warnings. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF9plw84KuGfSFAYARAotJAJ9BAhe/pj0BKfM4hnnv9Nz0h+ebiwCcCkZ+ eo+aekowcQMQsmIZMyAIrU0= =BSsC -END PGP SIGNATURE- Index: include/cygwin/stat.h === RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/stat.h,v retrieving revision 1.10 diff -u -p -r1.10 stat.h --- include/cygwin/stat.h 6 Mar 2007 14:56:44 - 1.10 +++ include/cygwin/stat.h 13 Mar 2007 12:26:19 - @@ -91,9 +91,9 @@ struct stat /* POSIX IPC objects are not implemented as distinct file types, so the below macros have to return 0. The expression is supposed to catch illegal usage with non-stat parameters. */ -#define S_TYPEISMQ(buf) ((buf)->st_mode,0) -#define S_TYPEISSEM(buf) ((buf)->st_mode,0) -#define S_TYPEISSHM(buf) ((buf)->st_mode,0) +#define S_TYPEISMQ(buf) ((void)(buf)->st_mode,0) +#define S_TYPEISSEM(buf) ((void)(buf)->st_mode,0) +#define S_TYPEISSHM(buf) ((void)(buf)->st_mode,0) #ifdef __cplusplus }
Re: compile warning in cygwin/stat.h
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Corinna Vinschen on 3/13/2007 7:22 AM: > On Mar 13 06:30, Eric Blake wrote: >> * include/cygwin/stat.h (S_TYPEISSHM, S_TYPEISSEM, S_TYPEISSHM): >> Avoid compiler warnings. > > Thanks, applied. For all that, and I still got the changelog wrong. I listed S_TYPEISSHM twice and missed S_TYPEISMQ. I'm spending more typing on the patch procedure than the patch itself :) - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF9qbl84KuGfSFAYARAihTAKCmoqXThbnAbrcp6nDGf+oTejzmJQCfXERJ ElI9YadGLZOg4wNDvncH9Fg= =xwql -END PGP SIGNATURE-
Re: stdint.h bug
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Christopher Faylor on 4/3/2007 1:13 PM: > On Tue, Apr 03, 2007 at 06:15:14PM +0000, Eric Blake wrote: >> Cygwin defines wint_t as unsigned int (valid, per POSIX), but then defines >> >> #ifndef WINT_MIN >> #define WINT_MIN (-2147483647 - 1) >> #define WINT_MAX (2147483647) >> #endif >> >> which is invalid given the underlying type of wint_t. Can we get this fixed >> (either make wint_t a signed type, or change WINT_MIN and WINT_MAX)? > > Patch? Well, I was hoping for some feedback as to whether changing wint_t to be signed was preferable over changing WINT_MIN. But further research shows Linux also uses an unsigned type for wint_t, so: 2007-04-03 Eric Blake <[EMAIL PROTECTED]> * include/stdint.h (WINT_MIN, WINT_MAX): Fix definition. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGEv9/84KuGfSFAYARAo1OAJ9Ig6W0WqaMfGWN4njXieB8AJb0pwCgh3FE x5B6wtRLeWqvadttHSbl6Hw= =fB6i -END PGP SIGNATURE- Index: include/stdint.h === RCS file: /cvs/src/src/winsup/cygwin/include/stdint.h,v retrieving revision 1.7 diff -u -p -r1.7 stdint.h --- include/stdint.h3 Jul 2006 12:30:04 - 1.7 +++ include/stdint.h4 Apr 2007 01:27:08 - @@ -1,6 +1,6 @@ /* stdint.h - integer types - Copyright 2003, 2006 Red Hat, Inc. + Copyright 2003, 2006, 2007 Red Hat, Inc. This file is part of Cygwin. @@ -158,8 +158,8 @@ typedef unsigned long long uintmax_t; #endif #ifndef WINT_MIN -#define WINT_MIN (-2147483647 - 1) -#define WINT_MAX (2147483647) +#define WINT_MIN 0 +#define WINT_MAX UINT_MAX #endif /* Macros for minimum-width integer constant expressions */
Re: stdint.h bug
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Corinna Vinschen on 4/4/2007 1:38 AM: > On Apr 3 19:29, Eric Blake wrote: >> * include/stdint.h (WINT_MIN, WINT_MAX): Fix definition. > > Thanks, applied. A two-line patch, and I _still_ managed to botch it. POSIX requires that WINT_MIN be unsigned if (wint_t)0 promotes to an unsigned type. Or in other words, (-1 < WINT_MIN) == ((wint_t) -1 < 0) must be true. 2007-04-05 Eric Blake <[EMAIL PROTECTED]> * include/stdint.h (WINT_MIN): Fix sign. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGFaQV84KuGfSFAYARAmW8AJ9QGdXtWbUxllUGN9n0FgONCtOHWACcDxRT gD5ZhCiGstr+Dx4lr8tsgi8= =sA5w -END PGP SIGNATURE- Index: include/stdint.h === RCS file: /cvs/src/src/winsup/cygwin/include/stdint.h,v retrieving revision 1.8 diff -u -p -r1.8 stdint.h --- include/stdint.h4 Apr 2007 07:37:53 - 1.8 +++ include/stdint.h6 Apr 2007 01:31:37 - @@ -158,7 +158,7 @@ typedef unsigned long long uintmax_t; #endif #ifndef WINT_MIN -#define WINT_MIN 0 +#define WINT_MIN 0U #define WINT_MAX UINT_MAX #endif
export a few newlib functions
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 As discussed this morning: 2007-05-14 Eric Blake <[EMAIL PROTECTED]> * cygwin.din (asnprintf, dprint, _Exit, vasnprintf, vdprintf): Export. * include/cygwin/version.h: Bump API minor number. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGSQQT84KuGfSFAYARAlSiAKCUTfbe5GdJA2UKCnIA2/UqMKwA8wCfTQl4 MxcJ3HIrDkTwV70mqfY9QOQ= =SA0B -END PGP SIGNATURE- Index: cygwin.din === RCS file: /cvs/src/src/winsup/cygwin/cygwin.din,v retrieving revision 1.171 diff -u -p -r1.171 cygwin.din --- cygwin.din 20 Feb 2007 15:48:04 - 1.171 +++ cygwin.din 15 May 2007 00:44:21 - @@ -112,6 +112,7 @@ asinh NOSIGFE _asinh = asinh NOSIGFE asinhf NOSIGFE _asinhf = asinhf NOSIGFE +asnprintf SIGFE asprintf SIGFE _asprintf = asprintf SIGFE asprintf_r = _asprintf_r SIGFE @@ -275,6 +276,7 @@ dn_expand = __dn_expand SIGFE __dn_expand SIGFE dn_skipname = __dn_skipname SIGFE __dn_skipname SIGFE +dprintf SIGFE drand48 NOSIGFE _drand48 = drand48 NOSIGFE drem NOSIGFE @@ -344,6 +346,7 @@ execvp SIGFE _execvp = execvp SIGFE exit = cygwin_exit SIGFE _exit SIGFE +_Exit SIGFE exp NOSIGFE _exp = exp NOSIGFE exp2 NOSIGFE @@ -1599,10 +1602,12 @@ utmpname SIGFE _utmpname = utmpname SIGFE utmpxname SIGFE valloc SIGFE +vasnprintf SIGFE vasprintf SIGFE _vasprintf = vasprintf SIGFE vasprintf_r = _vasprintf_r SIGFE _vasprintf_r SIGFE +vdprintf SIGFE verr SIGFE verrx SIGFE vfiprintf SIGFE Index: include/cygwin/version.h === RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/version.h,v retrieving revision 1.241 diff -u -p -r1.241 version.h --- include/cygwin/version.h6 Mar 2007 14:48:25 - 1.241 +++ include/cygwin/version.h15 May 2007 00:44:21 - @@ -307,12 +307,13 @@ details. */ mq_send, mq_setattr, mq_timedreceive, mq_timedsend, mq_unlink. 166: Export sem_unlink. 167: Add st_birthtim to struct stat. + 168: Export asnprintf, dprintf, _Exit, vasnprintf, vdprintf. */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 167 +#define CYGWIN_VERSION_API_MINOR 168 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible
declare hsearch_r
Cygwin already exports newlib's hsearch_r, but failed to declare it in cygwin's replacement . This leads to unnecessary warnings when compiling cygwin, at the point where newlib is trying to compile uses of hsearch_r. 2007-05-21 Eric Blake <[EMAIL PROTECTED]> * include/search.h (hsearch_r): Provide declaration. Index: include/search.h === RCS file: /cvs/src/src/winsup/cygwin/include/search.h,v retrieving revision 1.2 diff -u -p -r1.2 search.h --- include/search.h27 Mar 2005 02:31:33 - 1.2 +++ include/search.h21 May 2007 12:57:45 - @@ -57,6 +57,7 @@ void hdestroy (void); ENTRY *hsearch (ENTRY, ACTION); int hcreate_r (size_t, struct hsearch_data *); void hdestroy_r (struct hsearch_data *); +int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *); void *tdelete (const void * __restrict, void ** __restrict, int (*) (const void *, const void *)); void tdestroy (void *, void (*)(void *)); -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED]
Re: API compatibility documentation change
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Corinna Vinschen on 6/20/2007 8:53 AM: >> fmemopen - missing, but I'm working on it in newlib >> open_memstream - missing, but I'm working on it in newlib > > How are you going to implement that? mmap? shm_open? Actually, more like I did for fopencookie. fmemopen doesn't need to worry about growth, and provided that realloc is intelligent, open_memstream shouldn't be too slow, either. > >> stpcpy - missing, but gnulib has an emulation >> stpncpy - missing, but gnulib has an emulation > > Shouldn't be too difficult. Also, psignal and psiginfo seem pretty easy to implement. Here's a first patch to the list of functions, by the way, along with recent newlib additions: 2007-06-20 Eric Blake <[EMAIL PROTECTED]> * cygwin.din: Export exp10, exp10f, pow10, pow10f, strcasestr, funopen, fopencookie. * include/cygwin/version.h: Bump API minor number. * posix.sgml: Minor improvements. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGec6O84KuGfSFAYARAk0JAJsFzlSdaZYrrNqdDwodD0mASZl/BACfcuRz AnTEU2CR0LpH9Pb1rEvHUiE= =C5fB -END PGP SIGNATURE- Index: cygwin.din === RCS file: /cvs/src/src/winsup/cygwin/cygwin.din,v retrieving revision 1.174 diff -u -p -r1.174 cygwin.din --- cygwin.din 12 Jun 2007 15:24:46 - 1.174 +++ cygwin.din 21 Jun 2007 00:55:41 - @@ -350,6 +350,8 @@ _exit SIGFE _Exit SIGFE exp NOSIGFE _exp = exp NOSIGFE +exp10 NOSIGFE +exp10f NOSIGFE exp2 NOSIGFE exp2f NOSIGFE expf NOSIGFE @@ -469,6 +471,7 @@ _fnmatch = fnmatch NOSIGFE fopen SIGFE _fopen = fopen SIGFE _fopen64 = fopen64 SIGFE +fopencookie SIGFE fork SIGFE _fork = fork SIGFE forkpty SIGFE @@ -536,6 +539,7 @@ fts_set NOSIGFE fts_set_clientptr NOSIGFE ftw SIGFE funlockfile SIGFE +funopen SIGFE futimes SIGFE fwrite SIGFE _fwrite = fwrite SIGFE @@ -1012,6 +1016,8 @@ posix_regexec SIGFE posix_regfree SIGFE pow NOSIGFE _pow = pow NOSIGFE +pow10 NOSIGFE +pow10f NOSIGFE powf NOSIGFE _powf = powf NOSIGFE pread SIGFE @@ -1417,6 +1423,7 @@ _statfs = statfs SIGFE statvfs SIGFE strcasecmp NOSIGFE _strcasecmp = strcasecmp NOSIGFE +strcasestr NOSIGFE strcat NOSIGFE _strcat = strcat NOSIGFE strchr NOSIGFE Index: posix.sgml === RCS file: /cvs/src/src/winsup/cygwin/posix.sgml,v retrieving revision 1.6 diff -u -p -r1.6 posix.sgml --- posix.sgml 12 Jun 2007 15:24:46 - 1.6 +++ posix.sgml 21 Jun 2007 00:55:42 - @@ -171,6 +171,7 @@ also ISO/IEC 9945:2003 and IEEE Std 1003 fopen fork fpathconf +fpclassify (see chapter "Implementation Notes") fprintf fputc fputs @@ -296,21 +297,21 @@ also ISO/IEC 9945:2003 and IEEE Std 1003 isblank iscntrl isdigit -isfinite +isfinite (see chapter "Implementation Notes") isgraph -isgreater -isgreaterequal -isinf +isgreater (see chapter "Implementation Notes") +isgreaterequal (see chapter "Implementation Notes") +isinf (see chapter "Implementation Notes") isless -islessequal -islessgreater +islessequal(see chapter "Implementation Notes") +islessgreater (see chapter "Implementation Notes") islower -isnan -isnormal +isnan (see chapter "Implementation Notes") +isnormal (see chapter "Implementation Notes") isprint ispunct isspace -isunordered +isunordered(see chapter "Implementation Notes") isupper iswalnum iswalpha @@ -597,6 +598,7 @@ also ISO/IEC 9945:2003 and IEEE Std 1003 send sendmsg sendto +setbuf setegid setenv seteuid @@ -641,7 +643,7 @@ also ISO/IEC 9945:2003 and IEEE Std 1003 sigismember siglongjmp signal -signbit +signbit(see chapter "Implementation Notes") signgam sigpause sigpending @@ -764,6 +766,7 @@ also ISO/IEC 9945:2003 and IEEE Std 1003 utime utimes va_arg +va_copy va_end va_start vfork (see chapter "Implementation Notes") @@ -842,6 +845,7 @@ also ISO/IEC 9945:2003 and IEEE Std 1003 fts_read fts_set fts_set_clientptr +funopen gamma gamma_r gammaf @@ -895,6 +899,7 @@ also
Re: C99 assert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Eric Blake on 6/26/2007 2:07 PM: > Jeff Johnston redhat.com> writes: [see thread at http://sourceware.org/ml/newlib/2007/msg00763.html - cygwin's assert currently doesn't comply with POSIX] > >> Hi Eric, >> >>I'd like to see backward-compatiblity to be the old-style message >> format. I don't see the point of saying: function . So, old >> compiled calls to __assert would behave as they always have. Similarly, >> for systems without function capability, I would like to use the old >> message format. My take would be to have both __assert and >> __assert_func and have assert map to the appropriate call. I also think >> that the function should be quoted or you should use a colon (e.g. >> function: getparms) for clarification. >> > > How about the following, then? > > 2007-06-26 Eric Blake <[EMAIL PROTECTED]> > > Support __func__ in assert, as required by C99. > * libc/stdlib/assert.c (__assert_func): New function. > (__assert): Use __assert_func. > * libc/include/assert.h (assert) [!NDEBUG]: Use __assert_func when > possible. If I check in just the above newlib patch, CVS cygwin will be broken when trying to use assert (and simply exporting __assert_func won't help, since cygwin's assert.cc must provide all symbols present in newlib's assert.c). Likewise, this patch without newlib would break (because assert.h is maintained by newlib). So, is it OK to apply this patch at the same time as the newlib patch, to avoid breakage? 2007-06-26 Eric Blake <[EMAIL PROTECTED]> * assert.cc (__assert_func): New function, to match newlib header change. * cygwin.din: Export __assert_func. * include/cygwin/version.h: Bump API minor number. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGgbZm84KuGfSFAYARAlGEAJ0SkMaoL1uk3ubAKlpOAHEpqwyoKgCfWvO1 Ab5YpcbXTEG7FSab/uuxDZo= =W9ry -END PGP SIGNATURE- Index: cygwin.din === RCS file: /cvs/src/src/winsup/cygwin/cygwin.din,v retrieving revision 1.176 diff -u -p -r1.176 cygwin.din --- cygwin.din 21 Jun 2007 15:57:54 - 1.176 +++ cygwin.din 27 Jun 2007 00:43:20 - @@ -118,6 +118,7 @@ _asprintf = asprintf SIGFE asprintf_r = _asprintf_r SIGFE _asprintf_r SIGFE __assert SIGFE +__assert_func SIGFE __assertfail SIGFE atan NOSIGFE _atan = atan NOSIGFE Index: assert.cc === RCS file: /cvs/src/src/winsup/cygwin/assert.cc,v retrieving revision 1.9 diff -u -p -r1.9 assert.cc --- assert.cc 19 Sep 2002 15:12:48 - 1.9 +++ assert.cc 27 Jun 2007 00:43:20 - @@ -1,6 +1,6 @@ /* assert.cc: Handle the assert macro for WIN32. - Copyright 1997, 1998, 2000, 2001 Red Hat, Inc. + Copyright 1997, 1998, 2000, 2001, 2007 Red Hat, Inc. This file is part of Cygwin. @@ -23,6 +23,13 @@ details. */ extern "C" void __assert (const char *file, int line, const char *failedexpr) { + __assert_func (file, line, NULL, failedexpr); +} + +extern "C" void +__assert_func (const char *file, int line, const char *func, + const char *failedexpr) +{ HANDLE h; /* If we don't have a console in a Windows program, then bring up a @@ -35,15 +42,17 @@ __assert (const char *file, int line, co char *buf; buf = (char *) alloca (100 + strlen (failedexpr)); - __small_sprintf (buf, "Failed assertion\n\t%s\nat line %d of file %s", - failedexpr, line, file); + __small_sprintf (buf, "Failed assertion\n\t%s\nat line %d of file %s%s%s", + failedexpr, line, file, + func ? "\nin function " : "", func ? func : ""); MessageBox (NULL, buf, NULL, MB_OK | MB_ICONERROR | MB_TASKMODAL); } else { CloseHandle (h); - small_printf ("assertion \"%s\" failed: file \"%s\", line %d\n", - failedexpr, file, line); + small_printf ("assertion \"%s\" failed: file \"%s\", line %d%s%s\n", + failedexpr, file, line, + func ? ", function: " : "", func ? func : ""); } #ifdef DEBUGGING Index: include/cygwin/version.h === RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/version.h,v retrieving revision 1.246 diff -u
Re: C99 assert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Corinna Vinschen on 6/27/2007 1:35 AM: >> 2007-06-26 Eric Blake >> >> * assert.cc (__assert_func): New function, to match newlib header >> change. >> * cygwin.din: Export __assert_func. >> * include/cygwin/version.h: Bump API minor number. > > Yeees, barely. This is on the verge of being non-trivial, however. Applied. > Any chance you can sign the copyright assignment? Please? I'll try talking to my management at work today, once again, about the prospects of signing it. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGgl4H84KuGfSFAYARAkQuAKC1tPJ30XsDik9kPng84SqWHqgUrACfY+SV mU7KDEHOzXlzrxfNDvzJ4+w= =4SGM -END PGP SIGNATURE-