-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for monitoring entire mount
- Add support for monitoring entire mount - Update package documentation - Update README
- Loading branch information
Showing
6 changed files
with
141 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Package fanotify library provides a simple API to monitor filesystem for events. | ||
// | ||
// The listener is initialized with flags automatically based on the kernel version. The mark flag features that specify the | ||
// the events to monitor a file/directory are validated and checked for valid combinations and validated against the kernel | ||
// version. | ||
// | ||
// fanotify system has features spanning different kernel versions: | ||
// - For Linux kernel version 5.0 and earlier no additional information about the underlying filesystem object is available. | ||
// - For Linux kernel versions 5.1 to 5.8 additional information about the underlying filesystem object is correlated to an event. | ||
// - For Linux kernel version 5.9 or later the modified file name is made available in the event. | ||
// | ||
package fanotify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package fanotify_test | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/opcoder0/fanotify" | ||
) | ||
|
||
func ExampleNewListener() { | ||
if _, err := fanotify.NewListener("/", true); err != nil { | ||
log.Fatal("Cannot create listener for mount /", err) | ||
} | ||
} | ||
|
||
func ExampleListener_AddWatch() { | ||
var listener *fanotify.Listener | ||
listener, err := fanotify.NewListener("/", false) | ||
if err != nil { | ||
log.Fatal("Cannot create listener for mount /", err) | ||
} | ||
listener.AddWatch("/home/user", fanotify.FileModified) | ||
} | ||
|
||
func ExampleListener_AddWatch_all() { | ||
var listener *fanotify.Listener | ||
var actions fanotify.Action | ||
|
||
listener, err := fanotify.NewListener("/", false) | ||
if err != nil { | ||
log.Fatal("Cannot create listener for path /", err) | ||
} | ||
actions = fanotify.FileAccessed | | ||
fanotify.FileOrDirectoryAccessed | | ||
fanotify.FileModified | | ||
fanotify.FileOpenedForExec | | ||
fanotify.FileAttribChanged | | ||
fanotify.FileOrDirectoryAttribChanged | | ||
fanotify.FileCreated | | ||
fanotify.FileOrDirectoryCreated | | ||
fanotify.FileDeleted | | ||
fanotify.FileOrDirectoryDeleted | | ||
fanotify.WatchedFileDeleted | | ||
fanotify.WatchedFileOrDirectoryDeleted | | ||
fanotify.FileMovedFrom | | ||
fanotify.FileOrDirectoryMovedFrom | | ||
fanotify.FileMovedTo | | ||
fanotify.FileOrDirectoryMovedTo | | ||
fanotify.WatchedFileMoved | | ||
fanotify.WatchedFileOrDirectoryMoved | ||
listener.AddWatch("/home/user", actions) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters