inotify_init()

QNX SDP8.0C Library ReferenceAPIDeveloper

Initialize the inode notify system

Synopsis:

#include <sys/inotify.h>

int inotify_init( void );

Library:

libfsnotify

Use the -l fsnotify option to qcc to link against this library.

Description:

The inotify_init() function initializes the inode notify (inotify) system that you can use to watch for filesystem events.

Note:
This function opens the file /dev/fsnotify, which the filesystem event manager (fsevmgr) creates and owns. If your process doesn't have read permission for this path or fsevmgr is not running, the function fails.

The basic steps for using the inotify system are as follows:

  • Initialize the inotify system by calling inotify_init(), saving the file descriptor that it returns.
  • Use inotify_add_watch() to add or modify a watch for a given file or directory.
  • Read the filesystem events (of type struct inotify_event) from the file descriptor returned by inotify_init().
  • To remove a watch, call inotify_rm_watch().
  • To remove all watches and shut down inotify, close the file descriptor returned by inotify_init().

While the QNX OS inotify implementation follows the same semantics as the Linux implementation, the behavior differs from Linux due to the kernel and filesystem models employed.

For an overview of inotify, see http://www.linuxjournal.com/article/8478?page=0,0 in the Linux Journal, but note that there are differences between the Linux and QNX OS implementations. Currently, only io-blk.so-based filesystems and devf-ram-based filesystems support inotify.

Returns:

A file descriptor for the inotify mailbox, or -1 if an error occurred (errno is set).

Errors:

EMFILE
The maximum number of inotify client instances have been created.
ENAMETOOLONG
The value of the FSNOTIFY_PREFIX environment variable exceeds PATH_MAX.
ENFILE
The system-wide limit on file descriptors has been reached.
ENOSYS
The fsevmgr process is not running.

Environment variables:

FSNOTIFY_PREFIX
Prefix for the filesystem event manager, fsevmgr, to use in the paths of the interfaces that it registers in the system namespace. Client programs and resource managers will also prepend this variable's value to the paths they use for connecting to fsevmgr for reading and writing data. You must therefore set FSNOTIFY_PREFIX for fsevmgr and for any programs that use it to the same value.

Classification:

Linux

Safety:
Cancellation pointNo
Signal handlerNo
ThreadYes
Page updated: