Bug 6999

Summary: Return value irrelevant when reading from inotify fd failed.
Product: File System Reporter: Ryan (wolf0403)
Component: OtherAssignee: Nick Piggin (nickpiggin)
Status: RESOLVED CODE_FIX    
Severity: normal CC: bunk
Priority: P2    
Hardware: i386   
OS: Linux   
Kernel Version: 2.6.17 Subsystem:
Regression: --- Bisected commit-id:
Attachments: Test program to reproduce the described situation.
Sample patch
inotify fix

Description Ryan 2006-08-13 08:26:15 UTC
Most recent kernel where this bug did not occur:
Distribution: Fedora Core 4
Hardware Environment: x86, 1G memory, IDE HDD
Software Environment: kernel 2.6.17-1.2142_FC4, glibc-2.3.5-10
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).

Steps to reproduce:
Test program will be provided.
Comment 1 Ryan 2006-08-13 08:29:08 UTC
Created attachment 8770 [details]
Test program to reproduce the described situation.

Sample output:
$ ./itest .
32 bytes left in queue.
read() returns 0 with msg Success
Comment 2 Ryan 2006-08-13 08:36:07 UTC
Created attachment 8771 [details]
Sample patch
Comment 3 John McCutchan 2007-01-24 12:07:23 UTC
hey, I don't think the patch is correct. If the user passes in a buffer large
enough to hold at least one event, but there are more in the queue that won't
fit, they'll still get -EINVAL.
Comment 4 Nick Piggin 2007-02-01 17:31:19 UTC
Created attachment 10253 [details]
inotify fix

How about this patch, then?