Annotation of linux/fs/tty_ioctl.c, revision 1.1.1.2

1.1.1.2 ! root        1: /*
        !             2:  *  linux/fs/tty_ioctl.c
        !             3:  *
        !             4:  *  (C) 1991  Linus Torvalds
        !             5:  */
        !             6: 
1.1       root        7: #include <errno.h>
                      8: #include <termios.h>
                      9: 
                     10: #include <linux/sched.h>
                     11: #include <linux/kernel.h>
                     12: #include <linux/tty.h>
                     13: 
                     14: #include <asm/segment.h>
                     15: #include <asm/system.h>
                     16: 
                     17: static void flush(struct tty_queue * queue)
                     18: {
                     19:        cli();
                     20:        queue->head = queue->tail;
                     21:        sti();
                     22: }
                     23: 
                     24: static void wait_until_sent(struct tty_struct * tty)
                     25: {
                     26:        /* do nothing - not implemented */
                     27: }
                     28: 
                     29: static void send_break(struct tty_struct * tty)
                     30: {
                     31:        /* do nothing - not implemented */
                     32: }
                     33: 
                     34: static int get_termios(struct tty_struct * tty, struct termios * termios)
                     35: {
                     36:        int i;
                     37: 
                     38:        verify_area(termios, sizeof (*termios));
                     39:        for (i=0 ; i< (sizeof (*termios)) ; i++)
                     40:                put_fs_byte( ((char *)&tty->termios)[i] , i+(char *)termios );
                     41:        return 0;
                     42: }
                     43: 
                     44: static int set_termios(struct tty_struct * tty, struct termios * termios)
                     45: {
                     46:        int i;
                     47: 
                     48:        for (i=0 ; i< (sizeof (*termios)) ; i++)
                     49:                ((char *)&tty->termios)[i]=get_fs_byte(i+(char *)termios);
                     50:        return 0;
                     51: }
                     52: 
                     53: static int get_termio(struct tty_struct * tty, struct termio * termio)
                     54: {
                     55:        int i;
                     56:        struct termio tmp_termio;
                     57: 
                     58:        verify_area(termio, sizeof (*termio));
                     59:        tmp_termio.c_iflag = tty->termios.c_iflag;
                     60:        tmp_termio.c_oflag = tty->termios.c_oflag;
                     61:        tmp_termio.c_cflag = tty->termios.c_cflag;
                     62:        tmp_termio.c_lflag = tty->termios.c_lflag;
                     63:        tmp_termio.c_line = tty->termios.c_line;
                     64:        for(i=0 ; i < NCC ; i++)
                     65:                tmp_termio.c_cc[i] = tty->termios.c_cc[i];
                     66:        for (i=0 ; i< (sizeof (*termio)) ; i++)
                     67:                put_fs_byte( ((char *)&tmp_termio)[i] , i+(char *)termio );
                     68:        return 0;
                     69: }
                     70: 
1.1.1.2 ! root       71: /*
        !            72:  * This only works as the 386 is low-byt-first
        !            73:  */
1.1       root       74: static int set_termio(struct tty_struct * tty, struct termio * termio)
                     75: {
                     76:        int i;
                     77:        struct termio tmp_termio;
                     78: 
                     79:        for (i=0 ; i< (sizeof (*termio)) ; i++)
                     80:                ((char *)&tmp_termio)[i]=get_fs_byte(i+(char *)termio);
                     81:        *(unsigned short *)&tty->termios.c_iflag = tmp_termio.c_iflag;
                     82:        *(unsigned short *)&tty->termios.c_oflag = tmp_termio.c_oflag;
                     83:        *(unsigned short *)&tty->termios.c_cflag = tmp_termio.c_cflag;
                     84:        *(unsigned short *)&tty->termios.c_lflag = tmp_termio.c_lflag;
                     85:        tty->termios.c_line = tmp_termio.c_line;
                     86:        for(i=0 ; i < NCC ; i++)
                     87:                tty->termios.c_cc[i] = tmp_termio.c_cc[i];
                     88:        return 0;
                     89: }
                     90: 
                     91: int tty_ioctl(int dev, int cmd, int arg)
                     92: {
                     93:        struct tty_struct * tty;
                     94:        if (MAJOR(dev) == 5) {
                     95:                dev=current->tty;
                     96:                if (dev<0)
                     97:                        panic("tty_ioctl: dev<0");
                     98:        } else
                     99:                dev=MINOR(dev);
                    100:        tty = dev + tty_table;
                    101:        switch (cmd) {
                    102:                case TCGETS:
                    103:                        return get_termios(tty,(struct termios *) arg);
                    104:                case TCSETSF:
                    105:                        flush(&tty->read_q); /* fallthrough */
                    106:                case TCSETSW:
                    107:                        wait_until_sent(tty); /* fallthrough */
                    108:                case TCSETS:
                    109:                        return set_termios(tty,(struct termios *) arg);
                    110:                case TCGETA:
                    111:                        return get_termio(tty,(struct termio *) arg);
                    112:                case TCSETAF:
                    113:                        flush(&tty->read_q); /* fallthrough */
                    114:                case TCSETAW:
                    115:                        wait_until_sent(tty); /* fallthrough */
                    116:                case TCSETA:
                    117:                        return set_termio(tty,(struct termio *) arg);
                    118:                case TCSBRK:
                    119:                        if (!arg) {
                    120:                                wait_until_sent(tty);
                    121:                                send_break(tty);
                    122:                        }
                    123:                        return 0;
                    124:                case TCXONC:
                    125:                        return -EINVAL; /* not implemented */
                    126:                case TCFLSH:
                    127:                        if (arg==0)
                    128:                                flush(&tty->read_q);
                    129:                        else if (arg==1)
                    130:                                flush(&tty->write_q);
                    131:                        else if (arg==2) {
                    132:                                flush(&tty->read_q);
                    133:                                flush(&tty->write_q);
                    134:                        } else
                    135:                                return -EINVAL;
                    136:                        return 0;
                    137:                case TIOCEXCL:
                    138:                        return -EINVAL; /* not implemented */
                    139:                case TIOCNXCL:
                    140:                        return -EINVAL; /* not implemented */
                    141:                case TIOCSCTTY:
                    142:                        return -EINVAL; /* set controlling term NI */
                    143:                case TIOCGPGRP:
                    144:                        verify_area((void *) arg,4);
                    145:                        put_fs_long(tty->pgrp,(unsigned long *) arg);
                    146:                        return 0;
                    147:                case TIOCSPGRP:
                    148:                        tty->pgrp=get_fs_long((unsigned long *) arg);
                    149:                        return 0;
                    150:                case TIOCOUTQ:
                    151:                        verify_area((void *) arg,4);
                    152:                        put_fs_long(CHARS(tty->write_q),(unsigned long *) arg);
                    153:                        return 0;
                    154:                case TIOCSTI:
                    155:                        return -EINVAL; /* not implemented */
                    156:                case TIOCGWINSZ:
                    157:                        return -EINVAL; /* not implemented */
                    158:                case TIOCSWINSZ:
                    159:                        return -EINVAL; /* not implemented */
                    160:                case TIOCMGET:
                    161:                        return -EINVAL; /* not implemented */
                    162:                case TIOCMBIS:
                    163:                        return -EINVAL; /* not implemented */
                    164:                case TIOCMBIC:
                    165:                        return -EINVAL; /* not implemented */
                    166:                case TIOCMSET:
                    167:                        return -EINVAL; /* not implemented */
                    168:                case TIOCGSOFTCAR:
                    169:                        return -EINVAL; /* not implemented */
                    170:                case TIOCSSOFTCAR:
                    171:                        return -EINVAL; /* not implemented */
                    172:                default:
                    173:                        return -EINVAL;
                    174:        }
                    175: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.