]> sourceware.org Git - newlib-cygwin.git/blame - winsup/cygwin/ioctl.cc
* Merge in cygwin-64bit-branch.
[newlib-cygwin.git] / winsup / cygwin / ioctl.cc
CommitLineData
1fd5e000
CF
1/* ioctl.cc: ioctl routines.
2
61522196
CV
3 Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2008, 2009, 2011,
4 2012 Red Hat, Inc.
1fd5e000
CF
5
6 Written by Doug Evans of Cygnus Support
7 dje@cygnus.com
8
9This file is part of Cygwin.
10
11This software is a copyrighted work licensed under the terms of the
12Cygwin license. Please consult the file "CYGWIN_LICENSE" for
13details. */
14
4c8d72de 15#include "winsup.h"
9e2baf8d 16#include "cygerrno.h"
47063f00 17#include "path.h"
7ac61736 18#include "fhandler.h"
bccd5e0d 19#include "dtable.h"
0381fec6 20#include "cygheap.h"
1fd5e000 21
bccd5e0d 22extern "C" int
d6154fb7 23ioctl (int fd, int cmd, ...)
1fd5e000 24{
0a642325 25
df63bd49
CF
26 cygheap_fdget cfd (fd);
27 if (cfd < 0)
28 return -1;
1fd5e000 29
d6154fb7
CV
30 /* check for optional mode argument */
31 va_list ap;
32 va_start (ap, cmd);
33 char *argp = va_arg (ap, char *);
34 va_end (ap);
35
61522196 36 debug_printf ("ioctl(fd %d, cmd %y)", fd, cmd);
a2dea5c3 37 int res;
c0ac34fd
CF
38 /* FIXME: This stinks. There are collisions between cmd types
39 depending on whether fd is associated with a pty master or not.
40 Something to fix for Cygwin2. CGF 2006-06-04 */
38d732a1 41 if (cfd->is_tty () && cfd->get_major () != DEV_PTYM_MAJOR)
1fd5e000
CF
42 switch (cmd)
43 {
44 case TCGETA:
a2dea5c3
CF
45 res = tcgetattr (fd, (struct termios *) argp);
46 goto out;
1fd5e000 47 case TCSETA:
a2dea5c3
CF
48 res = tcsetattr (fd, TCSANOW, (struct termios *) argp);
49 goto out;
1fd5e000 50 case TCSETAW:
a2dea5c3
CF
51 res = tcsetattr (fd, TCSADRAIN, (struct termios *) argp);
52 goto out;
1fd5e000 53 case TCSETAF:
a2dea5c3
CF
54 res = tcsetattr (fd, TCSAFLUSH, (struct termios *) argp);
55 goto out;
1fd5e000
CF
56 }
57
a2dea5c3
CF
58 res = cfd->ioctl (cmd, argp);
59
60out:
61522196 61 syscall_printf ("%R = ioctl(%d, %y, ...)", res, fd, cmd);
b6183403 62 return res;
1fd5e000 63}
This page took 0.370778 seconds and 5 git commands to generate.