This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Pending change to cygwin DLL and binmode/textmode musings

I like the idea of a database of files... that would mean less porting
issues, particularly with programs that act on files in common with other


----- Original Message -----
From: "Chris Faylor" <>
To: <>
Sent: Sunday, June 25, 2000 1:40 PM
Subject: Pending change to cygwin DLL and binmode/textmode musings

> 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
> to the (little used?) _fmode variable which has always been around in
> 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 either 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]