diff options
author | Paul Fulghum <paulkf@microgate.com> | 2007-05-11 01:22:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-11 11:29:35 -0400 |
commit | e10cc1df1d2014f68a4bdcf73f6dd122c4561f94 (patch) | |
tree | e528fde48ca3b09168d8879a57fb220195c4e8ea /drivers/char/tty_io.c | |
parent | 108f39a1b3b1e4b28ca8cc156f06171445499d21 (diff) |
tty: add compat_ioctl
Add compat_ioctl method for tty code to allow processing of 32 bit ioctl
calls on 64 bit systems by tty core, tty drivers, and line disciplines.
Based on patch by Arnd Bergmann:
http://www.uwsg.iu.edu/hypermail/linux/kernel/0511.0/1732.html
[akpm@linux-foundation.org: make things static]
Signed-off-by: Paul Fulghum <paulkf@microgate.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/tty_io.c')
-rw-r--r-- | drivers/char/tty_io.c | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index fc662e4ce58a..fe62c2170d01 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -151,6 +151,12 @@ static int tty_open(struct inode *, struct file *); | |||
151 | static int tty_release(struct inode *, struct file *); | 151 | static int tty_release(struct inode *, struct file *); |
152 | int tty_ioctl(struct inode * inode, struct file * file, | 152 | int tty_ioctl(struct inode * inode, struct file * file, |
153 | unsigned int cmd, unsigned long arg); | 153 | unsigned int cmd, unsigned long arg); |
154 | #ifdef CONFIG_COMPAT | ||
155 | static long tty_compat_ioctl(struct file * file, unsigned int cmd, | ||
156 | unsigned long arg); | ||
157 | #else | ||
158 | #define tty_compat_ioctl NULL | ||
159 | #endif | ||
154 | static int tty_fasync(int fd, struct file * filp, int on); | 160 | static int tty_fasync(int fd, struct file * filp, int on); |
155 | static void release_tty(struct tty_struct *tty, int idx); | 161 | static void release_tty(struct tty_struct *tty, int idx); |
156 | static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty); | 162 | static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty); |
@@ -1143,8 +1149,8 @@ static unsigned int hung_up_tty_poll(struct file * filp, poll_table * wait) | |||
1143 | return POLLIN | POLLOUT | POLLERR | POLLHUP | POLLRDNORM | POLLWRNORM; | 1149 | return POLLIN | POLLOUT | POLLERR | POLLHUP | POLLRDNORM | POLLWRNORM; |
1144 | } | 1150 | } |
1145 | 1151 | ||
1146 | static int hung_up_tty_ioctl(struct inode * inode, struct file * file, | 1152 | static long hung_up_tty_ioctl(struct file * file, |
1147 | unsigned int cmd, unsigned long arg) | 1153 | unsigned int cmd, unsigned long arg) |
1148 | { | 1154 | { |
1149 | return cmd == TIOCSPGRP ? -ENOTTY : -EIO; | 1155 | return cmd == TIOCSPGRP ? -ENOTTY : -EIO; |
1150 | } | 1156 | } |
@@ -1155,6 +1161,7 @@ static const struct file_operations tty_fops = { | |||
1155 | .write = tty_write, | 1161 | .write = tty_write, |
1156 | .poll = tty_poll, | 1162 | .poll = tty_poll, |
1157 | .ioctl = tty_ioctl, | 1163 | .ioctl = tty_ioctl, |
1164 | .compat_ioctl = tty_compat_ioctl, | ||
1158 | .open = tty_open, | 1165 | .open = tty_open, |
1159 | .release = tty_release, | 1166 | .release = tty_release, |
1160 | .fasync = tty_fasync, | 1167 | .fasync = tty_fasync, |
@@ -1167,6 +1174,7 @@ static const struct file_operations ptmx_fops = { | |||
1167 | .write = tty_write, | 1174 | .write = tty_write, |
1168 | .poll = tty_poll, | 1175 | .poll = tty_poll, |
1169 | .ioctl = tty_ioctl, | 1176 | .ioctl = tty_ioctl, |
1177 | .compat_ioctl = tty_compat_ioctl, | ||
1170 | .open = ptmx_open, | 1178 | .open = ptmx_open, |
1171 | .release = tty_release, | 1179 | .release = tty_release, |
1172 | .fasync = tty_fasync, | 1180 | .fasync = tty_fasync, |
@@ -1179,6 +1187,7 @@ static const struct file_operations console_fops = { | |||
1179 | .write = redirected_tty_write, | 1187 | .write = redirected_tty_write, |
1180 | .poll = tty_poll, | 1188 | .poll = tty_poll, |
1181 | .ioctl = tty_ioctl, | 1189 | .ioctl = tty_ioctl, |
1190 | .compat_ioctl = tty_compat_ioctl, | ||
1182 | .open = tty_open, | 1191 | .open = tty_open, |
1183 | .release = tty_release, | 1192 | .release = tty_release, |
1184 | .fasync = tty_fasync, | 1193 | .fasync = tty_fasync, |
@@ -1189,7 +1198,8 @@ static const struct file_operations hung_up_tty_fops = { | |||
1189 | .read = hung_up_tty_read, | 1198 | .read = hung_up_tty_read, |
1190 | .write = hung_up_tty_write, | 1199 | .write = hung_up_tty_write, |
1191 | .poll = hung_up_tty_poll, | 1200 | .poll = hung_up_tty_poll, |
1192 | .ioctl = hung_up_tty_ioctl, | 1201 | .unlocked_ioctl = hung_up_tty_ioctl, |
1202 | .compat_ioctl = hung_up_tty_ioctl, | ||
1193 | .release = tty_release, | 1203 | .release = tty_release, |
1194 | }; | 1204 | }; |
1195 | 1205 | ||
@@ -3357,6 +3367,32 @@ int tty_ioctl(struct inode * inode, struct file * file, | |||
3357 | return retval; | 3367 | return retval; |
3358 | } | 3368 | } |
3359 | 3369 | ||
3370 | #ifdef CONFIG_COMPAT | ||
3371 | static long tty_compat_ioctl(struct file * file, unsigned int cmd, | ||
3372 | unsigned long arg) | ||
3373 | { | ||
3374 | struct inode *inode = file->f_dentry->d_inode; | ||
3375 | struct tty_struct *tty = file->private_data; | ||
3376 | struct tty_ldisc *ld; | ||
3377 | int retval = -ENOIOCTLCMD; | ||
3378 | |||
3379 | if (tty_paranoia_check(tty, inode, "tty_ioctl")) | ||
3380 | return -EINVAL; | ||
3381 | |||
3382 | if (tty->driver->compat_ioctl) { | ||
3383 | retval = (tty->driver->compat_ioctl)(tty, file, cmd, arg); | ||
3384 | if (retval != -ENOIOCTLCMD) | ||
3385 | return retval; | ||
3386 | } | ||
3387 | |||
3388 | ld = tty_ldisc_ref_wait(tty); | ||
3389 | if (ld->compat_ioctl) | ||
3390 | retval = ld->compat_ioctl(tty, file, cmd, arg); | ||
3391 | tty_ldisc_deref(ld); | ||
3392 | |||
3393 | return retval; | ||
3394 | } | ||
3395 | #endif | ||
3360 | 3396 | ||
3361 | /* | 3397 | /* |
3362 | * This implements the "Secure Attention Key" --- the idea is to | 3398 | * This implements the "Secure Attention Key" --- the idea is to |
@@ -3689,6 +3725,7 @@ void tty_set_operations(struct tty_driver *driver, | |||
3689 | driver->write_room = op->write_room; | 3725 | driver->write_room = op->write_room; |
3690 | driver->chars_in_buffer = op->chars_in_buffer; | 3726 | driver->chars_in_buffer = op->chars_in_buffer; |
3691 | driver->ioctl = op->ioctl; | 3727 | driver->ioctl = op->ioctl; |
3728 | driver->compat_ioctl = op->compat_ioctl; | ||
3692 | driver->set_termios = op->set_termios; | 3729 | driver->set_termios = op->set_termios; |
3693 | driver->throttle = op->throttle; | 3730 | driver->throttle = op->throttle; |
3694 | driver->unthrottle = op->unthrottle; | 3731 | driver->unthrottle = op->unthrottle; |