From: James S. <jsi...@us...> - 2005-03-21 20:26:39
|
Update of /cvsroot/linuxconsole/ruby/ruby-2.6/drivers/char In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25343 Modified Files: vc_screen.c Log Message: VCSA now updated to linus tree. I should send a patch with this work to linus. Index: vc_screen.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/ruby-2.6/drivers/char/vc_screen.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- vc_screen.c 24 Aug 2004 05:31:53 -0000 1.7 +++ vc_screen.c 21 Mar 2005 20:26:31 -0000 1.8 @@ -40,9 +40,6 @@ #include <asm/byteorder.h> #include <asm/unaligned.h> -#undef attr -#undef org -#undef addr #define HEADER_SIZE 4 unsigned short *screen_pos(struct vc_data *vc, int w_offset, int viewed) @@ -78,36 +75,28 @@ } } - static int -vcs_size(struct inode *inode) +vcs_size(struct vc_data *vc, unsigned long attr) { - int minor = iminor(inode); - int currcons = minor & 127; - struct vc_data *vc; - int size; - - vc = find_vc(currcons); - - if (!vc) - return -ENXIO; - - size = vc->vc_rows * vc->vc_cols; + int size = vc->vc_rows * vc->vc_cols; - if (minor & 128) + if (attr) size = 2*size + HEADER_SIZE; return size; } static loff_t vcs_lseek(struct file *file, loff_t offset, int orig) { + struct inode *inode = file->f_dentry->d_inode; + struct vc_data *vc = file->private_data; + long attr = iminor(inode) & 128; int size; - down(&con_buf_sem); - size = vcs_size(file->f_dentry->d_inode); + down(&vc->display_fg->lock); + size = vcs_size(vc, attr); switch (orig) { default: - up(&con_buf_sem); + up(&vc->display_fg->lock); return -EINVAL; case 2: offset += size; @@ -118,11 +107,11 @@ break; } if (offset < 0 || offset > size) { - up(&con_buf_sem); + up(&vc->display_fg->lock); return -EINVAL; } file->f_pos = offset; - up(&con_buf_sem); + up(&vc->display_fg->lock); return file->f_pos; } @@ -130,36 +119,29 @@ 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); - struct vc_data *vc; - long pos; - long viewed, attr, read; - int col, maxcol; + struct vc_data *vc = file->private_data; + long attr = iminor(inode) & 128; unsigned short *org = NULL; - ssize_t ret; - - down(&con_buf_sem); + long viewed, read, pos; + ssize_t ret = -ENXIO; + int col, maxcol; + if (!vc) + return ret; + down(&vc->display_fg->lock); + pos = *ppos; - - /* Select the proper current console and verify + /* + * Select the proper current console and verify * sanity of the situation under the console lock. */ acquire_console_sem(); - attr = (currcons & 128); - currcons = (currcons & 127); - if (currcons == 0) { + if (IS_VISIBLE) { viewed = 1; } else { viewed = 0; } - ret = -ENXIO; - - vc = find_vc(currcons); - - if (!vc) - goto unlock_out; ret = -EINVAL; if (pos < 0) @@ -176,15 +158,15 @@ * as copy_to_user at the end of this loop * could sleep. */ - size = vcs_size(inode); + size = vcs_size(vc, attr); if (pos >= size) break; if (count > size - pos) count = size - pos; this_round = count; - if (this_round > CON_BUF_SIZE) - this_round = CON_BUF_SIZE; + if (this_round > BUF_SIZE) + this_round = BUF_SIZE; /* Perform the whole read into the local con_buf. * Then we can drop the console spinlock and safely @@ -216,8 +198,8 @@ con_buf_start += p; this_round += p; - if (this_round > CON_BUF_SIZE) { - this_round = CON_BUF_SIZE; + if (this_round > BUF_SIZE) { + this_round = BUF_SIZE; orig_count = this_round - p; } @@ -236,7 +218,7 @@ * space in buffer. */ con_buf_start++; - if (this_round < CON_BUF_SIZE) + if (this_round < BUF_SIZE) this_round++; else orig_count--; @@ -295,7 +277,7 @@ ret = read; unlock_out: release_console_sem(); - up(&con_buf_sem); + up(&vc->display_fg->lock); return ret; } @@ -303,40 +285,32 @@ 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); - struct vc_data *vc; - long pos; - long viewed, attr, size, written; - char *con_buf0; - int col, maxcol; + struct vc_data *vc = file->private_data; + long viewed, size, written, pos; + long attr = iminor(inode) & 128; u16 *org0 = NULL, *org = NULL; - size_t ret; - - down(&con_buf_sem); + size_t ret = -ENXIO; + int col, maxcol; + char *con_buf0; - pos = *ppos; + if (!vc) + return ret; + down(&vc->display_fg->lock); - /* Select the proper current console and verify + /* + * Select the proper current console and verify * sanity of the situation under the console lock. */ acquire_console_sem(); - attr = (currcons & 128); - currcons = (currcons & 127); - - if (currcons == 0) { + pos = *ppos; + if (IS_VISIBLE) { viewed = 1; } else { viewed = 0; } - ret = -ENXIO; - vc = find_vc(currcons); - - if (!vc) - goto unlock_out; - - size = vcs_size(inode); + size = vcs_size(vc, attr); ret = -EINVAL; if (pos < 0 || pos > size) goto unlock_out; @@ -348,8 +322,8 @@ size_t orig_count; long p; - if (this_round > CON_BUF_SIZE) - this_round = CON_BUF_SIZE; + if (this_round > BUF_SIZE) + this_round = BUF_SIZE; /* Temporarily drop the console lock so that we can read * in the write data from userspace safely. @@ -371,11 +345,12 @@ } } - /* The vcs_size might have changed while we slept to grab + /* + * The vcs_size might have changed while we slept to grab * the user buffer, so recheck. * Return data written up to now on failure. */ - size = vcs_size(inode); + size = vcs_size(vc, attr); if (pos >= size) break; if (this_round > size - pos) @@ -481,9 +456,7 @@ unlock_out: release_console_sem(); - - up(&con_buf_sem); - + up(&vc->display_fg->lock); return ret; } @@ -491,9 +464,11 @@ vcs_open(struct inode *inode, struct file *filp) { unsigned int currcons = iminor(inode) & 127; + struct vc_data *vc = find_vc(currcons); - if (currcons && !find_vc(currcons)) + if (!vc) return -ENXIO; + filp->private_data = vc; return 0; } |