Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com From: Chris Faylor Date: Sat, 24 Jun 2000 23:42:33 -0400 To: cygwin-developers AT sourceware DOT cygnus DOT com Subject: Pending change to cygwin DLL and binmode/textmode musings Message-ID: <20000624234233.A29998@cygnus.com> Reply-To: cygwin-developers AT sourceware DOT cygnus DOT com Mail-Followup-To: cygwin-developers AT sourceware DOT cygnus DOT com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i [This was also posted to cygwin-apps but since both mailing lists are subscribe-post-only, I thought it best to send two separate messages.] I've been playing around with a change to the cygwin DLL that attempts to duplicate functionality that is found in MSVC. I've created an object called "binmode.o" which, when added to a link line will cause any open that does not specify binary or text mode access to default to binary access. This is not 100% the same as Microsoft since you also have to worry about text mode and bin mode mounts in Cygwin. My implementation gives precedence to the (little used?) _fmode variable which has always been around in Cygwin. Setting this variable to O_BINARY used to be the same as CYGWIN=binmode, i.e., it didn't affect disk files. Now it does. CYGWIN=binmode still affects only non-disk files, however. So, this effectively duplicates MSVC functionality, AFAICT. Corinna and I were talking about another interface that is more general and possibly more useful. We were talking about developing a "cygwin_set_default_open" function. It would work something like this: /* Reads of /etc/passwd default to text unless explicitly specified */ set_default_open ("/etc/passwd", O_RDONLY | O_TEXT); /* Writes of /tmp/bar default to binary unless explicitly specified */ set_default_open ("/tmp/bar", O_WRONLY | O_BINARY); /* Accesses of any file named foof default to binary unless... */ set_default_open ("foof", O_BINARY); The premise here is that calls to this function can live in a program's "main()" to avoid modifying opens or fopens throughout the source. Alternatively, this could be added to a "premain()" function which would be called prior to main(). This would mean that you only have to modify a Makefile to link in the file containing the premain() function. DJ has also suggested that we could maintain a database of files which are known to have a certain format. So, for instance, /etc/passwd and /etc/group would be marked in this database as "always text". Another possibility is to set aside a block of space in each cygwin executable that could be filled in with names and modes of files that the executable uses. So, tcsh.exe would be modified, after linking, to set .cshrc as "always text". Anyway, that's what we're thinking of for ways to minimize the neverending binmode/textmode problems. cgf