zfs: Use unix.Open to verify that /dev/zfs exists

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
(https://github.com/openzfs/zfs/issues/14286).

Signed-off-by: Doug Rabson <dfr@rabson.org>
This commit is contained in:
Doug Rabson 2022-12-13 11:33:11 +00:00
parent 6b3865cf6d
commit aeed7a16c9
1 changed files with 2 additions and 2 deletions

View File

@ -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 {