1 /* ioctl.cc: ioctl routines.
3 Written by Doug Evans of Cygnus Support
6 This file is part of Cygwin.
8 This software is a copyrighted work licensed under the terms of the
9 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
20 ioctl (int fd
, int cmd
, ...)
23 cygheap_fdget
cfd (fd
);
27 /* check for optional mode argument */
30 char *argp
= va_arg (ap
, char *);
33 debug_printf ("ioctl(fd %d, cmd %y)", fd
, cmd
);
35 if (cfd
->get_flags () & O_PATH
)
40 /* FIXME: This stinks. There are collisions between cmd types
41 depending on whether fd is associated with a pty master or not.
42 Something to fix for Cygwin2. CGF 2006-06-04 */
43 if (cfd
->is_tty () && cfd
->get_major () != DEV_PTYM_MAJOR
)
47 res
= tcgetattr (fd
, (struct termios
*) argp
);
50 res
= tcsetattr (fd
, TCSANOW
, (struct termios
*) argp
);
53 res
= tcsetattr (fd
, TCSADRAIN
, (struct termios
*) argp
);
56 res
= tcsetattr (fd
, TCSAFLUSH
, (struct termios
*) argp
);
60 res
= cfd
->ioctl (cmd
, argp
);
63 syscall_printf ("%R = ioctl(%d, %y, ...)", res
, fd
, cmd
);