tty_ioctl: drag screaming into compliance with the coding style
Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
@@ -50,7 +50,7 @@
|
|||||||
* Locking: none
|
* Locking: none
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void tty_wait_until_sent(struct tty_struct * tty, long timeout)
|
void tty_wait_until_sent(struct tty_struct *tty, long timeout)
|
||||||
{
|
{
|
||||||
#ifdef TTY_DEBUG_WAIT_UNTIL_SENT
|
#ifdef TTY_DEBUG_WAIT_UNTIL_SENT
|
||||||
char buf[64];
|
char buf[64];
|
||||||
@@ -67,7 +67,6 @@ void tty_wait_until_sent(struct tty_struct * tty, long timeout)
|
|||||||
if (tty->driver->wait_until_sent)
|
if (tty->driver->wait_until_sent)
|
||||||
tty->driver->wait_until_sent(tty, timeout);
|
tty->driver->wait_until_sent(tty, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(tty_wait_until_sent);
|
EXPORT_SYMBOL(tty_wait_until_sent);
|
||||||
|
|
||||||
static void unset_locked_termios(struct ktermios *termios,
|
static void unset_locked_termios(struct ktermios *termios,
|
||||||
@@ -76,7 +75,7 @@ static void unset_locked_termios(struct ktermios *termios,
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#define NOSET_MASK(x,y,z) (x = ((x) & ~(z)) | ((y) & (z)))
|
#define NOSET_MASK(x, y, z) (x = ((x) & ~(z)) | ((y) & (z)))
|
||||||
|
|
||||||
if (!locked) {
|
if (!locked) {
|
||||||
printk(KERN_WARNING "Warning?!? termios_locked is NULL.\n");
|
printk(KERN_WARNING "Warning?!? termios_locked is NULL.\n");
|
||||||
@@ -88,7 +87,7 @@ static void unset_locked_termios(struct ktermios *termios,
|
|||||||
NOSET_MASK(termios->c_cflag, old->c_cflag, locked->c_cflag);
|
NOSET_MASK(termios->c_cflag, old->c_cflag, locked->c_cflag);
|
||||||
NOSET_MASK(termios->c_lflag, old->c_lflag, locked->c_lflag);
|
NOSET_MASK(termios->c_lflag, old->c_lflag, locked->c_lflag);
|
||||||
termios->c_line = locked->c_line ? old->c_line : termios->c_line;
|
termios->c_line = locked->c_line ? old->c_line : termios->c_line;
|
||||||
for (i=0; i < NCCS; i++)
|
for (i = 0; i < NCCS; i++)
|
||||||
termios->c_cc[i] = locked->c_cc[i] ?
|
termios->c_cc[i] = locked->c_cc[i] ?
|
||||||
old->c_cc[i] : termios->c_cc[i];
|
old->c_cc[i] : termios->c_cc[i];
|
||||||
/* FIXME: What should we do for i/ospeed */
|
/* FIXME: What should we do for i/ospeed */
|
||||||
@@ -163,7 +162,6 @@ speed_t tty_termios_baud_rate(struct ktermios *termios)
|
|||||||
}
|
}
|
||||||
return baud_table[cbaud];
|
return baud_table[cbaud];
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(tty_termios_baud_rate);
|
EXPORT_SYMBOL(tty_termios_baud_rate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -203,7 +201,6 @@ speed_t tty_termios_input_baud_rate(struct ktermios *termios)
|
|||||||
return tty_termios_baud_rate(termios);
|
return tty_termios_baud_rate(termios);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(tty_termios_input_baud_rate);
|
EXPORT_SYMBOL(tty_termios_input_baud_rate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -338,7 +335,6 @@ speed_t tty_get_baud_rate(struct tty_struct *tty)
|
|||||||
|
|
||||||
return baud;
|
return baud;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(tty_get_baud_rate);
|
EXPORT_SYMBOL(tty_get_baud_rate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -361,7 +357,6 @@ void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old)
|
|||||||
new->c_ispeed = old->c_ispeed;
|
new->c_ispeed = old->c_ispeed;
|
||||||
new->c_ospeed = old->c_ospeed;
|
new->c_ospeed = old->c_ospeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(tty_termios_copy_hw);
|
EXPORT_SYMBOL(tty_termios_copy_hw);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -395,7 +390,7 @@ EXPORT_SYMBOL(tty_termios_hw_change);
|
|||||||
* Locking: termios_sem
|
* Locking: termios_sem
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void change_termios(struct tty_struct * tty, struct ktermios * new_termios)
|
static void change_termios(struct tty_struct *tty, struct ktermios *new_termios)
|
||||||
{
|
{
|
||||||
int canon_change;
|
int canon_change;
|
||||||
struct ktermios old_termios = *tty->termios;
|
struct ktermios old_termios = *tty->termios;
|
||||||
@@ -470,7 +465,7 @@ static void change_termios(struct tty_struct * tty, struct ktermios * new_termio
|
|||||||
* Called functions take ldisc and termios_sem locks
|
* Called functions take ldisc and termios_sem locks
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int set_termios(struct tty_struct * tty, void __user *arg, int opt)
|
static int set_termios(struct tty_struct *tty, void __user *arg, int opt)
|
||||||
{
|
{
|
||||||
struct ktermios tmp_termios;
|
struct ktermios tmp_termios;
|
||||||
struct tty_ldisc *ld;
|
struct tty_ldisc *ld;
|
||||||
@@ -501,8 +496,8 @@ static int set_termios(struct tty_struct * tty, void __user *arg, int opt)
|
|||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If old style Bfoo values are used then load c_ispeed/c_ospeed with the real speed
|
/* If old style Bfoo values are used then load c_ispeed/c_ospeed
|
||||||
so its unconditionally usable */
|
* with the real speed so its unconditionally usable */
|
||||||
tmp_termios.c_ispeed = tty_termios_input_baud_rate(&tmp_termios);
|
tmp_termios.c_ispeed = tty_termios_input_baud_rate(&tmp_termios);
|
||||||
tmp_termios.c_ospeed = tty_termios_baud_rate(&tmp_termios);
|
tmp_termios.c_ospeed = tty_termios_baud_rate(&tmp_termios);
|
||||||
|
|
||||||
@@ -529,14 +524,14 @@ static int set_termios(struct tty_struct * tty, void __user *arg, int opt)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_termio(struct tty_struct * tty, struct termio __user * termio)
|
static int get_termio(struct tty_struct *tty, struct termio __user *termio)
|
||||||
{
|
{
|
||||||
if (kernel_termios_to_user_termio(termio, tty->termios))
|
if (kernel_termios_to_user_termio(termio, tty->termios))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long inq_canon(struct tty_struct * tty)
|
static unsigned long inq_canon(struct tty_struct *tty)
|
||||||
{
|
{
|
||||||
int nr, head, tail;
|
int nr, head, tail;
|
||||||
|
|
||||||
@@ -561,7 +556,7 @@ static unsigned long inq_canon(struct tty_struct * tty)
|
|||||||
*
|
*
|
||||||
* The "sg_flags" translation is a joke..
|
* The "sg_flags" translation is a joke..
|
||||||
*/
|
*/
|
||||||
static int get_sgflags(struct tty_struct * tty)
|
static int get_sgflags(struct tty_struct *tty)
|
||||||
{
|
{
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
@@ -579,7 +574,7 @@ static int get_sgflags(struct tty_struct * tty)
|
|||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_sgttyb(struct tty_struct * tty, struct sgttyb __user * sgttyb)
|
static int get_sgttyb(struct tty_struct *tty, struct sgttyb __user *sgttyb)
|
||||||
{
|
{
|
||||||
struct sgttyb tmp;
|
struct sgttyb tmp;
|
||||||
|
|
||||||
@@ -594,7 +589,7 @@ static int get_sgttyb(struct tty_struct * tty, struct sgttyb __user * sgttyb)
|
|||||||
return copy_to_user(sgttyb, &tmp, sizeof(tmp)) ? -EFAULT : 0;
|
return copy_to_user(sgttyb, &tmp, sizeof(tmp)) ? -EFAULT : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_sgflags(struct ktermios * termios, int flags)
|
static void set_sgflags(struct ktermios *termios, int flags)
|
||||||
{
|
{
|
||||||
termios->c_iflag = ICRNL | IXON;
|
termios->c_iflag = ICRNL | IXON;
|
||||||
termios->c_oflag = 0;
|
termios->c_oflag = 0;
|
||||||
@@ -631,7 +626,7 @@ static void set_sgflags(struct ktermios * termios, int flags)
|
|||||||
* Locking: termios_sem
|
* Locking: termios_sem
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int set_sgttyb(struct tty_struct * tty, struct sgttyb __user * sgttyb)
|
static int set_sgttyb(struct tty_struct *tty, struct sgttyb __user *sgttyb)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
struct sgttyb tmp;
|
struct sgttyb tmp;
|
||||||
@@ -651,7 +646,8 @@ static int set_sgttyb(struct tty_struct * tty, struct sgttyb __user * sgttyb)
|
|||||||
set_sgflags(&termios, tmp.sg_flags);
|
set_sgflags(&termios, tmp.sg_flags);
|
||||||
/* Try and encode into Bfoo format */
|
/* Try and encode into Bfoo format */
|
||||||
#ifdef BOTHER
|
#ifdef BOTHER
|
||||||
tty_termios_encode_baud_rate(&termios, termios.c_ispeed, termios.c_ospeed);
|
tty_termios_encode_baud_rate(&termios, termios.c_ispeed,
|
||||||
|
termios.c_ospeed);
|
||||||
#endif
|
#endif
|
||||||
mutex_unlock(&tty->termios_mutex);
|
mutex_unlock(&tty->termios_mutex);
|
||||||
change_termios(tty, &termios);
|
change_termios(tty, &termios);
|
||||||
@@ -660,7 +656,7 @@ static int set_sgttyb(struct tty_struct * tty, struct sgttyb __user * sgttyb)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TIOCGETC
|
#ifdef TIOCGETC
|
||||||
static int get_tchars(struct tty_struct * tty, struct tchars __user * tchars)
|
static int get_tchars(struct tty_struct *tty, struct tchars __user *tchars)
|
||||||
{
|
{
|
||||||
struct tchars tmp;
|
struct tchars tmp;
|
||||||
|
|
||||||
@@ -673,7 +669,7 @@ static int get_tchars(struct tty_struct * tty, struct tchars __user * tchars)
|
|||||||
return copy_to_user(tchars, &tmp, sizeof(tmp)) ? -EFAULT : 0;
|
return copy_to_user(tchars, &tmp, sizeof(tmp)) ? -EFAULT : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_tchars(struct tty_struct * tty, struct tchars __user * tchars)
|
static int set_tchars(struct tty_struct *tty, struct tchars __user *tchars)
|
||||||
{
|
{
|
||||||
struct tchars tmp;
|
struct tchars tmp;
|
||||||
|
|
||||||
@@ -690,20 +686,22 @@ static int set_tchars(struct tty_struct * tty, struct tchars __user * tchars)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TIOCGLTC
|
#ifdef TIOCGLTC
|
||||||
static int get_ltchars(struct tty_struct * tty, struct ltchars __user * ltchars)
|
static int get_ltchars(struct tty_struct *tty, struct ltchars __user *ltchars)
|
||||||
{
|
{
|
||||||
struct ltchars tmp;
|
struct ltchars tmp;
|
||||||
|
|
||||||
tmp.t_suspc = tty->termios->c_cc[VSUSP];
|
tmp.t_suspc = tty->termios->c_cc[VSUSP];
|
||||||
tmp.t_dsuspc = tty->termios->c_cc[VSUSP]; /* what is dsuspc anyway? */
|
/* what is dsuspc anyway? */
|
||||||
|
tmp.t_dsuspc = tty->termios->c_cc[VSUSP];
|
||||||
tmp.t_rprntc = tty->termios->c_cc[VREPRINT];
|
tmp.t_rprntc = tty->termios->c_cc[VREPRINT];
|
||||||
tmp.t_flushc = tty->termios->c_cc[VEOL2]; /* what is flushc anyway? */
|
/* what is flushc anyway? */
|
||||||
|
tmp.t_flushc = tty->termios->c_cc[VEOL2];
|
||||||
tmp.t_werasc = tty->termios->c_cc[VWERASE];
|
tmp.t_werasc = tty->termios->c_cc[VWERASE];
|
||||||
tmp.t_lnextc = tty->termios->c_cc[VLNEXT];
|
tmp.t_lnextc = tty->termios->c_cc[VLNEXT];
|
||||||
return copy_to_user(ltchars, &tmp, sizeof(tmp)) ? -EFAULT : 0;
|
return copy_to_user(ltchars, &tmp, sizeof(tmp)) ? -EFAULT : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_ltchars(struct tty_struct * tty, struct ltchars __user * ltchars)
|
static int set_ltchars(struct tty_struct *tty, struct ltchars __user *ltchars)
|
||||||
{
|
{
|
||||||
struct ltchars tmp;
|
struct ltchars tmp;
|
||||||
|
|
||||||
@@ -711,9 +709,11 @@ static int set_ltchars(struct tty_struct * tty, struct ltchars __user * ltchars)
|
|||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
tty->termios->c_cc[VSUSP] = tmp.t_suspc;
|
tty->termios->c_cc[VSUSP] = tmp.t_suspc;
|
||||||
tty->termios->c_cc[VEOL2] = tmp.t_dsuspc; /* what is dsuspc anyway? */
|
/* what is dsuspc anyway? */
|
||||||
|
tty->termios->c_cc[VEOL2] = tmp.t_dsuspc;
|
||||||
tty->termios->c_cc[VREPRINT] = tmp.t_rprntc;
|
tty->termios->c_cc[VREPRINT] = tmp.t_rprntc;
|
||||||
tty->termios->c_cc[VEOL2] = tmp.t_flushc; /* what is flushc anyway? */
|
/* what is flushc anyway? */
|
||||||
|
tty->termios->c_cc[VEOL2] = tmp.t_flushc;
|
||||||
tty->termios->c_cc[VWERASE] = tmp.t_werasc;
|
tty->termios->c_cc[VWERASE] = tmp.t_werasc;
|
||||||
tty->termios->c_cc[VLNEXT] = tmp.t_lnextc;
|
tty->termios->c_cc[VLNEXT] = tmp.t_lnextc;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -761,10 +761,10 @@ static int send_prio_char(struct tty_struct *tty, char ch)
|
|||||||
* consistent mode setting.
|
* consistent mode setting.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int tty_mode_ioctl(struct tty_struct * tty, struct file *file,
|
int tty_mode_ioctl(struct tty_struct *tty, struct file *file,
|
||||||
unsigned int cmd, unsigned long arg)
|
unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct tty_struct * real_tty;
|
struct tty_struct *real_tty;
|
||||||
void __user *p = (void __user *)arg;
|
void __user *p = (void __user *)arg;
|
||||||
|
|
||||||
if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
|
if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
|
||||||
@@ -775,100 +775,100 @@ int tty_mode_ioctl(struct tty_struct * tty, struct file *file,
|
|||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
#ifdef TIOCGETP
|
#ifdef TIOCGETP
|
||||||
case TIOCGETP:
|
case TIOCGETP:
|
||||||
return get_sgttyb(real_tty, (struct sgttyb __user *) arg);
|
return get_sgttyb(real_tty, (struct sgttyb __user *) arg);
|
||||||
case TIOCSETP:
|
case TIOCSETP:
|
||||||
case TIOCSETN:
|
case TIOCSETN:
|
||||||
return set_sgttyb(real_tty, (struct sgttyb __user *) arg);
|
return set_sgttyb(real_tty, (struct sgttyb __user *) arg);
|
||||||
#endif
|
#endif
|
||||||
#ifdef TIOCGETC
|
#ifdef TIOCGETC
|
||||||
case TIOCGETC:
|
case TIOCGETC:
|
||||||
return get_tchars(real_tty, p);
|
return get_tchars(real_tty, p);
|
||||||
case TIOCSETC:
|
case TIOCSETC:
|
||||||
return set_tchars(real_tty, p);
|
return set_tchars(real_tty, p);
|
||||||
#endif
|
#endif
|
||||||
#ifdef TIOCGLTC
|
#ifdef TIOCGLTC
|
||||||
case TIOCGLTC:
|
case TIOCGLTC:
|
||||||
return get_ltchars(real_tty, p);
|
return get_ltchars(real_tty, p);
|
||||||
case TIOCSLTC:
|
case TIOCSLTC:
|
||||||
return set_ltchars(real_tty, p);
|
return set_ltchars(real_tty, p);
|
||||||
#endif
|
#endif
|
||||||
case TCSETSF:
|
case TCSETSF:
|
||||||
return set_termios(real_tty, p, TERMIOS_FLUSH | TERMIOS_WAIT | TERMIOS_OLD);
|
return set_termios(real_tty, p, TERMIOS_FLUSH | TERMIOS_WAIT | TERMIOS_OLD);
|
||||||
case TCSETSW:
|
case TCSETSW:
|
||||||
return set_termios(real_tty, p, TERMIOS_WAIT | TERMIOS_OLD);
|
return set_termios(real_tty, p, TERMIOS_WAIT | TERMIOS_OLD);
|
||||||
case TCSETS:
|
case TCSETS:
|
||||||
return set_termios(real_tty, p, TERMIOS_OLD);
|
return set_termios(real_tty, p, TERMIOS_OLD);
|
||||||
#ifndef TCGETS2
|
#ifndef TCGETS2
|
||||||
case TCGETS:
|
case TCGETS:
|
||||||
if (kernel_termios_to_user_termios((struct termios __user *)arg, real_tty->termios))
|
if (kernel_termios_to_user_termios((struct termios __user *)arg, real_tty->termios))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
case TCGETS:
|
case TCGETS:
|
||||||
if (kernel_termios_to_user_termios_1((struct termios __user *)arg, real_tty->termios))
|
if (kernel_termios_to_user_termios_1((struct termios __user *)arg, real_tty->termios))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
return 0;
|
return 0;
|
||||||
case TCGETS2:
|
case TCGETS2:
|
||||||
if (kernel_termios_to_user_termios((struct termios2 __user *)arg, real_tty->termios))
|
if (kernel_termios_to_user_termios((struct termios2 __user *)arg, real_tty->termios))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
return 0;
|
return 0;
|
||||||
case TCSETSF2:
|
case TCSETSF2:
|
||||||
return set_termios(real_tty, p, TERMIOS_FLUSH | TERMIOS_WAIT);
|
return set_termios(real_tty, p, TERMIOS_FLUSH | TERMIOS_WAIT);
|
||||||
case TCSETSW2:
|
case TCSETSW2:
|
||||||
return set_termios(real_tty, p, TERMIOS_WAIT);
|
return set_termios(real_tty, p, TERMIOS_WAIT);
|
||||||
case TCSETS2:
|
case TCSETS2:
|
||||||
return set_termios(real_tty, p, 0);
|
return set_termios(real_tty, p, 0);
|
||||||
#endif
|
#endif
|
||||||
case TCGETA:
|
case TCGETA:
|
||||||
return get_termio(real_tty, p);
|
return get_termio(real_tty, p);
|
||||||
case TCSETAF:
|
case TCSETAF:
|
||||||
return set_termios(real_tty, p, TERMIOS_FLUSH | TERMIOS_WAIT | TERMIOS_TERMIO);
|
return set_termios(real_tty, p, TERMIOS_FLUSH | TERMIOS_WAIT | TERMIOS_TERMIO);
|
||||||
case TCSETAW:
|
case TCSETAW:
|
||||||
return set_termios(real_tty, p, TERMIOS_WAIT | TERMIOS_TERMIO);
|
return set_termios(real_tty, p, TERMIOS_WAIT | TERMIOS_TERMIO);
|
||||||
case TCSETA:
|
case TCSETA:
|
||||||
return set_termios(real_tty, p, TERMIOS_TERMIO);
|
return set_termios(real_tty, p, TERMIOS_TERMIO);
|
||||||
#ifndef TCGETS2
|
#ifndef TCGETS2
|
||||||
case TIOCGLCKTRMIOS:
|
case TIOCGLCKTRMIOS:
|
||||||
if (kernel_termios_to_user_termios((struct termios __user *)arg, real_tty->termios_locked))
|
if (kernel_termios_to_user_termios((struct termios __user *)arg, real_tty->termios_locked))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
return 0;
|
return 0;
|
||||||
|
case TIOCSLCKTRMIOS:
|
||||||
case TIOCSLCKTRMIOS:
|
if (!capable(CAP_SYS_ADMIN))
|
||||||
if (!capable(CAP_SYS_ADMIN))
|
return -EPERM;
|
||||||
return -EPERM;
|
if (user_termios_to_kernel_termios(real_tty->termios_locked,
|
||||||
if (user_termios_to_kernel_termios(real_tty->termios_locked, (struct termios __user *) arg))
|
(struct termios __user *) arg))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
case TIOCGLCKTRMIOS:
|
case TIOCGLCKTRMIOS:
|
||||||
if (kernel_termios_to_user_termios_1((struct termios __user *)arg, real_tty->termios_locked))
|
if (kernel_termios_to_user_termios_1((struct termios __user *)arg, real_tty->termios_locked))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
return 0;
|
return 0;
|
||||||
|
case TIOCSLCKTRMIOS:
|
||||||
case TIOCSLCKTRMIOS:
|
if (!capable(CAP_SYS_ADMIN))
|
||||||
if (!capable(CAP_SYS_ADMIN))
|
return -EPERM;
|
||||||
return -EPERM;
|
if (user_termios_to_kernel_termios_1(real_tty->termios_locked,
|
||||||
if (user_termios_to_kernel_termios_1(real_tty->termios_locked, (struct termios __user *) arg))
|
(struct termios __user *) arg))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
case TIOCGSOFTCAR:
|
case TIOCGSOFTCAR:
|
||||||
return put_user(C_CLOCAL(tty) ? 1 : 0, (int __user *)arg);
|
return put_user(C_CLOCAL(tty) ? 1 : 0,
|
||||||
case TIOCSSOFTCAR:
|
(int __user *)arg);
|
||||||
if (get_user(arg, (unsigned int __user *) arg))
|
case TIOCSSOFTCAR:
|
||||||
return -EFAULT;
|
if (get_user(arg, (unsigned int __user *) arg))
|
||||||
mutex_lock(&tty->termios_mutex);
|
return -EFAULT;
|
||||||
tty->termios->c_cflag =
|
mutex_lock(&tty->termios_mutex);
|
||||||
((tty->termios->c_cflag & ~CLOCAL) |
|
tty->termios->c_cflag =
|
||||||
(arg ? CLOCAL : 0));
|
((tty->termios->c_cflag & ~CLOCAL) |
|
||||||
mutex_unlock(&tty->termios_mutex);
|
(arg ? CLOCAL : 0));
|
||||||
return 0;
|
mutex_unlock(&tty->termios_mutex);
|
||||||
default:
|
return 0;
|
||||||
return -ENOIOCTLCMD;
|
default:
|
||||||
|
return -ENOIOCTLCMD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL_GPL(tty_mode_ioctl);
|
EXPORT_SYMBOL_GPL(tty_mode_ioctl);
|
||||||
|
|
||||||
int tty_perform_flush(struct tty_struct *tty, unsigned long arg)
|
int tty_perform_flush(struct tty_struct *tty, unsigned long arg)
|
||||||
@@ -899,13 +899,12 @@ int tty_perform_flush(struct tty_struct *tty, unsigned long arg)
|
|||||||
tty_ldisc_deref(ld);
|
tty_ldisc_deref(ld);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL_GPL(tty_perform_flush);
|
EXPORT_SYMBOL_GPL(tty_perform_flush);
|
||||||
|
|
||||||
int n_tty_ioctl(struct tty_struct * tty, struct file * file,
|
int n_tty_ioctl(struct tty_struct *tty, struct file *file,
|
||||||
unsigned int cmd, unsigned long arg)
|
unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct tty_struct * real_tty;
|
struct tty_struct *real_tty;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
|
if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
|
||||||
@@ -915,68 +914,67 @@ int n_tty_ioctl(struct tty_struct * tty, struct file * file,
|
|||||||
real_tty = tty;
|
real_tty = tty;
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case TCXONC:
|
case TCXONC:
|
||||||
retval = tty_check_change(tty);
|
retval = tty_check_change(tty);
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case TCOOFF:
|
case TCOOFF:
|
||||||
if (!tty->flow_stopped) {
|
if (!tty->flow_stopped) {
|
||||||
tty->flow_stopped = 1;
|
tty->flow_stopped = 1;
|
||||||
stop_tty(tty);
|
stop_tty(tty);
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TCOON:
|
|
||||||
if (tty->flow_stopped) {
|
|
||||||
tty->flow_stopped = 0;
|
|
||||||
start_tty(tty);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TCIOFF:
|
|
||||||
if (STOP_CHAR(tty) != __DISABLED_CHAR)
|
|
||||||
return send_prio_char(tty, STOP_CHAR(tty));
|
|
||||||
break;
|
|
||||||
case TCION:
|
|
||||||
if (START_CHAR(tty) != __DISABLED_CHAR)
|
|
||||||
return send_prio_char(tty, START_CHAR(tty));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
return 0;
|
break;
|
||||||
case TCFLSH:
|
case TCOON:
|
||||||
return tty_perform_flush(tty, arg);
|
if (tty->flow_stopped) {
|
||||||
case TIOCOUTQ:
|
tty->flow_stopped = 0;
|
||||||
return put_user(tty->driver->chars_in_buffer ?
|
start_tty(tty);
|
||||||
tty->driver->chars_in_buffer(tty) : 0,
|
}
|
||||||
(int __user *) arg);
|
break;
|
||||||
case TIOCINQ:
|
case TCIOFF:
|
||||||
retval = tty->read_cnt;
|
if (STOP_CHAR(tty) != __DISABLED_CHAR)
|
||||||
if (L_ICANON(tty))
|
return send_prio_char(tty, STOP_CHAR(tty));
|
||||||
retval = inq_canon(tty);
|
break;
|
||||||
return put_user(retval, (unsigned int __user *) arg);
|
case TCION:
|
||||||
case TIOCPKT:
|
if (START_CHAR(tty) != __DISABLED_CHAR)
|
||||||
{
|
return send_prio_char(tty, START_CHAR(tty));
|
||||||
int pktmode;
|
break;
|
||||||
|
|
||||||
if (tty->driver->type != TTY_DRIVER_TYPE_PTY ||
|
|
||||||
tty->driver->subtype != PTY_TYPE_MASTER)
|
|
||||||
return -ENOTTY;
|
|
||||||
if (get_user(pktmode, (int __user *) arg))
|
|
||||||
return -EFAULT;
|
|
||||||
if (pktmode) {
|
|
||||||
if (!tty->packet) {
|
|
||||||
tty->packet = 1;
|
|
||||||
tty->link->ctrl_status = 0;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
tty->packet = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
/* Try the mode commands */
|
return -EINVAL;
|
||||||
return tty_mode_ioctl(tty, file, cmd, arg);
|
|
||||||
}
|
}
|
||||||
}
|
return 0;
|
||||||
|
case TCFLSH:
|
||||||
|
return tty_perform_flush(tty, arg);
|
||||||
|
case TIOCOUTQ:
|
||||||
|
return put_user(tty->driver->chars_in_buffer ?
|
||||||
|
tty->driver->chars_in_buffer(tty) : 0,
|
||||||
|
(int __user *) arg);
|
||||||
|
case TIOCINQ:
|
||||||
|
retval = tty->read_cnt;
|
||||||
|
if (L_ICANON(tty))
|
||||||
|
retval = inq_canon(tty);
|
||||||
|
return put_user(retval, (unsigned int __user *) arg);
|
||||||
|
case TIOCPKT:
|
||||||
|
{
|
||||||
|
int pktmode;
|
||||||
|
|
||||||
|
if (tty->driver->type != TTY_DRIVER_TYPE_PTY ||
|
||||||
|
tty->driver->subtype != PTY_TYPE_MASTER)
|
||||||
|
return -ENOTTY;
|
||||||
|
if (get_user(pktmode, (int __user *) arg))
|
||||||
|
return -EFAULT;
|
||||||
|
if (pktmode) {
|
||||||
|
if (!tty->packet) {
|
||||||
|
tty->packet = 1;
|
||||||
|
tty->link->ctrl_status = 0;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
tty->packet = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
/* Try the mode commands */
|
||||||
|
return tty_mode_ioctl(tty, file, cmd, arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
EXPORT_SYMBOL(n_tty_ioctl);
|
EXPORT_SYMBOL(n_tty_ioctl);
|
||||||
|
Reference in New Issue
Block a user