Comment 4 for bug 773260

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

To give this a more repeatable test, here is a python file which can be used to verify. When I do

  (sudo bash)
  mkdir src tgt
  mount -t ecryptfs src tgt
  (in window 1):
  python inotify_test.py
  (in window 2):
  echo hi > hi
  echo there >> hi

I see:
root@ecryptfs-natty-amd64:~# python inotify_test.py
Create: /home/serge/src/hi
MOdified: /home/serge/src/hi
MOdified: /home/serge/src/hi

so the modified inotify events are sent, but the closed-write are not.

=========================
import os
from pyinotify import WatchManager, Notifier, ThreadedNotifier, EventsCodes, ProcessEvent

wm = WatchManager()

mask = EventsCodes.ALL_FLAGS['IN_DELETE'] | EventsCodes.ALL_FLAGS['IN_CREATE'] | EventsCodes.ALL_FLAGS['IN_MODIFY'] | EventsCodes.ALL_FLAGS['IN_CLOSE_WRITE'] # watched events

class PTmp(ProcessEvent):
    def process_IN_CREATE(self, event):
        print "Create: %s" % os.path.join(event.path, event.name)

    def process_IN_DELETE(self, event):
        print "Remove: %s" % os.path.join(event.path, event.name)

    def process_IN_MODIFY(self, event):
        print "MOdified: %s" % os.path.join(event.path, event.name)

    def process_IN_CLOSE_WRITE(self, event):
        print "closed write: %s" % os.path.join(event.path, event.name)

notifier = Notifier(wm, PTmp())

wdd = wm.add_watch('/home/serge/src/', mask, rec=True)

while True: # loop forever
    try:
        # process the queue of events as explained above
        notifier.process_events()
        if notifier.check_events():
            # read notified events and enqeue them
            notifier.read_events()
        # you can do some tasks here...
    except KeyboardInterrupt:
        # destroy the inotify's instance on this interrupt (stop monitoring)
        notifier.stop()
        break
========