X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Fri, 17 Sep 2010 21:38:29 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: where was mention of what creates NUL files? Message-ID: <20100917193829.GA18327@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <4C93A171 DOT 4040402 AT fgm DOT com> <4C93A3C4 DOT 80508 AT redhat DOT com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <4C93A3C4.80508@redhat.com> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On Sep 17 11:22, Eric Blake wrote: > On 09/17/2010 11:12 AM, Daniel Barclay wrote: > >Does anyone recall a mention of what in CygWin (or possibly Emacs) creates It's Cygwin, not CygWin. files with a simple name of "NUL"? > > Windows automagically maps the file named "NUL", in any directory, Meep! The Win32 API, not Windows per se. > to the equivalent of Unix' /dev/null. Cygwin doesn't create it, but > all the same, portable programs should never name a file that > case-insensitively matches 'nul', 'aux', or a host of other > windows-magic names: > > http://www.gnu.org/software/autoconf/manual/autoconf.html#File-System-Conventions > > Meanwhile, cygwin 1.7 has added some magic to use native NT calls to > work around these limitations, so that you can have a file that > appears to be named "NUL" from within cygwin, but which is really > exploiting some 16-bit values outside of Unicode. Sorry, but that's not entirely correct. There isn't any magic involved and the resulting filename is actually "nul". No mapping to the Unicode private use area. The terrible DOS device name hack, which maps filenames containing substring named like the the old DOS device names (NUL, AUX, PRN, etc) to the actual Windows device, only exists in the Win32 API. Cygwin doesn't use the Win32 API to access files, rather it uses the underlying native NT API. This API allows to create and access actual files like "nul" or "aux.c", just as on any other OS. The DOS device name hack simply doesn't affect us. So, any Cygwin application can create files like "nul". It happens, for instance, if you call something like: $ echo foo > NUL $ ls -l NUL -rw-r--r-- 1 corinna vinschen 4 Sep 17 21:25 NUL Note: Don't use DOS device names in Cygwin! Wrong: $ echo foo > NUL $ echo foo > nul $ echo foo > nul: Right: $ echo foo > /dev/null See here: http://cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-dosdevices and here: http://cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-posixdevices Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple