[PATCH 4/5] pagemap: Make /proc/kpage{count,flags} return EINVAL (not EIO) on unaligned read.

From: Thomas Tuttle
Date: Thu Jun 05 2008 - 11:07:49 EST


If a process tries to read at a position that's not a multiple of 8,
or for a count that's not a multiple of 8, they've passed an invalid
argument to read (for this file), so we should return EINVAL.
From f03729d3da3a7e38e3d8fba2826ea9dd88baaaf1 Mon Sep 17 00:00:00 2001
From: Thomas Tuttle <ttuttle@xxxxxxxxxx>
Date: Thu, 5 Jun 2008 10:49:01 -0400
Subject: [PATCH] Make /proc/kpage{count,flags} return EINVAL (not EIO) on unaligned read.

This is what /proc/pid/pagemap does, and seems to make more sense, as the
error is really that the read had an invalid argument (location or size),
not that the underlying data could not be accessed.

Signed-off-by: Thomas Tuttle <ttuttle@xxxxxxxxxx>
---
fs/proc/proc_misc.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 5a16090..7e277f2 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -716,7 +716,7 @@ static ssize_t kpagecount_read(struct file *file, char __user *buf,
pfn = src / KPMSIZE;
count = min_t(size_t, count, (max_pfn * KPMSIZE) - src);
if (src & KPMMASK || count & KPMMASK)
- return -EIO;
+ return -EINVAL;

while (count > 0) {
ppage = NULL;
@@ -782,7 +782,7 @@ static ssize_t kpageflags_read(struct file *file, char __user *buf,
pfn = src / KPMSIZE;
count = min_t(unsigned long, count, (max_pfn * KPMSIZE) - src);
if (src & KPMMASK || count & KPMMASK)
- return -EIO;
+ return -EINVAL;

while (count > 0) {
ppage = NULL;
--
1.5.3.6