Skip to content

Commit

Permalink
zfs: Use unix.Open to verify that /dev/zfs exists
Browse files Browse the repository at this point in the history
The alternative os.OpenFile internally tries to enable non-blocking i/o
on the descriptor which on FreeBSD has the side effect of printing a
cryptic error message on the console
(openzfs/zfs#14286).

Signed-off-by: Doug Rabson <dfr@rabson.org>
  • Loading branch information
dfr committed Dec 13, 2022
1 parent 6b3865c commit aeed7a1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/zfs/zfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ func Init(base string, opt graphdriver.Options) (graphdriver.Driver, error) {
return nil, fmt.Errorf("the 'zfs' command is not available: %w", graphdriver.ErrPrerequisites)
}

file, err := os.OpenFile("/dev/zfs", os.O_RDWR, 0600)
file, err := unix.Open("/dev/zfs", unix.O_RDWR, 0600)
if err != nil {
logger.Debugf("cannot open /dev/zfs: %v", err)
return nil, fmt.Errorf("could not open /dev/zfs: %v: %w", err, graphdriver.ErrPrerequisites)
}
defer file.Close()
defer unix.Close(file)

options, err := parseOptions(opt.DriverOptions)
if err != nil {
Expand Down

0 comments on commit aeed7a1

Please sign in to comment.