]> sourceware.org Git - newlib-cygwin.git/blame - winsup/cygwin/ioctl.cc
Cygwin: add release message for latest pipe changes
[newlib-cygwin.git] / winsup / cygwin / ioctl.cc
CommitLineData
1fd5e000
CF
1/* ioctl.cc: ioctl routines.
2
1fd5e000
CF
3 Written by Doug Evans of Cygnus Support
4 dje@cygnus.com
5
6This file is part of Cygwin.
7
8This software is a copyrighted work licensed under the terms of the
9Cygwin license. Please consult the file "CYGWIN_LICENSE" for
10details. */
11
4c8d72de 12#include "winsup.h"
9e2baf8d 13#include "cygerrno.h"
47063f00 14#include "path.h"
7ac61736 15#include "fhandler.h"
bccd5e0d 16#include "dtable.h"
0381fec6 17#include "cygheap.h"
1fd5e000 18
bccd5e0d 19extern "C" int
d6154fb7 20ioctl (int fd, int cmd, ...)
1fd5e000 21{
0a642325 22
df63bd49
CF
23 cygheap_fdget cfd (fd);
24 if (cfd < 0)
25 return -1;
1fd5e000 26
d6154fb7
CV
27 /* check for optional mode argument */
28 va_list ap;
29 va_start (ap, cmd);
30 char *argp = va_arg (ap, char *);
31 va_end (ap);
32
61522196 33 debug_printf ("ioctl(fd %d, cmd %y)", fd, cmd);
a2dea5c3 34 int res;
b93022a8
CV
35 if (cfd->get_flags () & O_PATH)
36 {
37 set_errno (EBADF);
38 return -1;
39 }
c0ac34fd
CF
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 */
38d732a1 43 if (cfd->is_tty () && cfd->get_major () != DEV_PTYM_MAJOR)
1fd5e000
CF
44 switch (cmd)
45 {
46 case TCGETA:
a2dea5c3
CF
47 res = tcgetattr (fd, (struct termios *) argp);
48 goto out;
1fd5e000 49 case TCSETA:
a2dea5c3
CF
50 res = tcsetattr (fd, TCSANOW, (struct termios *) argp);
51 goto out;
1fd5e000 52 case TCSETAW:
a2dea5c3
CF
53 res = tcsetattr (fd, TCSADRAIN, (struct termios *) argp);
54 goto out;
1fd5e000 55 case TCSETAF:
a2dea5c3
CF
56 res = tcsetattr (fd, TCSAFLUSH, (struct termios *) argp);
57 goto out;
1fd5e000
CF
58 }
59
a2dea5c3
CF
60 res = cfd->ioctl (cmd, argp);
61
62out:
61522196 63 syscall_printf ("%R = ioctl(%d, %y, ...)", res, fd, cmd);
b6183403 64 return res;
1fd5e000 65}
This page took 0.556428 seconds and 6 git commands to generate.