VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / drivers / char / vc_screen.c
index c357ab7..c5c6b5e 100644 (file)
@@ -70,11 +70,11 @@ static loff_t vcs_lseek(struct file *file, loff_t offset, int orig)
 {
        int size;
 
-       lock_kernel();
+       down(&con_buf_sem);
        size = vcs_size(file->f_dentry->d_inode);
        switch (orig) {
                default:
-                       unlock_kernel();
+                       up(&con_buf_sem);
                        return -EINVAL;
                case 2:
                        offset += size;
@@ -85,28 +85,21 @@ static loff_t vcs_lseek(struct file *file, loff_t offset, int orig)
                        break;
        }
        if (offset < 0 || offset > size) {
-               unlock_kernel();
+               up(&con_buf_sem);
                return -EINVAL;
        }
        file->f_pos = offset;
-       unlock_kernel();
+       up(&con_buf_sem);
        return file->f_pos;
 }
 
-/* We share this temporary buffer with the console write code
- * so that we can easily avoid touching user space while holding the
- * console spinlock.
- */
-extern char con_buf[PAGE_SIZE];
-#define CON_BUF_SIZE   PAGE_SIZE
-extern struct semaphore con_buf_sem;
 
 static ssize_t
 vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 {
        struct inode *inode = file->f_dentry->d_inode;
        unsigned int currcons = iminor(inode);
-       long pos = *ppos;
+       long pos;
        long viewed, attr, read;
        int col, maxcol;
        unsigned short *org = NULL;
@@ -114,6 +107,8 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 
        down(&con_buf_sem);
 
+       pos = *ppos;
+
        /* Select the proper current console and verify
         * sanity of the situation under the console lock.
         */
@@ -275,7 +270,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 {
        struct inode *inode = file->f_dentry->d_inode;
        unsigned int currcons = iminor(inode);
-       long pos = *ppos;
+       long pos;
        long viewed, attr, size, written;
        char *con_buf0;
        int col, maxcol;
@@ -284,6 +279,8 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 
        down(&con_buf_sem);
 
+       pos = *ppos;
+
        /* Select the proper current console and verify
         * sanity of the situation under the console lock.
         */