Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 54958
b: refs/heads/master
c: c831c33
h: refs/heads/master
v: v3
  • Loading branch information
Matthias Kaehlcke authored and Linus Torvalds committed May 8, 2007
1 parent 3a647c6 commit e1fb9d4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 159dde93692ef549a0b2012c9f25feb4df638c9c
refs/heads/master: c831c338f0ad299fcd1592c6e4f30657480f39af
18 changes: 10 additions & 8 deletions trunk/drivers/char/vc_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
#include <linux/interrupt.h>
#include <linux/mm.h>
#include <linux/init.h>
#include <linux/mutex.h>
#include <linux/vt_kern.h>
#include <linux/selection.h>
#include <linux/kbd_kern.h>
#include <linux/console.h>
#include <linux/device.h>

#include <asm/uaccess.h>
#include <asm/byteorder.h>
#include <asm/unaligned.h>
Expand Down Expand Up @@ -69,11 +71,11 @@ static loff_t vcs_lseek(struct file *file, loff_t offset, int orig)
{
int size;

down(&con_buf_sem);
mutex_lock(&con_buf_mtx);
size = vcs_size(file->f_path.dentry->d_inode);
switch (orig) {
default:
up(&con_buf_sem);
mutex_unlock(&con_buf_mtx);
return -EINVAL;
case 2:
offset += size;
Expand All @@ -84,11 +86,11 @@ static loff_t vcs_lseek(struct file *file, loff_t offset, int orig)
break;
}
if (offset < 0 || offset > size) {
up(&con_buf_sem);
mutex_unlock(&con_buf_mtx);
return -EINVAL;
}
file->f_pos = offset;
up(&con_buf_sem);
mutex_unlock(&con_buf_mtx);
return file->f_pos;
}

Expand All @@ -105,7 +107,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
unsigned short *org = NULL;
ssize_t ret;

down(&con_buf_sem);
mutex_lock(&con_buf_mtx);

pos = *ppos;

Expand Down Expand Up @@ -262,7 +264,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
ret = read;
unlock_out:
release_console_sem();
up(&con_buf_sem);
mutex_unlock(&con_buf_mtx);
return ret;
}

Expand All @@ -279,7 +281,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
u16 *org0 = NULL, *org = NULL;
size_t ret;

down(&con_buf_sem);
mutex_lock(&con_buf_mtx);

pos = *ppos;

Expand Down Expand Up @@ -449,7 +451,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
unlock_out:
release_console_sem();

up(&con_buf_sem);
mutex_unlock(&con_buf_mtx);

return ret;
}
Expand Down
5 changes: 3 additions & 2 deletions trunk/drivers/char/vt.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
#include <linux/mm.h>
#include <linux/console.h>
#include <linux/init.h>
#include <linux/mutex.h>
#include <linux/vt_kern.h>
#include <linux/selection.h>
#include <linux/tiocl.h>
Expand Down Expand Up @@ -1952,7 +1953,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)
* kernel memory allocation is available.
*/
char con_buf[CON_BUF_SIZE];
DECLARE_MUTEX(con_buf_sem);
DEFINE_MUTEX(con_buf_mtx);

/* is_double_width() is based on the wcwidth() implementation by
* Markus Kuhn -- 2003-05-20 (Unicode 4.0)
Expand Down Expand Up @@ -2049,7 +2050,7 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co

/* At this point 'buf' is guaranteed to be a kernel buffer
* and therefore no access to userspace (and therefore sleeping)
* will be needed. The con_buf_sem serializes all tty based
* will be needed. The con_buf_mtx serializes all tty based
* console rendering and vcs write/read operations. We hold
* the console spinlock during the entire write.
*/
Expand Down
3 changes: 2 additions & 1 deletion trunk/include/linux/vt_kern.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/vt.h>
#include <linux/kd.h>
#include <linux/tty.h>
#include <linux/mutex.h>
#include <linux/console_struct.h>
#include <linux/mm.h>

Expand Down Expand Up @@ -82,7 +83,7 @@ void reset_vc(struct vc_data *vc);

#define CON_BUF_SIZE (CONFIG_BASE_SMALL ? 256 : PAGE_SIZE)
extern char con_buf[CON_BUF_SIZE];
extern struct semaphore con_buf_sem;
extern struct mutex con_buf_mtx;
extern char vt_dont_switch;

struct vt_spawn_console {
Expand Down

0 comments on commit e1fb9d4

Please sign in to comment.