diff options
| author | Kyle Evans <kevans@FreeBSD.org> | 2018-11-17 19:19:37 +0000 |
|---|---|---|
| committer | Kyle Evans <kevans@FreeBSD.org> | 2018-11-17 19:19:37 +0000 |
| commit | efd6500d03b48b6f1f35a280eaeb5206e032fc2b (patch) | |
| tree | 91a950379a72ea8235f66f49f41967b86aaa627b /lib/libbe | |
| parent | 51aecc893a107f6e00fadccf2555357a7cbd53e5 (diff) | |
Notes
Diffstat (limited to 'lib/libbe')
| -rw-r--r-- | lib/libbe/be_access.c | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/lib/libbe/be_access.c b/lib/libbe/be_access.c index 328326f7147d..a129e55a0303 100644 --- a/lib/libbe/be_access.c +++ b/lib/libbe/be_access.c @@ -164,37 +164,18 @@ be_unmount(libbe_handle_t *lbh, char *bootenv, int flags) { int err, mntflags; char be[BE_MAXPATHLEN]; - struct statfs *mntbuf; - int mntsize; - char *mntpath; + zfs_handle_t *root_hdl; if ((err = be_root_concat(lbh, bootenv, be)) != 0) return (set_error(lbh, err)); - if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) { - if (errno == EIO) - return (set_error(lbh, BE_ERR_IO)); - return (set_error(lbh, BE_ERR_NOMOUNT)); - } - - mntpath = NULL; - for (int i = 0; i < mntsize; ++i) { - /* 0x000000de is the type number of zfs */ - if (mntbuf[i].f_type != 0x000000de) - continue; + if ((root_hdl = zfs_open(lbh->lzh, be, ZFS_TYPE_FILESYSTEM)) == NULL) + return (set_error(lbh, BE_ERR_ZFSOPEN)); - if (strcmp(mntbuf[i].f_mntfromname, be) == 0) { - mntpath = mntbuf[i].f_mntonname; - break; - } - } + mntflags = (flags & BE_MNT_FORCE) ? MS_FORCE : 0; - if (mntpath == NULL) - return (set_error(lbh, BE_ERR_NOMOUNT)); - - mntflags = (flags & BE_MNT_FORCE) ? MNT_FORCE : 0; - - if ((err = unmount(mntpath, mntflags)) != 0) { + if (zfs_unmount(root_hdl, NULL, mntflags) != 0) { + zfs_close(root_hdl); switch (errno) { case ENAMETOOLONG: return (set_error(lbh, BE_ERR_PATHLEN)); @@ -210,6 +191,7 @@ be_unmount(libbe_handle_t *lbh, char *bootenv, int flags) return (set_error(lbh, BE_ERR_UNKNOWN)); } } + zfs_close(root_hdl); - return (set_error(lbh, BE_ERR_SUCCESS)); + return (BE_ERR_SUCCESS); } |
