public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 4/5] pagemap: Make /proc/kpage{count,flags} return EINVAL (not EIO) on unaligned read.
@ 2008-06-05 15:07 Thomas Tuttle
  2008-06-05 16:24 ` Matt Mackall
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Tuttle @ 2008-06-05 15:07 UTC (permalink / raw)
  To: mpm, akpm, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 200 bytes --]

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.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0004-Make-proc-kpage-count-flags-return-EINVAL-not-EIO.patch --]
[-- Type: text/x-patch; name=0004-Make-proc-kpage-count-flags-return-EINVAL-not-EIO.patch, Size: 1308 bytes --]

From f03729d3da3a7e38e3d8fba2826ea9dd88baaaf1 Mon Sep 17 00:00:00 2001
From: Thomas Tuttle <ttuttle@google.com>
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@google.com>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 4/5] pagemap: Make /proc/kpage{count,flags} return EINVAL (not EIO) on unaligned read.
  2008-06-05 15:07 [PATCH 4/5] pagemap: Make /proc/kpage{count,flags} return EINVAL (not EIO) on unaligned read Thomas Tuttle
@ 2008-06-05 16:24 ` Matt Mackall
  0 siblings, 0 replies; 2+ messages in thread
From: Matt Mackall @ 2008-06-05 16:24 UTC (permalink / raw)
  To: Thomas Tuttle; +Cc: akpm, linux-kernel


On Thu, 2008-06-05 at 11:07 -0400, Thomas Tuttle wrote:
> 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.

This patch should probably precede your 3/5.

-- 
Mathematics is the supreme nostalgia of our time.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-06-05 16:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-05 15:07 [PATCH 4/5] pagemap: Make /proc/kpage{count,flags} return EINVAL (not EIO) on unaligned read Thomas Tuttle
2008-06-05 16:24 ` Matt Mackall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox