#14834: wxFileSystemWatcher: Add wxFSW_EVENT_UNMOUNT flag for inotify's IN_UNMOUNT

8 views
Skip to first unread message

wxTrac

unread,
Nov 16, 2012, 3:40:24 PM11/16/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14834>

#14834: wxFileSystemWatcher: Add wxFSW_EVENT_UNMOUNT flag for inotify's IN_UNMOUNT
-----------------------------------------------------+----------------------
Reporter: dghart | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 2.9.5
Component: base | Version: 2.9-svn
Keywords: wxFileSystemWatcher wxFSW_EVENT_UNMOUNT | Blockedby:
Patch: 1 | Blocking:
-----------------------------------------------------+----------------------
Inotify emits an IN_UNMOUNT event when a watched item's filesystem is
unmounted. wxFileSystemWatcher currently treats this event as an error;
I'm not sure why. The attached patch (which should be applied after the
IN_ATTRIB one but doesn't depend it) converts it to wxFSW_EVENT_UNMOUNT
which I've added to the wxFSWFlags enum (using the IN_UNMOUNT value for no
important reason). It shouldn't be included in wxFSW_EVENT_ALL as
IN_UNMOUNT is not intended to be a user-requested watch and is outside the
INOTIFY_ADD_WATCH bit-mask.

As unmounting is not entirely cross-platform, I've #if def.ed
wxFSW_EVENT_UNMOUNT in common code. In the future, NOTE_REVOKE looks like
the best kqueue match; this is currently ignored.

I can't think of a good way to add a test for this, but it can be seen to
work in the fswatcher sample: mount something, watch a dir inside that
filesystem, then unmount it.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14834>

wxTrac

unread,
Nov 17, 2012, 6:13:28 PM11/17/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14834#comment:1>

#14834: wxFileSystemWatcher: Add wxFSW_EVENT_UNMOUNT flag for inotify's IN_UNMOUNT
-----------------------------------------------------+----------------------
Reporter: dghart | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 3.0
Component: base | Version: 2.9-svn
Keywords: wxFileSystemWatcher wxFSW_EVENT_UNMOUNT | Blockedby:
Patch: 1 | Blocking:
-----------------------------------------------------+----------------------
Changes (by vadz):

* milestone: 2.9.5 => 3.0


Comment:

I wonder how does this work under Windows and OS X right now. I.e. if the
directory is unmounted (or a disk is ejected under Windows), do we get an
error or nothing at all? If it's the latter, then this patch is fine
(nitpick: just need "@since 2.9.5" in the docs), but if this results in
errors under the other platforms then giving an error under Linux doesn't
seem like such a bad idea.

Would it be possible for you to test how does this behave there please?


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14834#comment:1>

wxTrac

unread,
Nov 18, 2012, 12:57:54 PM11/18/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14834#comment:2>

#14834: wxFileSystemWatcher: Add wxFSW_EVENT_UNMOUNT flag for inotify's IN_UNMOUNT
-----------------------------------------------------+----------------------
Reporter: dghart | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 3.0
Component: base | Version: 2.9-svn
Keywords: wxFileSystemWatcher wxFSW_EVENT_UNMOUNT | Blockedby:
Patch: 1 | Blocking:
-----------------------------------------------------+----------------------

Comment(by dghart):

I have no way of testing OS X. The code contains nflags &= ~NOTE_REVOKE,
so I suspect it does nothing.

On ejecting a CD in winXP, wxIOCPThread::ProcessNativeEvents received no
event of any sort. (It's possible that being in a virtualbox guest
affected this, but XP itself did notice the CD and its removal.)

I've also now tested without the patch in wxGTK and found the
errors/warnings code is broken. Prior to the r72961 change, it failed as
GetErrorDescription() called Watcher2NativeFlags() and got back
IN_ALL_EVENTS. This isn't in the list of known errors, so
GetErrorDescription() asserted. Later GetFSWEventChangeTypeName() asserted
too as it doesn't handle wxFSW_EVENT_WARNING or wxFSW_EVENT_ERROR. Since
r72961 there are similar problems. These are fixed in errors.diff, which
is needed whatever the IN_UNMOUNT decision.

I've redone unmount.diff to apply over errors.diff, and also fixed the
doc.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14834#comment:2>

wxTrac

unread,
Nov 19, 2012, 7:52:03 AM11/19/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14834#comment:3>

#14834: wxFileSystemWatcher: Add wxFSW_EVENT_UNMOUNT flag for inotify's IN_UNMOUNT
-----------------------------------------------------+----------------------
Reporter: dghart | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 3.0
Component: base | Version: 2.9-svn
Keywords: wxFileSystemWatcher wxFSW_EVENT_UNMOUNT | Blockedby:
Patch: 1 | Blocking:
-----------------------------------------------------+----------------------

Comment(by VZ):

(In [72986]) Convert wxFSW_EVENT_{WARNING,ERROR} to string correctly.

Previously these types were not handled at all, resulting in asserts.

See #14834.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14834#comment:3>

wxTrac

unread,
Nov 19, 2012, 7:52:20 AM11/19/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14834#comment:4>

#14834: wxFileSystemWatcher: Add wxFSW_EVENT_UNMOUNT flag for inotify's IN_UNMOUNT
--------------------------+-------------------------------------------------
Reporter: dghart | Owner:
Type: enhancement | Status: closed
Priority: normal | Milestone: 3.0
Component: base | Version: 2.9-svn
Resolution: fixed | Keywords: wxFileSystemWatcher wxFSW_EVENT_UNMOUNT
Blockedby: | Patch: 1
Blocking: |
--------------------------+-------------------------------------------------
Changes (by VZ):

* status: new => closed
* resolution: => fixed


Comment:

(In [72987]) Add wxFSW_EVENT_UNMOUNT wxFileSystemWatcher flag and
implement it for Linux.

This flag generates the corresponding event when the file system
containing
the watched directory is unmounted. Currently it is only implemented for
Linux where unmounting now generates this event instead of an error.

Closes #14834.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14834#comment:4>
Reply all
Reply to author
Forward
0 new messages