this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ioctl() translation (work in progress)

+564
+79
src/kernel/emulation/linux/ioctl/ioctl.c
··· 1 + #include "ioctl.h" 2 + #include "../unistd/readlink.h" 3 + #include "../../../../../platform-include/sys/errno.h" 4 + #include <stddef.h> 5 + #include <stdbool.h> 6 + #include "termios.h" 7 + 8 + #define D_TAPE 1 9 + #define D_DISK 2 10 + #define D_TTY 3 11 + 12 + #define IOCTL_STEP(x) { int state, retval; state = (x); \ 13 + if (state == IOCTL_HANDLED) return retval; } 14 + 15 + static int handle_filio(int fd, int cmd, void* arg, int* retval); 16 + 17 + // Emulated ioctl implementation 18 + long ioctl(int fd, int cmd, void* arg) 19 + { 20 + IOCTL_STEP(handle_filio(fd, cmd, arg, &retval)); 21 + IOCTL_STEP(handle_termios(fd, cmd, arg, &retval)); 22 + 23 + run_ioctl: 24 + return __real_ioctl(fd, cmd, arg); 25 + } 26 + 27 + extern int sprintf(char* buf, const char* fmt, ...); 28 + extern int strncmp(const char *, const char *, unsigned long); 29 + static bool get_fd_path(int fd, char* buf, size_t len) 30 + { 31 + char proc[32]; 32 + int ret; 33 + 34 + sprintf(proc, "/proc/self/%d", fd); 35 + ret = sys_readlink(proc, buf, len-1); 36 + 37 + if (ret <= 0) 38 + return false; 39 + 40 + buf[ret] = 0; 41 + return true; 42 + } 43 + 44 + static int handle_filio(int fd, int cmd, void* arg, int* retval) 45 + { 46 + switch (cmd) 47 + { 48 + case BSD_FIODTYPE: 49 + { 50 + char orig_path[256]; 51 + 52 + if (!get_fd_path(fd, orig_path, sizeof(orig_path))) 53 + { 54 + *retval = -EBADF; 55 + return IOCTL_HANDLED; 56 + } 57 + 58 + if (strncmp(orig_path, "/dev/pts", 8) == 0 59 + || strncmp(orig_path, "/dev/tty", 8) == 0) 60 + { 61 + *retval = D_TTY; 62 + } 63 + else if (strncmp(orig_path, "/dev/st", 7) == 0 64 + || strncmp(orig_path, "/dev/nst", 8) == 0) 65 + { 66 + *retval = D_TAPE; 67 + } 68 + else 69 + { 70 + *retval = D_DISK; 71 + } 72 + return IOCTL_HANDLED; 73 + } 74 + default: 75 + return IOCTL_PASS; 76 + } 77 + } 78 + 79 +
+44
src/kernel/emulation/linux/ioctl/ioctl.h
··· 1 + #ifndef EMU_IOCTL_H 2 + #define EMU_IOCTL_H 3 + #include <stdint.h> 4 + 5 + extern long __real_ioctl(int fd, int cmd, void* arg); 6 + 7 + enum { 8 + IOCTL_PASS, /** ioctl cmd not known */ 9 + IOCTL_HANDLED /** ioctl cmd now already handled */ 10 + }; 11 + 12 + 13 + #define BSD_IOCPARM_MASK 0x1fff 14 + #define BSD_IOCPARM_LEN(x) (((x) >> 16) & BSD_IOCPARM_MASK) 15 + #define BSD_IOCBASECMD(x) ((x) & ~(IBSD_OCPARM_MASK << 16)) 16 + #define BSD_IOCGROUP(x) (((x) >> 8) & 0xff) 17 + 18 + #define BSD_IOCPARM_MAX (BSD_IOCPARM_MASK + 1) 19 + #define BSD_IOC_VOID (uint32_t)0x20000000 20 + #define BSD_IOC_OUT (uint32_t)0x40000000 21 + #define BSD_IOC_IN (uint32_t)0x80000000 22 + #define BSD_IOC_INOUT (BSD_IOC_IN|BSD_IOC_OUT) 23 + #define BSD_IOC_DIRMASK (uint32_t)0xe0000000 24 + 25 + #define BSD_IOC(inout,group,num,len) \ 26 + (inout | ((len & BSD_IOCPARM_MASK) << 16) | ((group) << 8) | (num)) 27 + #define BSD_IO(g,n) BSD_IOC(BSD_IOC_VOID, (g), (n), 0) 28 + #define BSD_IOR(g,n,t) BSD_IOC(BSD_IOC_OUT, (g), (n), sizeof(t)) 29 + #define BSD_IOW(g,n,t) BSD_IOC(BSD_IOC_IN, (g), (n), sizeof(t)) 30 + #define BSD_IOWR(g,n,t) BSD_IOC(BSD_IOC_INOUT, (g), (n), sizeof(t)) 31 + 32 + 33 + #define BSD_FIOCLEX BSD_IO('f', 1) 34 + #define BSD_FIONCLEX BSD_IO('f', 2) 35 + #define BSD_FIONREAD BSD_IOR('f', 127, int) 36 + #define BSD_FIONBIO BSD_IOW('f', 126, int) 37 + #define BSD_FIOASYNC BSD_IOW('f', 125, int) 38 + #define BSD_FIOSETOWN BSD_IOW('f', 124, int) 39 + #define BSD_FIOGETOWN BSD_IOR('f', 123, int) 40 + #define BSD_FIODTYPE BSD_IOR('f', 122, int) 41 + 42 + 43 + #endif 44 +
+176
src/kernel/emulation/linux/ioctl/termios.c
··· 1 + #include "termios.h" 2 + #include "../../../../../platform-include/sys/errno.h" 3 + #include <stddef.h> 4 + #include <stdint.h> 5 + #include <stdbool.h> 6 + 7 + // Speeds are stored in cflags 8 + // http://osxr.org/glibc/source/sysdeps/unix/sysv/linux/speed.c?v=glibc-2.13 9 + 10 + extern void *memset(void *s, int c, size_t n); 11 + static void cc_linux_to_bsd(const unsigned char* l, unsigned char* b); 12 + static void cc_bsd_to_linux(const unsigned char* b, unsigned char* l); 13 + static void iflag_linux_to_bsd(unsigned int l, unsigned long* b); 14 + static void iflag_bsd_to_linux(unsigned long b, unsigned int* l); 15 + 16 + int handle_termios(int fd, int cmd, void* arg, int* retval) 17 + { 18 + switch (cmd) 19 + { 20 + case BSD_TIOCGETA: 21 + { 22 + struct bsd_termios* out = (struct bsd_termios*) arg; 23 + struct linux_termios in; 24 + 25 + *retval = __real_ioctl(fd, LINUX_TCGETS, &in); 26 + 27 + // TODO: translate termios 28 + memset(out, 0, sizeof(*out)); 29 + cc_linux_to_bsd(in.c_cc, out->c_cc); 30 + iflag_linux_to_bsd(in.c_iflag, &out->c_iflag); 31 + 32 + return IOCTL_HANDLED; 33 + } 34 + case BSD_TIOCSETA: 35 + case BSD_TIOCSETAW: 36 + case BSD_TIOCSETAF: 37 + { 38 + const struct bsd_termios* in = (struct bsd_termios*) arg; 39 + struct linux_termios out; 40 + int op; 41 + 42 + if (cmd == BSD_TIOCSETA) 43 + op = LINUX_TCSETS; 44 + else if (cmd == BSD_TIOCSETAW) 45 + op = LINUX_TCSETSW; 46 + else 47 + op = LINUX_TCSETSF; 48 + 49 + // TODO: translate termios 50 + memset(&out, 0, sizeof(out)); 51 + cc_bsd_to_linux(in->c_cc, out.c_cc); 52 + iflag_bsd_to_linux(in->c_iflag, &out.c_iflag); 53 + 54 + *retval = __real_ioctl(fd, op, &out); 55 + 56 + return IOCTL_HANDLED; 57 + } 58 + case BSD_TIOCGWINSZ: 59 + { 60 + *retval = __real_ioctl(fd, LINUX_TIOCGWINSZ, arg); 61 + return IOCTL_HANDLED; 62 + } 63 + case BSD_TIOCSWINSZ: 64 + { 65 + *retval = __real_ioctl(fd, LINUX_TIOCSWINSZ, arg); 66 + return IOCTL_HANDLED; 67 + } 68 + default: 69 + return IOCTL_PASS; 70 + } 71 + } 72 + 73 + static void cc_linux_to_bsd(const unsigned char* l, unsigned char* b) 74 + { 75 + b[BSD_VEOF] = l[LINUX_VEOF]; 76 + b[BSD_VEOL] = l[LINUX_VEOL]; 77 + b[BSD_VEOL2] = l[LINUX_VEOL2]; 78 + b[BSD_VERASE] = l[LINUX_VERASE]; 79 + b[BSD_VWERASE] = l[LINUX_VWERASE]; 80 + b[BSD_VKILL] = l[LINUX_VKILL]; 81 + b[BSD_VREPRINT] = l[LINUX_VREPRINT]; 82 + b[BSD_VINTR] = l[LINUX_VINTR]; 83 + b[BSD_VQUIT] = l[LINUX_VQUIT]; 84 + b[BSD_VSUSP] = l[LINUX_VSUSP]; 85 + b[BSD_VSTART] = l[LINUX_VSTART]; 86 + b[BSD_VSTOP] = l[LINUX_VSTOP]; 87 + b[BSD_VLNEXT] = l[LINUX_VLNEXT]; 88 + b[BSD_VDISCARD] = l[LINUX_VDISCARD]; 89 + b[BSD_VMIN] = l[LINUX_VMIN]; 90 + b[BSD_VTIME] = l[LINUX_VTIME]; 91 + } 92 + 93 + static void cc_bsd_to_linux(const unsigned char* b, unsigned char* l) 94 + { 95 + l[LINUX_VEOF] = b[BSD_VEOF]; 96 + l[LINUX_VEOL] = b[BSD_VEOL]; 97 + l[LINUX_VEOL2] = b[BSD_VEOL2]; 98 + l[LINUX_VERASE] = b[BSD_VERASE]; 99 + l[LINUX_VWERASE] = b[BSD_VWERASE]; 100 + l[LINUX_VKILL] = b[BSD_VKILL]; 101 + l[LINUX_VREPRINT] = b[BSD_VREPRINT]; 102 + l[LINUX_VINTR] = b[BSD_VINTR]; 103 + l[LINUX_VQUIT] = b[BSD_VQUIT]; 104 + l[LINUX_VSUSP] = b[BSD_VSUSP]; 105 + l[LINUX_VSTART] = b[BSD_VSTART]; 106 + l[LINUX_VSTOP] = b[BSD_VSTOP]; 107 + l[LINUX_VLNEXT] = b[BSD_VLNEXT]; 108 + l[LINUX_VDISCARD] = b[BSD_VDISCARD]; 109 + l[LINUX_VMIN] = b[BSD_VMIN]; 110 + l[LINUX_VTIME] = b[BSD_VTIME]; 111 + } 112 + 113 + static void iflag_linux_to_bsd(unsigned int l, unsigned long* b) 114 + { 115 + if (l & LINUX_IGNBRK) 116 + *b |= BSD_IGNBRK; 117 + if (l & LINUX_BRKINT) 118 + *b |= BSD_BRKINT; 119 + if (l & LINUX_IGNPAR) 120 + *b |= BSD_IGNPAR; 121 + if (l & LINUX_PARMRK) 122 + *b |= BSD_PARMRK; 123 + if (l & LINUX_INPCK) 124 + *b |= BSD_INPCK; 125 + if (l & LINUX_ISTRIP) 126 + *b |= BSD_ISTRIP; 127 + if (l & LINUX_INLCR) 128 + *b |= BSD_INLCR; 129 + if (l & LINUX_IGNCR) 130 + *b |= BSD_IGNCR; 131 + if (l & LINUX_ICRNL) 132 + *b |= BSD_ICRNL; 133 + if (l & LINUX_IXON) 134 + *b |= BSD_IXON; 135 + if (l & LINUX_IXANY) 136 + *b |= BSD_IXANY; 137 + if (l & LINUX_IXOFF) 138 + *b |= BSD_IXOFF; 139 + if (l & LINUX_IMAXBEL) 140 + *b |= BSD_IMAXBEL; 141 + if (l & LINUX_IUTF8) 142 + *b |= BSD_IUTF8; 143 + } 144 + 145 + static void iflag_bsd_to_linux(unsigned long b, unsigned int* l) 146 + { 147 + if (b & BSD_IGNBRK) 148 + *l |= LINUX_IGNBRK; 149 + if (b & BSD_BRKINT) 150 + *l |= LINUX_BRKINT; 151 + if (b & BSD_IGNPAR) 152 + *l |= LINUX_IGNPAR; 153 + if (b & BSD_PARMRK) 154 + *l |= LINUX_PARMRK; 155 + if (b & BSD_INPCK) 156 + *l |= LINUX_INPCK; 157 + if (b & BSD_ISTRIP) 158 + *l |= LINUX_ISTRIP; 159 + if (b & BSD_INLCR) 160 + *l |= LINUX_INLCR; 161 + if (b & BSD_IGNCR) 162 + *l |= LINUX_IGNCR; 163 + if (b & BSD_ICRNL) 164 + *l |= LINUX_ICRNL; 165 + if (b & BSD_IXON) 166 + *l |= LINUX_IXON; 167 + if (b & BSD_IXOFF) 168 + *l |= LINUX_IXOFF; 169 + if (b & BSD_IXANY) 170 + *l |= LINUX_IXANY; 171 + if (b & BSD_IMAXBEL) 172 + *l |= LINUX_IMAXBEL; 173 + if (b & BSD_IUTF8) 174 + *l |= LINUX_IUTF8; 175 + } 176 +
+265
src/kernel/emulation/linux/ioctl/termios.h
··· 1 + #ifndef EMU_TERMIOS_H 2 + #define EMU_TERMIOS_H 3 + #include "ioctl.h" 4 + 5 + int handle_termios(int fd, int cmd, void* arg, int* retval); 6 + 7 + struct bsd_winsize 8 + { 9 + unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; 10 + }; 11 + 12 + struct bsd_termios 13 + { 14 + unsigned long c_iflag; 15 + unsigned long c_oflag; 16 + unsigned long c_cflag; 17 + unsigned long c_lflag; 18 + unsigned char c_cc[20]; 19 + unsigned long c_ispeed; 20 + unsigned long c_ospeed; 21 + }; 22 + struct linux_termios 23 + { 24 + unsigned int c_iflag; 25 + unsigned int c_oflag; 26 + unsigned int c_cflag; 27 + unsigned int c_lflag; 28 + unsigned char c_cc[32]; 29 + unsigned int c_ispeed; 30 + unsigned int c_ospeed; 31 + }; 32 + 33 + // c_cc indices 34 + enum { 35 + BSD_VEOF, BSD_VEOL, BSD_VEOL2, BSD_VERASE, BSD_VWERASE, BSD_VKILL, 36 + BSD_VREPRINT, BSD_VINTR, BSD_VQUIT, BSD_VSUSP, BSD_VDSUSP, BSD_VSTART, 37 + BSD_VSTOP, BSD_VLNEXT, BSD_VDISCARD, BSD_VMIN, BSD_VTIME, BSD_VSTATUS, 38 + }; 39 + enum { 40 + LINUX_VINTR, LINUX_VQUIT, LINUX_VERASE, LINUX_VKILL, LINUX_VEOF, 41 + LINUX_VTIME, LINUX_VMIN, LINUX_VSWTC, LINUX_VSTART, LINUX_VSTOP, 42 + LINUX_VSUSP, LINUX_VEOL, LINUX_VREPRINT, LINUX_VDISCARD, LINUX_VWERASE, 43 + LINUX_VLNEXT, LINUX_VEOL2 44 + }; 45 + 46 + #define BSD_TIOCMODG BSD_IOR('t', 3, int) 47 + #define BSD_TIOCMODS BSD_IOW('t', 4, int) 48 + #define BSD_TIOCM_LE 0001 49 + #define BSD_TIOCM_DTR 0002 50 + #define BSD_TIOCM_RTS 0004 51 + #define BSD_TIOCM_ST 0010 52 + #define BSD_TIOCM_SR 0020 53 + #define BSD_TIOCM_CTS 0040 54 + #define BSD_TIOCM_CAR 0100 55 + #define BSD_TIOCM_CD TIOCM_CAR 56 + #define BSD_TIOCM_RNG 0200 57 + #define BSD_TIOCM_RI TIOCM_RNG 58 + #define BSD_TIOCM_DSR 0400 59 + 60 + #define BSD_TIOCEXCL BSD_IO('t', 13) 61 + #define BSD_TIOCNXCL BSD_IO('t', 14) 62 + 63 + #define BSD_TIOCFLUSH BSD_IOW('t', 16, int) 64 + 65 + #define BSD_TIOCGETA BSD_IOR('t', 19, struct bsd_termios) 66 + #define BSD_TIOCSETA BSD_IOW('t', 20, struct bsd_termios) 67 + #define BSD_TIOCSETAW BSD_IOW('t', 21, struct bsd_termios) 68 + #define BSD_TIOCSETAF BSD_IOW('t', 22, struct bsd_termios) 69 + #define BSD_TIOCGETD BSD_IOR('t', 26, int) 70 + #define BSD_TIOCSETD BSD_IOW('t', 27, int) 71 + #define BSD_TIOCIXON BSD_IO('t', 129) 72 + #define BSD_TIOCIXOFF BSD_IO('t', 128) 73 + 74 + #define BSD_TIOCSBRK BSD_IO('t', 123) 75 + #define BSD_TIOCCBRK BSD_IO('t', 122) 76 + #define BSD_TIOCSDTR BSD_IO('t', 121) 77 + #define BSD_TIOCCDTR BSD_IO('t', 120) 78 + #define BSD_TIOCGPGRP BSD_IOR('t', 119, int) 79 + #define BSD_TIOCSPGRP BSD_IOW('t', 118, int) 80 + 81 + #define BSD_TIOCOUTQ BSD_IOR('t', 115, int) 82 + #define BSD_TIOCSTI BSD_IOW('t', 114, char) 83 + #define BSD_TIOCNOTTY BSD_IO('t', 113) 84 + #define BSD_TIOCPKT BSD_IOW('t', 112, int) 85 + #define BSD_TIOCPKT_DATA 0x00 86 + #define BSD_TIOCPKT_FLUSHREAD 0x01 87 + #define BSD_TIOCPKT_FLUSHWRITE 0x02 88 + #define BSD_TIOCPKT_STOP 0x04 89 + #define BSD_TIOCPKT_START 0x08 90 + #define BSD_TIOCPKT_NOSTOP 0x10 91 + #define BSD_TIOCPKT_DOSTOP 0x20 92 + #define BSD_TIOCPKT_IOCTL 0x40 93 + #define BSD_TIOCSTOP BSD_IO('t', 111) 94 + #define BSD_TIOCSTART BSD_IO('t', 110) 95 + #define BSD_TIOCMSET BSD_IOW('t', 109, int) 96 + #define BSD_TIOCMBIS BSD_IOW('t', 108, int) 97 + #define BSD_TIOCMBIC BSD_IOW('t', 107, int) 98 + #define BSD_TIOCMGET BSD_IOR('t', 106, int) 99 + #define BSD_TIOCREMOTE BSD_IOW('t', 105, int) 100 + #define BSD_TIOCGWINSZ BSD_IOR('t', 104, struct bsd_winsize) 101 + #define BSD_TIOCSWINSZ BSD_IOW('t', 103, struct bsd_winsize) 102 + #define BSD_TIOCUCNTL BSD_IOW('t', 102, int) 103 + #define BSD_TIOCSTAT BSD_IO('t', 101) 104 + #define BSD_UIOCCMD(n) BSD_IO('u', n) 105 + #define BSD_TIOCSCONS BSD_IO('t', 99) 106 + #define BSD_TIOCCONS BSD_IOW('t', 98, int) 107 + #define BSD_TIOCSCTTY BSD_IO('t', 97) 108 + #define BSD_TIOCEXT BSD_IOW('t', 96, int) 109 + #define BSD_TIOCSIG BSD_IO('t', 95) 110 + #define BSD_TIOCDRAIN BSD_IO('t', 94) 111 + #define BSD_TIOCMSDTRWAIT BSD_IOW('t', 91, int) 112 + #define BSD_TIOCMGDTRWAIT BSD_IOR('t', 90, int) 113 + #define BSD_TIOCTIMESTAMP BSD_IOR('t', 89, struct bsd_timeval) 114 + #define BSD_TIOCDCDTIMESTAMP BSD_IOR('t', 88, struct bsd_timeval) 115 + #define BSD_TIOCSDRAINWAIT BSD_IOW('t', 87, int) 116 + #define BSD_TIOCGDRAINWAIT BSD_IOR('t', 86, int) 117 + #define BSD_TIOCPTYGRANT BSD_IO('t', 84) 118 + #define BSD_TIOCPTYGNAME BSD_IOC(IOC_OUT, 't', 83, 128) 119 + #define BSD_TIOCPTYUNLK BSD_IO('t', 82) 120 + 121 + #define BSD_IGNBRK 0x00000001 122 + #define BSD_BRKINT 0x00000002 123 + #define BSD_IGNPAR 0x00000004 124 + #define BSD_PARMRK 0x00000008 125 + #define BSD_INPCK 0x00000010 126 + #define BSD_ISTRIP 0x00000020 127 + #define BSD_INLCR 0x00000040 128 + #define BSD_IGNCR 0x00000080 129 + #define BSD_ICRNL 0x00000100 130 + #define BSD_IXON 0x00000200 131 + #define BSD_IXOFF 0x00000400 132 + #define BSD_IXANY 0x00000800 133 + #define BSD_IMAXBEL 0x00002000 134 + #define BSD_IUTF8 0x00004000 135 + 136 + #define BSD_OPOST 0x00000001 137 + #define BSD_ONLCR 0x00000002 138 + #define BSD_OXTABS 0x00000004 139 + #define BSD_ONOEOT 0x00000008 140 + 141 + #define BSD_CIGNORE 0x00000001 142 + #define BSD_CSIZE 0x00000300 143 + #define BSD_CS5 0x00000000 144 + #define BSD_CS6 0x00000100 145 + #define BSD_CS7 0x00000200 146 + #define BSD_CS8 0x00000300 147 + #define BSD_CSTOPB 0x00000400 148 + #define BSD_CREAD 0x00000800 149 + #define BSD_PARENB 0x00001000 150 + #define BSD_PARODD 0x00002000 151 + #define BSD_HUPCL 0x00004000 152 + #define BSD_CLOCAL 0x00008000 153 + #define BSD_CCTS_OFLOW 0x00010000 154 + #define BSD_CRTS_IFLOW 0x00020000 155 + #define BSD_CDTR_IFLOW 0x00040000 156 + #define BSD_CDSR_OFLOW 0x00080000 157 + #define BSD_CCAR_OFLOW 0x00100000 158 + #define BSD_MDMBUF 0x00100000 159 + 160 + 161 + #define BSD_ECHOKE 0x00000001 162 + #define BSD_ECHOE 0x00000002 163 + #define BSD_ECHOK 0x00000004 164 + #define BSD_ECHO 0x00000008 165 + #define BSD_ECHONL 0x00000010 166 + #define BSD_ECHOPRT 0x00000020 167 + #define BSD_ECHOCTL 0x00000040 168 + #define BSD_ISIG 0x00000080 169 + #define BSD_ICANON 0x00000100 170 + #define BSD_ALTWERASE 0x00000200 171 + #define BSD_IEXTEN 0x00000400 172 + #define BSD_EXTPROC 0x00000800 173 + #define BSD_TOSTOP 0x00400000 174 + #define BSD_FLUSHO 0x00800000 175 + #define BSD_NOKERNINFO 0x02000000 176 + #define BSD_PENDIN 0x20000000 177 + #define BSD_NOFLSH 0x80000000 178 + 179 + /* c_cc characters */ 180 + #define LINUX_VINTR 0 181 + #define LINUX_VQUIT 1 182 + #define LINUX_VERASE 2 183 + #define LINUX_VKILL 3 184 + #define LINUX_VEOF 4 185 + #define LINUX_VTIME 5 186 + #define LINUX_VMIN 6 187 + #define LINUX_VSWTC 7 188 + #define LINUX_VSTART 8 189 + #define LINUX_VSTOP 9 190 + #define LINUX_VSUSP 10 191 + #define LINUX_VEOL 11 192 + #define LINUX_VREPRINT 12 193 + #define LINUX_VDISCARD 13 194 + #define LINUX_VWERASE 14 195 + #define LINUX_VLNEXT 15 196 + #define LINUX_VEOL2 16 197 + 198 + /* c_iflag bits */ 199 + #define LINUX_IGNBRK 0000001 200 + #define LINUX_BRKINT 0000002 201 + #define LINUX_IGNPAR 0000004 202 + #define LINUX_PARMRK 0000010 203 + #define LINUX_INPCK 0000020 204 + #define LINUX_ISTRIP 0000040 205 + #define LINUX_INLCR 0000100 206 + #define LINUX_IGNCR 0000200 207 + #define LINUX_ICRNL 0000400 208 + #define LINUX_IUCLC 0001000 209 + #define LINUX_IXON 0002000 210 + #define LINUX_IXANY 0004000 211 + #define LINUX_IXOFF 0010000 212 + #define LINUX_IMAXBEL 0020000 213 + #define LINUX_IUTF8 0040000 214 + 215 + /* c_oflag bits */ 216 + #define LINUX_OPOST 0000001 217 + #define LINUX_OLCUC 0000002 218 + #define LINUX_ONLCR 0000004 219 + #define LINUX_OCRNL 0000010 220 + #define LINUX_ONOCR 0000020 221 + #define LINUX_ONLRET 0000040 222 + #define LINUX_OFILL 0000100 223 + #define LINUX_OFDEL 0000200 224 + 225 + #define LINUX_VTDLY 0040000 226 + #define LINUX_VT0 0000000 227 + #define LINUX_VT1 0040000 228 + 229 + #define LINUX_XTABS 0014000 230 + 231 + /* c_cflag bit meaning */ 232 + #define LINUX_CSIZE 0000060 233 + #define LINUX_CS5 0000000 234 + #define LINUX_CS6 0000020 235 + #define LINUX_CS7 0000040 236 + #define LINUX_CS8 0000060 237 + #define LINUX_CSTOPB 0000100 238 + #define LINUX_CREAD 0000200 239 + #define LINUX_PARENB 0000400 240 + #define LINUX_PARODD 0001000 241 + #define LINUX_HUPCL 0002000 242 + #define LINUX_CLOCAL 0004000 243 + 244 + /* c_lflag bits */ 245 + #define LINUX_ISIG 0000001 246 + #define LINUX_ICANON 0000002 247 + #define LINUX_XCASE 0000004 248 + #define LINUX_ECHO 0000010 249 + #define LINUX_ECHOE 0000020 250 + #define LINUX_ECHOK 0000040 251 + #define LINUX_ECHONL 0000100 252 + #define LINUX_NOFLSH 0000200 253 + #define LINUX_TOSTOP 0000400 254 + 255 + #define LINUX_ECHOCTL 0001000 256 + #define LINUX_ECHOPRT 0002000 257 + #define LINUX_ECHOKE 0004000 258 + #define LINUX_FLUSHO 0010000 259 + #define LINUX_PENDIN 0040000 260 + #define LINUX_IEXTEN 0100000 261 + #define LINUX_EXTPROC 0200000 262 + 263 + 264 + #endif 265 +