Bug 6999 - Return value irrelevant when reading from inotify fd failed.
Summary: Return value irrelevant when reading from inotify fd failed.
Status: RESOLVED CODE_FIX
Alias: None
Product: File System
Classification: Unclassified
Component: Other (show other bugs)
Hardware: i386 Linux
: P2 normal
Assignee: Nick Piggin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-13 08:26 UTC by Ryan
Modified: 2007-05-17 20:12 UTC (History)
1 user (show)

See Also:
Kernel Version: 2.6.17
Subsystem:
Regression: ---
Bisected commit-id:


Attachments
Test program to reproduce the described situation. (936 bytes, text/plain)
2006-08-13 08:29 UTC, Ryan
Details
Sample patch (427 bytes, patch)
2006-08-13 08:36 UTC, Ryan
Details | Diff
inotify fix (641 bytes, patch)
2007-02-01 17:31 UTC, Nick Piggin
Details | Diff

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?

Note You need to log in before you can comment on or make changes to this bug.