aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/mem.c
diff options
context:
space:
mode:
authorKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>2010-10-01 17:20:22 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2010-10-25 21:18:21 -0400
commit4a3956c790290efeb647bbb0c3a90476bb57800e (patch)
tree18abb41325273d23ae271e49627f01054c5baeb6 /drivers/char/mem.c
parentba10f486658c0ca1bc84c936f6a996e40d071453 (diff)
vfs: introduce FMODE_UNSIGNED_OFFSET for allowing negative f_pos
Now, rw_verify_area() checsk f_pos is negative or not. And if negative, returns -EINVAL. But, some special files as /dev/(k)mem and /proc/<pid>/mem etc.. has negative offsets. And we can't do any access via read/write to the file(device). So introduce FMODE_UNSIGNED_OFFSET to allow negative file offsets. Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Al Viro <viro@ZenIV.linux.org.uk> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/char/mem.c')
-rw-r--r--drivers/char/mem.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index e985b1c2730e..1256454b2d43 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -876,6 +876,10 @@ static int memory_open(struct inode *inode, struct file *filp)
876 if (dev->dev_info) 876 if (dev->dev_info)
877 filp->f_mapping->backing_dev_info = dev->dev_info; 877 filp->f_mapping->backing_dev_info = dev->dev_info;
878 878
879 /* Is /dev/mem or /dev/kmem ? */
880 if (dev->dev_info == &directly_mappable_cdev_bdi)
881 filp->f_mode |= FMODE_UNSIGNED_OFFSET;
882
879 if (dev->fops->open) 883 if (dev->fops->open)
880 return dev->fops->open(inode, filp); 884 return dev->fops->open(inode, filp);
881 885