[PATCH] tty locking on resize
The current kernel serializes console resizes but does not serialize the resize against the tty structure updates. This means that while two parallel resizes cannot mess up the console you can get incorrect results reported. Secondly while doing this I added vc_lock_resize() to lock and resize the console. This leaves all knowledge of the console_sem in the vt/console driver and kicks it out of the tty layer, which is good Thirdly while doing this I decided I couldn't stand "disallocate" any longer so I switched it to "deallocate". Signed-off-by: Alan Cox <alan@redhat.com> Cc: Paul Fulghum <paulkf@microgate.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
@@ -96,7 +96,7 @@ do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm, struct kbd_str
|
||||
if (!perm)
|
||||
return -EPERM;
|
||||
if (!i && v == K_NOSUCHMAP) {
|
||||
/* disallocate map */
|
||||
/* deallocate map */
|
||||
key_map = key_maps[s];
|
||||
if (s && key_map) {
|
||||
key_maps[s] = NULL;
|
||||
@@ -819,20 +819,20 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
|
||||
if (arg > MAX_NR_CONSOLES)
|
||||
return -ENXIO;
|
||||
if (arg == 0) {
|
||||
/* disallocate all unused consoles, but leave 0 */
|
||||
/* deallocate all unused consoles, but leave 0 */
|
||||
acquire_console_sem();
|
||||
for (i=1; i<MAX_NR_CONSOLES; i++)
|
||||
if (! VT_BUSY(i))
|
||||
vc_disallocate(i);
|
||||
vc_deallocate(i);
|
||||
release_console_sem();
|
||||
} else {
|
||||
/* disallocate a single console, if possible */
|
||||
/* deallocate a single console, if possible */
|
||||
arg--;
|
||||
if (VT_BUSY(arg))
|
||||
return -EBUSY;
|
||||
if (arg) { /* leave 0 */
|
||||
acquire_console_sem();
|
||||
vc_disallocate(arg);
|
||||
vc_deallocate(arg);
|
||||
release_console_sem();
|
||||
}
|
||||
}
|
||||
@@ -847,11 +847,8 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
|
||||
if (get_user(ll, &vtsizes->v_rows) ||
|
||||
get_user(cc, &vtsizes->v_cols))
|
||||
return -EFAULT;
|
||||
for (i = 0; i < MAX_NR_CONSOLES; i++) {
|
||||
acquire_console_sem();
|
||||
vc_resize(vc_cons[i].d, cc, ll);
|
||||
release_console_sem();
|
||||
}
|
||||
for (i = 0; i < MAX_NR_CONSOLES; i++)
|
||||
vc_lock_resize(vc_cons[i].d, cc, ll);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user