High performance C++ framework for concurrent servers
Classes | Public Types | Public Member Functions | List of all members
seastar::experimental::fsnotifier Class Reference

Detailed Description

Filesystem modification notifier.

This is a thin wrapper around inotify(see, which is the de-facto light-weight filesystem modification watch interface in Linux and can be used to log filesystem activities, reload configurations, etc.

The wrapper provides a buffered read of events, and RAII handling of watches themselves.

Note that this is an experimental feature, and thus any tweaks that are backward incompatible can be made before finally freezing it. Besides, the impl currently does not (yet) handle re-writing watches.

#include <seastar/core/fsnotify.hh>


struct  event
 A wrapper around inotify_event. More...
class  watch
 Simple RAII wrapper around a fsnotifier::watch_token. More...

Public Types

enum class  flags : uint32_t {
  access = IN_ACCESS , attrib = IN_ATTRIB , close_write = IN_CLOSE_WRITE , close_nowrite = IN_CLOSE_NOWRITE ,
  create_child = IN_CREATE , delete_child = IN_DELETE , delete_self = IN_DELETE_SELF , modify = IN_MODIFY ,
  move_self = IN_MOVE_SELF , move_from = IN_MOVED_FROM , move_to = IN_MOVED_TO , open = IN_OPEN ,
  close = IN_CLOSE , move = IN_MOVE , oneshot = IN_ONESHOT , ignored = IN_IGNORED ,
  onlydir = IN_ONLYDIR
 Flags of events supported by FileSystem Notifier. More...
using watch_token = int32_t
 Token of a watch point.
using sequence_no = uint32_t
 Unique sequence number of associating related events. More...

Public Member Functions

 fsnotifier (fsnotifier &&)
fsnotifieroperator= (fsnotifier &&)
future< watchcreate_watch (const sstring &path, flags mask)
 Monitor events specified in mask for the give path. More...
future< std::vector< event > > wait () const
void shutdown ()
bool active () const
 Check if the notifier is activated.
 operator bool () const
 Equivalent to active().

Class Documentation

◆ seastar::experimental::fsnotifier::event

struct seastar::experimental::fsnotifier::event
Class Members
watch_token id
flags mask
sstring name
sequence_no seq

Member Typedef Documentation

◆ sequence_no

Unique sequence number of associating related events.

The sequence number is used to connect related events. Currently, it is used only for the rename events(i.e., move_from and move_to), and is 0 for other types.

Member Enumeration Documentation

◆ flags

enum class seastar::experimental::fsnotifier::flags : uint32_t

Flags of events supported by FileSystem Notifier.

Note that the flags are bit-matched with inotify and they can be calculated using the bitwise AND and bitwise OR operators (including the assignment form) directly to take intersection or union.

Member Function Documentation

◆ create_watch()

future< watch > seastar::experimental::fsnotifier::create_watch ( const sstring &  path,
flags  mask 

Monitor events specified in mask for the give path.

pathpath of the file or directory to monitor for.
maskevents of interest.
a future that becomes ready when the underlying inotify_add_watch(2) call completes.

◆ shutdown()

void seastar::experimental::fsnotifier::shutdown ( )

Shutdown the notifier and abort any waiting events.

After shutdown, all watches are invalidated, and no new ones can be created.

◆ wait()

future< std::vector< event > > seastar::experimental::fsnotifier::wait ( ) const

Wait for events.

a future that becomes ready when registered events occur.

The documentation for this class was generated from the following file: