Re: fanotify read returns with errno == EOPENSTALE
From: Amir Goldstein <amir73il@gmail.com>
Date: 2017-03-23 13:47:09
Also in:
linux-api, linux-fsdevel
On Thu, Mar 23, 2017 at 8:43 AM, Marko Rauhamaa [off-list ref] wrote:
Jeff Layton [off-list ref]:quoted
It was definitely not the intention to leak this error code to userland. EOPENSTALE is not a POSIX sanctioned error code, so applications generally don't know anything about it and will be confused.Got it. I will try to work on a reproduction and make a proper bug report.
Try this: - watch a single file for permissions events (so you will only have one event in the queue) - open file from client to generate single event (don't read event yet) - remove file from server (to make it stale) - read event (with stale file)
quoted
I haven't looked closely at this particular problem, but IIRC we usually just translate EOPENSTALE to ESTALE, and that may be all that needs to be done here. If this happened in the RHEL kernel, then please do open a bug with Red Hat and we'll get it straightened out.ESTALE has not been mentioned as a possible error code from an fanotify read. Most importantly, since read fails, I suppose there is no recovery but you must close the fanotify fd and call fanotify_init() again. Or should I just ignore it and read on? If so, why bother returning the error from the kernel in the first place?
Oh my. I completely misread your report before. I though you were trying to read from the event->fd. Now I understand that you mean read from fanotify fd. That will definitely return the error, but only in the special case where open error happened on the first event being read to the buffer. If error happens after adding some events to the buffer, fanotify process will not know about this. Regular event will be silently dropped and permission event will be denied.