* fhandler.h: Move fcntl.h include here.
(fhandler_base::set_flags): Accept supplied_bin argument. Make non-inlined.
* dtable.cc (dtable::init_std_file_from_handle): Just use binmode from pc.
(reset_to_open_binmode): Use set_flags.
* cygwin.din (open): Avoid newlib wrapper.
(read): Ditto.
(unlink): Ditto.
(write): Ditto.
* fhandler.cc (fhandler_base::set_flags): Accept supplied_bin argument. Make
binmode decisions here.
(fhandler_base::open): Avoid using pc if it is NULL. Eliminate binmode logic.
Just call set_flags with binmode argument.
(fhandler_base::init): Call set_flags with binmode argument.
* fhandler_clipboard.cc (fhandler_dev_clipboard::open): Ditto.
* fhandler_console.cc (fhandler_console::open): Ditto.
(fhandler_console::init): Force binary on open.
* fhandler_disk_file.cc (fhandler_disk_file::open): Don't set binmode here.
Let it happen in base class.
* fhandler_dsp.cc (fhandler_dev_dsp::open): Force binmode open. Set return
value appropriately if unable to open.
* fhandler_proc.cc (fhandler_proc::open): Make sure flags are set before
open_status.
* fhandler_process.cc (fhandler_process::open): Ditto.
* fhandler_registry.cc (fhandler_registry::open): Ditto.
* fhandler_random.cc (fhandler_dev_random::fhandler_dev_random): Ditto.
* fhandler_raw.cc (fhandler_dev_raw::open): Force O_BINARY by default.
* fhandler_serial.cc (fhandler_serial::init): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::open): Ditto.
(fhandler_pty_master::open): Ditto.
* fhandler_virtual.cc (fhandler_virtual::open): Ditto.
* fhandler_windows.cc (fhandler_windows::open): Ditto.
* fhandler_zero.cc (fhandler_dev_zero::open): Ditto.
* net.cc (fdsock): Ditto.
* path.cc (path_conv::check): Avoid checking for extension when error or
directory.
(set_flags): Set PATH_TEXT explicitly, when appropriate.
(mount_info::conv_to_win32_path): Use set_flags() to set path flags.
* path.h (PATH_TEXT): New enum.
(path_conv::binmode): Return appropriate constant based on binmode.
* pipe.cc (make_pipe): Set binmode to O_TEXT xor O_BINARY.
* syscalls.cc (setmode_helper): Make debugging message a little clearer.
(setmode): Set binmode via set_flags.
+2002-06-04 Christopher Faylor <cgf@redhat.com>
+
+ Remove fcntl.h includes throughout.
+ * fhandler.h: Move fcntl.h include here.
+ (fhandler_base::set_flags): Accept supplied_bin argument. Make
+ non-inlined.
+ * dtable.cc (dtable::init_std_file_from_handle): Just use binmode from
+ pc.
+ (reset_to_open_binmode): Use set_flags.
+ * cygwin.din (open): Avoid newlib wrapper.
+ (read): Ditto.
+ (unlink): Ditto.
+ (write): Ditto.
+ * fhandler.cc (fhandler_base::set_flags): Accept supplied_bin argument.
+ Make binmode decisions here.
+ (fhandler_base::open): Avoid using pc if it is NULL. Eliminate binmode
+ logic. Just call set_flags with binmode argument.
+ (fhandler_base::init): Call set_flags with binmode argument.
+ * fhandler_clipboard.cc (fhandler_dev_clipboard::open): Ditto.
+ * fhandler_console.cc (fhandler_console::open): Ditto.
+ (fhandler_console::init): Force binary on open.
+ * fhandler_disk_file.cc (fhandler_disk_file::open): Don't set binmode
+ here. Let it happen in base class.
+ * fhandler_dsp.cc (fhandler_dev_dsp::open): Force binmode open. Set
+ return value appropriately if unable to open.
+ * fhandler_proc.cc (fhandler_proc::open): Make sure flags are set
+ before open_status.
+ * fhandler_process.cc (fhandler_process::open): Ditto.
+ * fhandler_registry.cc (fhandler_registry::open): Ditto.
+ * fhandler_random.cc (fhandler_dev_random::fhandler_dev_random): Ditto.
+ * fhandler_raw.cc (fhandler_dev_raw::open): Force O_BINARY by default.
+ * fhandler_serial.cc (fhandler_serial::init): Ditto.
+ * fhandler_tty.cc (fhandler_tty_slave::open): Ditto.
+ (fhandler_pty_master::open): Ditto.
+ * fhandler_virtual.cc (fhandler_virtual::open): Ditto.
+ * fhandler_windows.cc (fhandler_windows::open): Ditto.
+ * fhandler_zero.cc (fhandler_dev_zero::open): Ditto.
+ * net.cc (fdsock): Ditto.
+ * path.cc (path_conv::check): Avoid checking for executable extension
+ when directory. (Suggested by Pavel Tsekov)
+ (set_flags): Set PATH_TEXT explicitly, when appropriate.
+ (mount_info::conv_to_win32_path): Use set_flags() to set path flags.
+ * path.h (PATH_TEXT): New enum.
+ (path_conv::binmode): Return appropriate constant based on binmode.
+ * pipe.cc (make_pipe): Set binmode to O_TEXT xor O_BINARY.
+ * syscalls.cc (setmode_helper): Make debugging message a little
+ clearer.
+ (setmode): Set binmode via set_flags.
+
2002-06-04 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add private method
(create_token): Delete logonserver and call to get_logon_server.
Adjust arguments of get_group_sidlist, see above.
* security.h: Delete declaration of get_logon_server_and_user_domain
- and add declaration of get_logon_server.
+ and add declaration of get_logon_server.
* uinfo.cc (internal_get_login): Call get_logon_server instead of
get_logon_server_and_user_domain.
2002-06-02 Christopher Faylor <cgf@redhat.com>
- * dtable.cc (handle_to_fn): Use largest match for device. Correctly
- (?) deal with remote drive weirdness.
+ * dtable.cc (handle_to_fn): Use largest match for device. Correctly
+ (?) deal with remote drive weirdness.
2002-06-02 Christopher Faylor <cgf@redhat.com>
_nextafter = nextafter
nextafterf
_nextafterf = nextafterf
-open
-_open = open
+_open
+open = _open
opendir
_opendir = opendir
pathconf
random
initstate
setstate
-read
-_read = read
+_read
+read = read
readdir
_readdir = readdir
readlink
_uname = uname
ungetc
_ungetc = ungetc
-unlink
-_unlink = unlink
+_unlink
+unlink = _unlink
usleep
_usleep = usleep
utime
_wcstombs = wcstombs
wctomb
_wctomb = wctomb
-write
-_write = write
+_write
+write = _write
barfly = write
writev
_writev = writev
details. */
#include "winsup.h"
-#include <sys/fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
-#include <fcntl.h>
#include <sys/cygwin.h>
#include <assert.h>
#include <ntdef.h>
void
dtable::init_std_file_from_handle (int fd, HANDLE handle, DWORD myaccess)
{
- int bin = -1;
const char *name;
CONSOLE_SCREEN_BUFFER_INFO buf;
struct sockaddr sa;
name = NULL;
else
{
- if (__fmode)
- bin = __fmode;
- else
- bin = (int) binmode ?: -1;
-
- /* See if we can consoleify it - if it is a console,
- don't open it in binary. That will screw up our crlfs*/
+ /* See if we can consoleify it */
if (GetConsoleScreenBufferInfo (handle, &buf))
{
if (ISSTATE (myself, PID_USETTY))
name = "/dev/tty";
else
name = "/dev/conout";
- bin = 0;
}
else if (GetNumberOfConsoleInputEvents (handle, (DWORD *) &buf))
{
name = "/dev/tty";
else
name = "/dev/conin";
- bin = 0;
}
else if (ft == FILE_TYPE_PIPE)
{
name = "/dev/piper";
else
name = "/dev/pipew";
- if (bin == 0)
- bin = O_BINARY;
}
else if (wsock_started && getpeername ((SOCKET) handle, &sa, &sal) == 0)
name = "/dev/socket";
{
path_conv pc;
build_fhandler_from_name (fd, name, handle, pc)->init (handle, myaccess,
- bin < 0 ? pc.isbinary () : bin);
+ pc.binmode ());
set_std_handle (fd);
paranoid_printf ("fd %d, handle %p", fd, handle);
}
#include <stdlib.h>
#include <stddef.h>
#include <ctype.h>
-#include <fcntl.h>
#include <sys/cygwin.h>
#include <cygwin/version.h>
#include "pinfo.h"
details. */
#include "winsup.h"
-#include <fcntl.h>
#include <stdarg.h>
#include <errno.h>
#include <unistd.h>
details. */
#include "winsup.h"
-#include <sys/fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
return success;
}
+void
+fhandler_base::set_flags (int flags, int supplied_bin)
+{
+ int bin;
+ int fmode;
+ debug_printf ("flags %p, supplied_bin %p", flags, supplied_bin);
+ if ((bin = flags & (O_BINARY | O_TEXT)))
+ debug_printf ("O_TEXT/O_BINARY set in flags %p", bin);
+ else if (get_r_binset () && get_w_binset ())
+ bin = get_r_binary () ? O_BINARY : O_TEXT; // FIXME: Not quite right
+ else if (supplied_bin)
+ bin = supplied_bin;
+ else if ((fmode = get_default_fmode (flags)) & O_BINARY)
+ bin = O_BINARY;
+ else if (fmode & O_TEXT)
+ bin = O_TEXT;
+ else
+ bin = get_w_binary () || get_r_binary () || (binmode != O_TEXT) ?
+ O_BINARY : O_TEXT;
+
+ openflags = flags | bin;
+
+ set_r_binary (bin & O_BINARY);
+ set_w_binary (bin & O_BINARY);
+ syscall_printf ("filemode set to %s", bin ? "binary" : "text");
+}
+
int
fhandler_base::put_readahead (char value)
{
/* CreateFile() with dwDesiredAccess == 0 when called on remote
share returns some handle, even if file doesn't exist. This code
works around this bug. */
- if (get_query_open () &&
- isremote () &&
- creation_distribution == OPEN_EXISTING &&
- !pc->exists ())
+ if (get_query_open () && isremote () &&
+ creation_distribution == OPEN_EXISTING && pc && !pc->exists ())
{
set_errno (ENOENT);
goto done;
set_file_attribute (has_acls (), get_win32_name (), mode);
set_io_handle (x);
- if (get_w_binset () && get_r_binset ())
- syscall_printf ("filemode already set to %d/%d", get_r_binary (), get_w_binary ());
- else
- {
- int bin;
- int fmode;
- if ((bin = flags & (O_BINARY | O_TEXT)))
- /* nothing to do */;
- else if ((fmode = get_default_fmode (flags)) & O_BINARY)
- bin = O_BINARY;
- else if (fmode & O_TEXT)
- bin = O_TEXT;
- else
- bin = get_w_binary () || get_r_binary () || (binmode != O_TEXT);
-
- if (bin & O_TEXT)
- bin = 0;
-
- set_flags (flags | (bin ? O_BINARY : O_TEXT));
-
- set_r_binary (bin);
- set_w_binary (bin);
- syscall_printf ("filemode set to %s", bin ? "binary" : "text");
- }
+ set_flags (flags, pc ? pc->binmode () : 0);
res = 1;
set_open_status ();
fhandler_base::init (HANDLE f, DWORD a, mode_t bin)
{
set_io_handle (f);
- set_r_binary (bin);
- set_w_binary (bin);
access = a;
a &= GENERIC_READ | GENERIC_WRITE;
- int oflags = 0;
+ int flags = 0;
if (a == GENERIC_READ)
- oflags = O_RDONLY;
+ flags = O_RDONLY;
else if (a == GENERIC_WRITE)
- oflags = O_WRONLY;
+ flags = O_WRONLY;
else if (a == (GENERIC_READ | GENERIC_WRITE))
- oflags = O_RDWR;
- set_flags (oflags | (bin ? O_BINARY : O_TEXT));
+ flags = O_RDWR;
+ set_flags (flags, bin);
set_open_status ();
debug_printf ("created new fhandler_base for handle %p, bin %d", f, get_r_binary ());
}
#define _FHANDLER_H_
#include <sys/ioctl.h>
+#include <fcntl.h>
enum
{
void set_async (int x) { FHCONDSETF (x, ASYNC); }
int get_flags () { return openflags; }
- void set_flags (int x) { openflags = x; }
+ void set_flags (int x, int supplied_bin = 0);
bool is_nonblocking ();
void set_nonblocking (int yes);
DWORD get_open_status () {return open_status;}
void reset_to_open_binmode ()
{
- status = status & ~(FH_WBINARY | FH_WBINSET | FH_RBINARY | FH_RBINSET);
- status = status | ((FH_WBINARY | FH_WBINSET | FH_RBINARY | FH_RBINSET)
- & open_status);
+ set_flags ((get_flags () & ~(O_TEXT | O_BINARY))
+ | ((open_status & (FH_WBINARY | FH_RBINARY)
+ ? O_BINARY : O_TEXT)));
}
int get_default_fmode (int flags);
int
fhandler_dev_clipboard::open (path_conv *, int flags, mode_t)
{
- set_flags (flags);
+ set_flags (flags, O_TEXT);
eof = false;
pos = 0;
if (membuffer)
#include <sys/termios.h>
#include <stdio.h>
#include <stdlib.h>
-#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <wingdi.h>
set_io_handle (INVALID_HANDLE_VALUE);
set_output_handle (INVALID_HANDLE_VALUE);
- set_flags (flags);
- set_w_binary (1);
- set_r_binary (1);
+ set_flags (flags & ~O_TEXT, O_BINARY);
/* Open the input handle as handle_ */
h = CreateFileA ("CONIN$", GENERIC_READ|GENERIC_WRITE,
void
fhandler_console::init (HANDLE f, DWORD a, mode_t bin)
{
- this->fhandler_termios::init (f, a, bin);
-
+ // this->fhandler_termios::init (f, mode, bin);
/* Ensure both input and output console handles are open */
- int mode = 0;
+ int flags = 0;
a &= GENERIC_READ | GENERIC_WRITE;
if (a == GENERIC_READ)
- mode = O_RDONLY;
+ flags = O_RDONLY;
if (a == GENERIC_WRITE)
- mode = O_WRONLY;
+ flags = O_WRONLY;
if (a == (GENERIC_READ | GENERIC_WRITE))
- mode = O_RDWR;
- open ((path_conv *) NULL, mode);
+ flags = O_RDWR;
+ open ((path_conv *) NULL, flags | O_BINARY);
if (f != INVALID_HANDLE_VALUE)
CloseHandle (f); /* Reopened by open */
details. */
#include "winsup.h"
-#include <sys/fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
return 0;
}
- set_r_binary (real_path->isbinary ());
- set_w_binary (real_path->isbinary ());
-
set_has_acls (real_path->has_acls ());
set_isremote (real_path->isremote ());
#include <errno.h>
#include <windows.h>
#include <sys/soundcard.h>
-#include <sys/fcntl.h>
#include <mmsystem.h>
#include "cygerrno.h"
#include "security.h"
return 0;
}
- set_flags (flags);
+ set_flags (flags & ~O_TEXT, O_BINARY);
if (!s_audio)
s_audio = new (audio_buf) Audio;
audiobits_ = 8;
audiochannels_ = 1;
+ int res;
if (!s_audio->open (audiofreq_, audiobits_, audiochannels_))
- debug_printf ("/dev/dsp: failed to open\n");
+ res = 0;
else
{
set_open_status ();
- debug_printf ("/dev/dsp: successfully opened\n");
+ res = 1;
}
- return 1;
+
+ debug_printf ("returns %d", res);
+ return res;
}
int
#include "winsup.h"
#include <sys/termios.h>
-#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <winioctl.h>
details. */
#include "winsup.h"
-#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <sys/mman.h>
details. */
#include "winsup.h"
-#include <sys/fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
success:
res = 1;
+ set_flags (flags & ~O_TEXT, O_BINARY);
set_open_status ();
- set_flags (flags);
out:
syscall_printf ("%d = fhandler_proc::open (%p, %d)", res, flags, mode);
return res;
details. */
#include "winsup.h"
-#include <sys/fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
success:
res = 1;
+ set_flags (flags & ~O_TEXT, O_BINARY);
set_open_status ();
- set_flags (flags);
out:
syscall_printf ("%d = fhandler_proc::open (%p, %d)", res, flags, mode);
return res;
int
fhandler_dev_random::open (path_conv *, int flags, mode_t)
{
- set_flags (flags);
+ set_flags (flags & ~O_TEXT, O_BINARY);
set_open_status ();
return 1;
}
#include "winsup.h"
#include <sys/termios.h>
-#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
}
set_io_handle (h);
- set_flags (flags);
- set_r_binary (O_BINARY);
- set_w_binary (O_BINARY);
+ set_flags (flags & ~O_TEXT, O_BINARY);
if (devbufsiz > 1L)
devbuf = new char [devbufsiz];
/* FIXME: Access permissions are ignored at the moment. */
#include "winsup.h"
-#include <sys/fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
success:
res = 1;
+ set_flags (flags & ~O_TEXT, O_BINARY);
set_open_status ();
- set_flags (flags);
out:
if (hKey != (HKEY) INVALID_HANDLE_VALUE)
RegCloseKey (hKey);
details. */
#include "winsup.h"
-#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
void
fhandler_serial::init (HANDLE f, DWORD flags, mode_t bin)
{
- fhandler_base::init (f, flags, bin);
- (void) open (NULL, flags, bin ? O_BINARY : 0);
+ (void) open (NULL, flags, bin & (O_BINARY | O_TEXT));
}
int
#include <stdlib.h>
#include <unistd.h>
-#include <fcntl.h>
#define USE_SYS_TYPES_FD_SET
#include <winsock2.h>
#include "cygerrno.h"
#include "winsup.h"
#include <sys/termios.h>
-#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <sys/mtio.h>
#include "winsup.h"
#include <sys/termios.h>
#include <stdlib.h>
-#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
#include "winsup.h"
#include <stdio.h>
-#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
attach_tty (ttynum);
tc->set_ctty (ttynum, flags);
- set_flags (flags);
+ set_flags (flags & ~O_TEXT, O_BINARY);
/* Create synchronisation events */
char buf[40];
cygwin_shared->tty[ttynum]->common_init (this);
inuse = get_ttyp ()->create_inuse (TTY_MASTER_ALIVE);
- set_flags (flags);
+ set_flags (flags & ~O_TEXT, O_BINARY);
set_open_status ();
termios_printf ("opened pty master tty%d<%p>", ttynum, this);
details. */
#include "winsup.h"
-#include <sys/fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
set_execable_p (not_executable);
set_socket_p (false);
- set_flags (flags);
+ set_flags (flags & ~O_TEXT, O_BINARY);
set_nohandle (true);
int
fhandler_windows::open (path_conv *, int flags, mode_t)
{
- set_flags (flags);
+ set_flags (flags & ~O_TEXT, O_BINARY);
set_close_on_exec_flag (1);
set_open_status ();
return 1;
int
fhandler_dev_zero::open (path_conv *, int flags, mode_t)
{
- set_flags (flags);
+ set_flags (flags & ~O_TEXT, O_BINARY);
set_open_status ();
return 1;
}
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
-#include <fcntl.h>
#include <stdarg.h>
#include <errno.h>
#include "security.h"
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
-#include <fcntl.h>
#define USE_SYS_TYPES_FD_SET
#include <winsock2.h>
#include "cygerrno.h"
debug_printf ("not setting socket inheritance since winsock2_active %d", winsock2_active);
fhandler_socket *fh = (fhandler_socket *) cygheap->fdtab.build_fhandler (fd, FH_SOCKET, name);
fh->set_io_handle ((HANDLE) soc);
- fh->set_flags (O_RDWR);
+ fh->set_flags (O_RDWR, O_BINARY);
debug_printf ("fd %d, name '%s', soc %p", fd, name, soc);
return fh;
}
#include <stdlib.h>
#include <sys/mount.h>
#include <mntent.h>
-#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
if (saw_symlinks)
set_has_symlinks ();
- if (!error && !(path_flags & PATH_ALL_EXEC))
+ if (!error && !isdir () && !(path_flags & PATH_ALL_EXEC))
{
const char *p = strchr (path, '\0') - 4;
if (p >= path &&
from_registry ();
}
+static void
+set_flags (unsigned *flags, unsigned val)
+{
+ *flags = val;
+ if (!(*flags & PATH_BINARY))
+ *flags = PATH_TEXT;
+}
+
/* conv_to_win32_path: Ensure src_path is a pure Win32 path and store
the result in win32_path.
return rc;
}
- *flags = set_flags_from_win32_path (dst);
+ set_flags (flags, (unsigned) set_flags_from_win32_path (dst));
goto out;
}
if (rc)
{
debug_printf ("%d = conv_to_win32_path (%s)", rc, src_path);
- *flags = 0;
return rc;
}
}
}
else if (cygdrive_win32_path (pathbuf, dst, unit))
{
- *flags = cygdrive_flags;
+ set_flags (flags, (unsigned) cygdrive_flags);
goto out;
}
else if (mount_table->cygdrive_len > 1)
}
if (i >= nmounts)
- {
- backslashify (pathbuf, dst, 0); /* just convert */
- *flags = PATH_BINARY; /* Default to binmode */
- }
+ backslashify (pathbuf, dst, 0); /* just convert */
else
{
int n;
dst[n++] = '\\';
strcpy (dst + n, p);
backslashify (dst, dst, 0);
- *flags = mi->flags;
+ set_flags (flags, (unsigned) mi->flags);
}
if (!isvirtual_dev (devn))
PATH_NOTEXEC = MOUNT_NOTEXEC,
PATH_CYGWIN_EXEC = MOUNT_CYGWIN_EXEC,
PATH_ALL_EXEC = (PATH_CYGWIN_EXEC | PATH_EXEC),
+ PATH_TEXT = 0x02000000,
PATH_ISDISK = 0x04000000,
PATH_HAS_SYMLINKS = 0x10000000,
PATH_HASBUGGYOPEN = 0x20000000,
int has_symlinks () const {return path_flags & PATH_HAS_SYMLINKS;}
int hasgood_inode () const {return path_flags & PATH_HASACLS;} // Not strictly correct
int has_buggy_open () const {return path_flags & PATH_HASBUGGYOPEN;}
- int isbinary () const {return path_flags & PATH_BINARY;}
+ int binmode () const
+ {
+ if (path_flags & PATH_BINARY)
+ return O_BINARY;
+ if (path_flags & PATH_TEXT)
+ return O_TEXT;
+ return 0;
+ }
int issymlink () const {return path_flags & PATH_SYMLINK;}
int issocket () const {return path_flags & PATH_SOCKET;}
int iscygexec () const {return path_flags & PATH_CYGWIN_EXEC;}
#include "winsup.h"
#include <unistd.h>
-#include <sys/fcntl.h>
#include <errno.h>
#include "cygerrno.h"
#include "security.h"
fhandler_pipe *fhr = (fhandler_pipe *) cygheap->fdtab.build_fhandler (fdr, FH_PIPER, "/dev/piper");
fhandler_pipe *fhw = (fhandler_pipe *) cygheap->fdtab.build_fhandler (fdw, FH_PIPEW, "/dev/pipew");
- int binmode = mode & O_TEXT ? 0 : 1;
+ int binmode = mode & O_TEXT ?: O_BINARY;
fhr->init (r, GENERIC_READ, binmode);
fhw->init (w, GENERIC_WRITE, binmode);
if (mode & O_NOINHERIT)
#include "winsup.h"
#include <sys/stat.h>
#include <sys/vfs.h> /* needed for statfs */
-#include <fcntl.h>
#include <pwd.h>
#include <grp.h>
#include <stdlib.h>
if (fileno (f) != setmode_file)
return 0;
syscall_printf ("setmode: file was %s now %s\n",
- f->_flags & __SCLE ? "cle" : "raw",
- setmode_mode & O_TEXT ? "cle" : "raw");
+ f->_flags & __SCLE ? "text" : "raw",
+ setmode_mode & O_TEXT ? "text" : "raw");
if (setmode_mode & O_TEXT)
f->_flags |= __SCLE;
else
if (!mode)
cfd->reset_to_open_binmode ();
- else if (mode & O_BINARY)
- {
- cfd->set_w_binary (1);
- cfd->set_r_binary (1);
- }
else
- {
- cfd->set_w_binary (0);
- cfd->set_r_binary (0);
- }
+ cfd->set_flags ((cfd->get_flags () & ~(O_TEXT | O_BINARY)) | mode);
if (_cygwin_istext_for_stdio (fd))
setmode_mode = O_TEXT;
setmode_file = fd;
_fwalk (_REENT, setmode_helper);
- syscall_printf ("setmode (%d<%s>, %s) returns %s\n", fd, cfd->get_name (),
- mode & O_TEXT ? "text" : "binary",
- res & O_TEXT ? "text" : "binary");
+ syscall_printf ("setmode (%d<%s>, %p) returns %s\n", fd, cfd->get_name (),
+ mode, res & O_TEXT ? "text" : "binary");
return res;
}