Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f9e4acf3befd3b2903e01b3ef1bd344f03299826
Commit:     f9e4acf3befd3b2903e01b3ef1bd344f03299826
Parent:     d003fb70fd356d0684ee0cd37a785e058c8678de
Author:     Nick Piggin <[EMAIL PROTECTED]>
AuthorDate: Mon Feb 12 00:51:59 2007 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Mon Feb 12 09:48:28 2007 -0800

    [PATCH] inotify: read return val fix
    
    Fix for inotify read bug (bugzilla.kernel.org #6999)
    
    Problem Description:
    When reading from an inotify device with an insufficient sized buffer, 
read(2)
    will return 0 with no errno set. This is because of an logically incorrect
    action from the user program thus should return an more logical value. My
    suggestion is return -EINVAL as for bind(2).
    
    This patch is based on the proposal from Ryan <[EMAIL PROTECTED]>, and
    feedback from John McCutchan <[EMAIL PROTECTED]>.
    
    Return -EINVAL if we have not passed in enough buffer space to read a single
    inotify event, rather than 0 which indicates that there is nothing to read.
    
    Signed-off-by: Nick Piggin <[EMAIL PROTECTED]>
    Acked-by: "John McCutchan" <[EMAIL PROTECTED]>
    Cc: Ryan <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 fs/inotify_user.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/fs/inotify_user.c b/fs/inotify_user.c
index 55f6da5..9f2224f 100644
--- a/fs/inotify_user.c
+++ b/fs/inotify_user.c
@@ -455,8 +455,16 @@ static ssize_t inotify_read(struct file *file, char __user 
*buf,
                        break;
 
                kevent = inotify_dev_get_event(dev);
-               if (event_size + kevent->event.len > count)
+               if (event_size + kevent->event.len > count) {
+                       if (ret == 0 && count > 0) {
+                               /*
+                                * could not get a single event because we
+                                * didn't have enough buffer space.
+                                */
+                               ret = -EINVAL;
+                       }
                        break;
+               }
 
                if (copy_to_user(buf, &kevent->event, event_size)) {
                        ret = -EFAULT;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to