Evgeny Grin | 23 Sep 17:20 2015

[PATCH] Fix compiler errors/warnings when compiling with -O3

GCC find more suspicious places with -O3. Cygwin use -Werror so uninitialized variables prevent compilations.
This patch allow compilation with CFLAGS='-O3' CXXFLAGS='-O3'.

 winsup/cygwin/fhandler_socket.cc | 4 ++--
 winsup/cygwin/regex/regcomp.c    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index ecb6198..658dca7 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
 <at>  <at>  -746,7 +746,7  <at>  <at>  fhandler_socket::wait_for_events (const long event_mask, const DWORD flags)
     return 0;

   int ret;
-  long events;
+  long events = 0;

   while (!(ret = evaluate_events (event_mask, events, !(flags & MSG_PEEK)))
 	 && !events)
 <at>  <at>  -1160,7 +1160,7  <at>  <at>  int
 fhandler_socket::connect (const struct sockaddr *name, int namelen)
   struct sockaddr_storage sst;
-  int type;
+  int type = 0;

   if (get_inet_addr (name, namelen, &sst, &namelen, &type, connect_secret)
       == SOCKET_ERROR)
(Continue reading)

Evgeny Grin | 23 Sep 13:06 2015

[PATCH] Add ability to use NTFS native directory symlinks without admin rights on XP and later

This patch will add ability to create directory junction which are supported from Windows 2000 and not
require any special rights (unlike file/directory symbolic links).
New three modes for symbolic links creation added: "safenative", "safenativestrict" and
"safenativeonly". First two allow fallback to "native" and "nativesctrict", last one use only
directory junction for symbolic links (file links will fail with this setting, but it can be useful for
derived projects like MSys or Git for Windows).

Only creation of directory junctions is implemented in this patch, reading and resolving junction as
symbolic links are already supported by Cygwin.
I'd recommend to set default mode to "safenative" as it allow to use system functionality out-of-box with
fallback to Cygwin's functionality where system's symlinks are not available.

 winsup/cygwin/environ.cc |   9 ++
 winsup/cygwin/globals.cc |   5 +-
 winsup/cygwin/path.cc    | 215 ++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 226 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 8f25fb1..b02d685 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
 <at>  <at>  -84,6 +84,15  <at>  <at>  set_winsymlinks (const char *buf)
     allow_winsymlinks = WSYM_lnk;
   else if (ascii_strncasematch (buf, "lnk", 3))
     allow_winsymlinks = WSYM_lnk;
+  else if (ascii_strncasematch (buf, "safenative", 10))
+    {
+      if (ascii_strcasematch (buf + 10, "strict"))
+        allow_winsymlinks = WSYM_safenativestrict;
(Continue reading)

Johannes Schindelin | 16 Sep 15:06 2015

[PATCH] Allow overriding the home directory via the HOME variable

	* uinfo.cc (cygheap_pwdgrp::get_home): Offer an option in
	nsswitch.conf that let's the environment variable HOME (or

	* ntsec.xml: Document the `env` schema.

Detailed comments:

In the context of Git for Windows, it is a well-established technique
to let the `$HOME` variable define where the current user's home
directory is, falling back to `$HOMEDRIVE$HOMEPATH` and `$USERPROFILE`.

The idea is that we want to share user-specific settings between
programs, whether they be Cygwin, MSys2 or not.  Unfortunately, we
cannot blindly activate the "db_home: windows" setting because in some
setups, the user's home directory is set to a hidden directory via an
UNC path (\\share\some\hidden\folder$) -- something many programs
cannot handle correctly.

The established technique is to allow setting the user's home directory
via the environment variables mentioned above.  This has the additional
advantage that it is much faster than querying the Windows user database.

Of course this scheme needs to be opt-in.  For that reason, it needs
to be activated explicitly via `db_home: env` in `/etc/nsswitch.conf`.

Signed-off-by: Johannes Schindelin <johannes.schindelin <at> gmx.de>
 winsup/cygwin/cygheap.h |  3 ++-
(Continue reading)

Johannes Schindelin | 16 Sep 09:35 2015

[PATCH] Introduce the 'usertemp' filesystem type

	* mount.cc (mount_info::from_fstab_line): support mounting the
	current user's temp folder as /tmp/. This is particularly
	useful a feature when Cygwin's own files are write-protected.

	* pathnames.xml: document the new usertemp file system type

Detailed explanation:

In the context of Windows, there is a per-user directory for temporary
files, by default specified via the environment variable %TEMP%. Let's
allow to use that directory for our /tmp/ directory.

With this patch, we introduce the special filesystem type "usertemp":
By specifying

	none /tmp usertemp binary,posix=0 0 0

in /etc/fstab, the /tmp/ directory gets auto-mounted to the directory
specified by the %TEMP% variable.

This feature comes handy in particularly in scenarios where the
administrator might want to write-protect the entire Cygwin directory
yet still needs to allow users to write into the /tmp/ directory.
This is the case in the context of Git for Windows, where the
Cygwin (MSys2) root directory lives inside C:\Program Files and hence
/tmp/ would not be writable otherwise.

Signed-off-by: Johannes Schindelin <johannes.schindelin <at> gmx.de>
 winsup/cygwin/mount.cc   | 17 +++++++++++++++++
(Continue reading)

Jon TURNEY | 18 Aug 18:25 2015

[PATCH] Add Lavasoft Web Companion to BLODA list.

2015-08-18  Jon Turney  <jon.turney <at> dronecode.org.uk>

	* faq-using.xml (faq.using.bloda): Add Lavasoft Web Companion to
	BLODA list.

Signed-off-by: Jon TURNEY <jon.turney <at> dronecode.org.uk>
 winsup/doc/ChangeLog     | 5 +++++
 winsup/doc/faq-using.xml | 1 +
 2 files changed, 6 insertions(+)

diff --git a/winsup/doc/ChangeLog b/winsup/doc/ChangeLog
index 9cff0e4..02061ff 100644
--- a/winsup/doc/ChangeLog
+++ b/winsup/doc/ChangeLog
 <at>  <at>  -1,3 +1,8  <at>  <at> 
+2015-08-18  Jon Turney  <jon.turney <at> dronecode.org.uk>
+	* faq-using.xml (faq.using.bloda): Add Lavasoft Web Companion to
+	BLODA list.
 2015-08-03  Jon Turney  <jon.turney <at> dronecode.org.uk>

 	* faq-programming.xml: Improve debugging-cygwin answer.
diff --git a/winsup/doc/faq-using.xml b/winsup/doc/faq-using.xml
index 372888f..87ec112 100644
--- a/winsup/doc/faq-using.xml
+++ b/winsup/doc/faq-using.xml
 <at>  <at>  -1274,6 +1274,7  <at>  <at>  behaviour which affect the operation of other programs, such as Cygwin.
 <listitem><para>Credant Guardian Shield</para></listitem>
(Continue reading)

Orgad Shaneh | 17 Aug 09:41 2015

[PATCH] mkglobals: Fix EOL detection

When globals.cc has CRLF line endings, winsup.h is not removed, and
compilation fails for duplicate definitions.
 winsup/cygwin/mkglobals_h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/cygwin/mkglobals_h b/winsup/cygwin/mkglobals_h
index ea4a582..2d185f2 100755
--- a/winsup/cygwin/mkglobals_h
+++ b/winsup/cygwin/mkglobals_h
 <at>  <at>  -1,6 +1,7  <at>  <at> 
 my  <at> argv =  <at> ARGV;
 $_ = join('', <>);
 <at>  <at>  -12,7 +13,6  <at>  <at>  s/^\n+//sog;
 s/#include "winsup\.h"\n//so;
 print <<PRELUDE,$_;
 /* $target - Autogenerated from  <at> argv.  Look there for comments. */

(Continue reading)

Jon TURNEY | 4 Aug 14:36 2015

[PATCH] Improve FAQ answer on debugging Cygwin

Improve FAQ answer on debugging Cygwin to mention the cygwin-debuginfo package
and the gdb command 'set cygwin-exceptions oon'.

2015-08-03  Jon Turney  <jon.turney <at> dronecode.org.uk>

	* faq-programming.xml: Improve debugging-cygwin answer.

Signed-off-by: Jon TURNEY <jon.turney <at> dronecode.org.uk>
 winsup/doc/ChangeLog           |  4 ++++
 winsup/doc/faq-programming.xml | 26 ++++++++++++++++++++++----
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/winsup/doc/ChangeLog b/winsup/doc/ChangeLog
index e3eb26f..9cff0e4 100644
--- a/winsup/doc/ChangeLog
+++ b/winsup/doc/ChangeLog
 <at>  <at>  -1,3 +1,7  <at>  <at> 
+2015-08-03  Jon Turney  <jon.turney <at> dronecode.org.uk>
+	* faq-programming.xml: Improve debugging-cygwin answer.
 2015-07-21  Corinna Vinschen  <corinna <at> vinschen.de>

 	* new-features.xml (ov-new2.2): Document sigsetjmp, siglongjmp.
diff --git a/winsup/doc/faq-programming.xml b/winsup/doc/faq-programming.xml
index 491da5d..0c936eb 100644
--- a/winsup/doc/faq-programming.xml
+++ b/winsup/doc/faq-programming.xml
 <at>  <at>  -747,14 +747,32  <at>  <at>  same time. Remove all but one.
(Continue reading)

Petrovski, Roman | 29 Jul 16:11 2015

RtlFillMemory fails on block sizes over 0x7fffffff

Hi, just ran into a problem which boils down to the following at least with Windows 7:

char *p = (char*)malloc(0x80000000UL);	//works fine, allocates memory as requested
memset(p, 0, 0x80000000UL);			//Watch process segfault.

The RtlFillMemory either crashes or underfills the buffer depending on the size given.
Looks like internally it treats size as a signed 4-byte integer.

Please apply the patch below or implement an alternative.


From 60ed745b75d16755769653f19882335ef69960dd Mon Sep 17 00:00:00 2001
From: Roman Petrovski <rpetrovski <at> illumina.com>
Date: Wed, 29 Jul 2015 06:45:45 -0700
Subject: [PATCH] RtlFillMemory fails on block sizes over 0x7fffffff

 winsup/cygwin/miscfuncs.cc | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc
index 4a7a1b8..7308498 100644
--- a/winsup/cygwin/miscfuncs.cc
+++ b/winsup/cygwin/miscfuncs.cc
 <at>  <at>  -904,17 +904,35  <at>  <at>  err:
 extern "C" void NTAPI RtlFillMemory (PVOID, SIZE_T, BYTE);
 extern "C" void NTAPI RtlCopyMemory (PVOID, const VOID *, SIZE_T);

(Continue reading)

Michael Haubenwallner | 24 Jul 17:43 2015

[PATCH] winsup/cygwin: Protect fork() against dll- and exe-updates.


When starting to port Gentoo Prefix to Cygwin, the first real problem
discovered is that fork() does use the original executable's location
to Create the child's Process, probably finding linked dlls that just
have emerged in the current directory (sth. like /my/prefix/usr/bin),
causing "Loaded different DLL with same basename in forked child" errors.

Diving into the details, I'm coming up with (a patch-draft based on) the
idea to create hardlinks for the binaries-in-use into some cygwin-specific
directory, like \proc\<ntpid>\object\ ('ve seen this name on AIX),
and use these hardlinks instead to create the new child's process.

Thoughts so far?

For now, when <cygroot>\proc\ directory does exist, the patch (roughly) does:

For /bin/bash.exe, cygwin1.dll creates these hardlinks at process startup:
  \proc\<ntpid>\object\bash.exe         -> /bin/bash.exe
  \proc\<ntpid>\object\bash.exe.local      (empty file for dll redirection)
  \proc\<ntpid>\object\cygwin1.dll      -> /bin/cygwin1.dll
  \proc\<ntpid>\object\cygreadline7.dll -> /bin/cygreadline7.dll

And frok::parent then does:

  CreateProcess("\proc\<ntpid>\object\bash.exe", "/bin/bash.exe", ...)

Resulting in another \proc\<ntpid>\object\ directory with same hardlinks.

While attached patch does work so far already, there's a few issues:
(Continue reading)

Jon TURNEY | 5 Jul 20:11 2015

[PATCH] winsup/doc: Add a configure test to find docbook2xtexi

Fedora installs docbook2texi under the name db2x_docbook2texi
Other distros and Cygwin install docbook2texi under the name docbook2x-texi

Add a configure test to find either.

2015-07-05  Jon Turney  <jon.turney <at> dronecode.org.uk>

	* configure.ac: Add check for DOCBOOK2XTEXI
	* configure: Regenerate.
	* Makefile.in (DOCBOOK2XTEXI): Use.

Signed-off-by: Jon TURNEY <jon.turney <at> dronecode.org.uk>
 winsup/doc/ChangeLog    |  6 ++++++
 winsup/doc/Makefile.in  |  2 +-
 winsup/doc/configure    | 44 ++++++++++++++++++++++++++++++++++++++++++++
 winsup/doc/configure.ac |  1 +
 4 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/winsup/doc/ChangeLog b/winsup/doc/ChangeLog
index 841bbe2..b452fa9 100644
--- a/winsup/doc/ChangeLog
+++ b/winsup/doc/ChangeLog
 <at>  <at>  -1,3 +1,9  <at>  <at> 
+2015-07-05  Jon Turney  <jon.turney <at> dronecode.org.uk>
+	* configure.ac: Add check for DOCBOOK2XTEXI
+	* configure: Regenerate.
+	* Makefile.in (DOCBOOK2XTEXI): Use.
(Continue reading)

Jeffrey Walton | 1 Jul 03:38 2015

Using g++ and -m32 option on x86_64 broken

Cygwin's GCC responds to the -m32 option, but it causes a compile error:

   expected unqualified-id before ‘__int128’
       inline __int128

If the project does not support the -m32 option, then it should be
removes so that using it causes a compile error.

Below is the changed needed to get through the compile with -m32:

$ diff /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/x86_64-pc-cygwin/bits/c++config.h
< #ifndef __CYGWIN32__      /* -m32 used on x86_64 */
< # define _GLIBCXX_USE_INT128 1
< #endif
> #define _GLIBCXX_USE_INT128 1


And this project really needs a bug tracker...