aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libzfs/libzfs_mount.c
diff options
context:
space:
mode:
authorнаб <[email protected]>2021-04-09 00:44:23 +0200
committerBrian Behlendorf <[email protected]>2021-04-13 14:14:44 -0700
commit533527725bf3fa72b8feb61993d1ed0d6e5672dc (patch)
tree3255d96e5f8570d66c0d9212af724f407220243c /lib/libzfs/libzfs_mount.c
parent74e48f470e8190ed64bbea020e6535f69e17c1a8 (diff)
libzfs: get rid of libzfs_handle::libzfs_mnttab
All users did a freopen() on it. Even some non-users did! This is point-less ‒ just open the mtab when needed If I understand Solaris' getextmntent(3C) correctly, the non-user freopen()s are very likely an odd, twisted vestigial tail of that ‒ but it's got a completely different calling convention and caching semantics than any platform we support Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #11868
Diffstat (limited to 'lib/libzfs/libzfs_mount.c')
-rw-r--r--lib/libzfs/libzfs_mount.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c
index d3f7e6106..3df42e2dc 100644
--- a/lib/libzfs/libzfs_mount.c
+++ b/lib/libzfs/libzfs_mount.c
@@ -1528,6 +1528,7 @@ int
zpool_disable_datasets(zpool_handle_t *zhp, boolean_t force)
{
int used, alloc;
+ FILE *mnttab;
struct mnttab entry;
size_t namelen;
char **mountpoints = NULL;
@@ -1539,12 +1540,11 @@ zpool_disable_datasets(zpool_handle_t *zhp, boolean_t force)
namelen = strlen(zhp->zpool_name);
- /* Reopen MNTTAB to prevent reading stale data from open file */
- if (freopen(MNTTAB, "re", hdl->libzfs_mnttab) == NULL)
+ if ((mnttab = fopen(MNTTAB, "re")) == NULL)
return (ENOENT);
used = alloc = 0;
- while (getmntent(hdl->libzfs_mnttab, &entry) == 0) {
+ while (getmntent(mnttab, &entry) == 0) {
/*
* Ignore non-ZFS entries.
*/
@@ -1646,6 +1646,7 @@ zpool_disable_datasets(zpool_handle_t *zhp, boolean_t force)
ret = 0;
out:
+ (void) fclose(mnttab);
for (i = 0; i < used; i++) {
if (datasets[i])
zfs_close(datasets[i]);