Skip to content

Commit

Permalink
lxd/fsmonitor/drivers: Use driver names where applicable.
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Laing <mark.laing@canonical.com>
  • Loading branch information
markylaing committed Sep 25, 2024
1 parent 8b68296 commit 247f73b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lxd/fsmonitor/drivers/driver_fanotify.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (d *fanotify) eventMask() (uint64, error) {

// DriverName returns the name of the driver.
func (d *fanotify) DriverName() string {
return "fanotify"
return fsmonitor.DriverNameFANotify
}

func (d *fanotify) load(ctx context.Context) error {
Expand Down
2 changes: 1 addition & 1 deletion lxd/fsmonitor/drivers/driver_inotify.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (d *inotify) eventMask() (uint32, error) {

// DriverName returns the name of the driver.
func (d *inotify) DriverName() string {
return "inotify"
return fsmonitor.DriverNameINotify
}

func (d *inotify) load(ctx context.Context) error {
Expand Down
8 changes: 4 additions & 4 deletions lxd/fsmonitor/drivers/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
)

var drivers = map[string]func() driver{
"inotify": func() driver { return &inotify{} },
"fanotify": func() driver { return &fanotify{} },
fsmonitor.DriverNameINotify: func() driver { return &inotify{} },
fsmonitor.DriverNameFANotify: func() driver { return &fanotify{} },
}

// Load returns a new fsmonitor.FSMonitor with an applicable Driver.
Expand Down Expand Up @@ -46,10 +46,10 @@ func Load(ctx context.Context, path string, events ...fsmonitor.Event) (fsmonito
return startMonitor(driverName)
}

driver, err := startMonitor("fanotify")
driver, err := startMonitor(fsmonitor.DriverNameFANotify)
if err != nil {
logger.Warn("Failed to initialize fanotify, falling back on inotify", logger.Ctx{"err": err})
driver, err = startMonitor("inotify")
driver, err = startMonitor(fsmonitor.DriverNameINotify)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 247f73b

Please sign in to comment.