~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/include/asm/termios.h

Version: ~ [ linux-5.13-rc1 ] ~ [ linux-5.12.2 ] ~ [ linux-5.11.19 ] ~ [ linux-5.10.35 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.117 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.190 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.232 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.268 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.268 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * This file is subject to the terms and conditions of the GNU General Public
  3  * License.  See the file "COPYING" in the main directory of this archive
  4  * for more details.
  5  *
  6  * Copyright (C) 1995, 1996, 2000, 2001 by Ralf Baechle
  7  * Copyright (C) 2000, 2001 Silicon Graphics, Inc.
  8  */
  9 #ifndef _ASM_TERMIOS_H
 10 #define _ASM_TERMIOS_H
 11 
 12 #include <asm/uaccess.h>
 13 #include <uapi/asm/termios.h>
 14 
 15 /*
 16  *      intr=^C         quit=^\         erase=del       kill=^U
 17  *      vmin=\1         vtime=\0        eol2=\0         swtc=\0
 18  *      start=^Q        stop=^S         susp=^Z         vdsusp=
 19  *      reprint=^R      discard=^U      werase=^W       lnext=^V
 20  *      eof=^D          eol=\0
 21  */
 22 #define INIT_C_CC "\003\034\177\025\1\0\0\0\021\023\032\0\022\017\027\026\004\0"
 23 
 24 #include <linux/string.h>
 25 
 26 /*
 27  * Translate a "termio" structure into a "termios". Ugh.
 28  */
 29 static inline int user_termio_to_kernel_termios(struct ktermios *termios,
 30         struct termio __user *termio)
 31 {
 32         unsigned short iflag, oflag, cflag, lflag;
 33         unsigned int err;
 34 
 35         if (!access_ok(VERIFY_READ, termio, sizeof(struct termio)))
 36                 return -EFAULT;
 37 
 38         err = __get_user(iflag, &termio->c_iflag);
 39         termios->c_iflag = (termios->c_iflag & 0xffff0000) | iflag;
 40         err |=__get_user(oflag, &termio->c_oflag);
 41         termios->c_oflag = (termios->c_oflag & 0xffff0000) | oflag;
 42         err |=__get_user(cflag, &termio->c_cflag);
 43         termios->c_cflag = (termios->c_cflag & 0xffff0000) | cflag;
 44         err |=__get_user(lflag, &termio->c_lflag);
 45         termios->c_lflag = (termios->c_lflag & 0xffff0000) | lflag;
 46         err |=__get_user(termios->c_line, &termio->c_line);
 47         if (err)
 48                 return -EFAULT;
 49 
 50         if (__copy_from_user(termios->c_cc, termio->c_cc, NCC))
 51                 return -EFAULT;
 52 
 53         return 0;
 54 }
 55 
 56 /*
 57  * Translate a "termios" structure into a "termio". Ugh.
 58  */
 59 static inline int kernel_termios_to_user_termio(struct termio __user *termio,
 60         struct ktermios *termios)
 61 {
 62         int err;
 63 
 64         if (!access_ok(VERIFY_WRITE, termio, sizeof(struct termio)))
 65                 return -EFAULT;
 66 
 67         err = __put_user(termios->c_iflag, &termio->c_iflag);
 68         err |= __put_user(termios->c_oflag, &termio->c_oflag);
 69         err |= __put_user(termios->c_cflag, &termio->c_cflag);
 70         err |= __put_user(termios->c_lflag, &termio->c_lflag);
 71         err |= __put_user(termios->c_line, &termio->c_line);
 72         if (err)
 73                 return -EFAULT;
 74 
 75         if (__copy_to_user(termio->c_cc, termios->c_cc, NCC))
 76                 return -EFAULT;
 77 
 78         return 0;
 79 }
 80 
 81 static inline int user_termios_to_kernel_termios(struct ktermios __user *k,
 82         struct termios2 *u)
 83 {
 84         return copy_from_user(k, u, sizeof(struct termios2)) ? -EFAULT : 0;
 85 }
 86 
 87 static inline int kernel_termios_to_user_termios(struct termios2 __user *u,
 88         struct ktermios *k)
 89 {
 90         return copy_to_user(u, k, sizeof(struct termios2)) ? -EFAULT : 0;
 91 }
 92 
 93 static inline int user_termios_to_kernel_termios_1(struct ktermios *k,
 94         struct termios __user *u)
 95 {
 96         return copy_from_user(k, u, sizeof(struct termios)) ? -EFAULT : 0;
 97 }
 98 
 99 static inline int kernel_termios_to_user_termios_1(struct termios __user *u,
100         struct ktermios *k)
101 {
102         return copy_to_user(u, k, sizeof(struct termios)) ? -EFAULT : 0;
103 }
104 
105 #endif /* _ASM_TERMIOS_H */
106 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp