Вопрос

I'm using a single inotify file descriptor to monitor many busy directories for several events, including IN_MOVED_TO and IN_MOVED_FROM.

I have a loop that calls read on it (which blocks until there is data to be read) and handles events as they happen.

When a file is moved between two of the directories being monitored, two inotify_events are written to the inotify file descriptor: one with the IN_MOVED_TO bit set in mask and one with IN_MOVED_FROM, both with the same cookie.

Is it guaranteed that both events will be buffered with the same call to read, or might I need to call it once to buffer one event and again to buffer the next?

Это было полезно?

Решение

AFAIK, there isn't such a gurantee.
What we can rely on is only the fact that the two events(IN_MOVED_FROM, IN_MOVED_TO) on a rename operation are assocaited with the same cookie.

Any assumption except above is unreliable, for instance:

  • The two events will come sequentially(one comes right after the other).
  • The two events will be appear in the same read system call together.
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top