patch-2.4.27 linux-2.4.27/fs/devfs/base.c
Next file: linux-2.4.27/fs/devpts/inode.c
Previous file: linux-2.4.27/fs/cramfs/inode.c
Back to the patch index
Back to the overall index
- Lines: 51
- Date:
2004-08-07 16:26:05.968400770 -0700
- Orig file:
linux-2.4.26/fs/devfs/base.c
- Orig date:
2004-04-14 06:05:40.000000000 -0700
diff -urN linux-2.4.26/fs/devfs/base.c linux-2.4.27/fs/devfs/base.c
@@ -3312,7 +3312,7 @@
{
int done = FALSE;
int ival;
- loff_t pos, devname_offset, tlen, rpos;
+ loff_t pos, devname_offset, tlen, rpos, old_pos;
devfs_handle_t de;
struct devfsd_buf_entry *entry;
struct fs_info *fs_info = file->f_dentry->d_inode->i_sb->u.generic_sbp;
@@ -3363,8 +3363,8 @@
info->namelen = DEVFS_PATHLEN - pos - 1;
if (info->mode == 0) info->mode = de->mode;
devname_offset = info->devname - (char *) info;
- rpos = *ppos;
- if (rpos < devname_offset)
+ old_pos = rpos = *ppos;
+ if (rpos >= 0 && rpos < devname_offset)
{
/* Copy parts of the header */
tlen = devname_offset - rpos;
@@ -3390,7 +3390,7 @@
}
rpos += tlen;
}
- tlen = rpos - *ppos;
+ tlen = rpos - old_pos;
if (done)
{
devfs_handle_t parent;
@@ -3504,16 +3504,17 @@
loff_t *ppos)
{
ssize_t num;
+ loff_t n = *ppos;
char txt[80];
num = sprintf (txt, "Number of entries: %u number of bytes: %u\n",
stat_num_entries, stat_num_bytes) + 1;
/* Can't seek (pread) on this device */
if (ppos != &file->f_pos) return -ESPIPE;
- if (*ppos >= num) return 0;
- if (*ppos + len > num) len = num - *ppos;
- if ( copy_to_user (buf, txt + *ppos, len) ) return -EFAULT;
- *ppos += len;
+ if (n != (unsigned)n || n >= num) return 0;
+ if (len > num - n) len = num - n;
+ if ( copy_to_user (buf, txt + n, len) ) return -EFAULT;
+ *ppos = n + len;
return len;
} /* End Function stat_read */
#endif
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)