diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/zfs/zfs_main.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 836979bdf..d7c1a2a47 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -5862,7 +5862,11 @@ share_mount(int op, int argc, char **argv) * display any active ZFS mounts. We hide any snapshots, since * they are controlled automatically. */ - rewind(mnttab_file); + + /* Reopen MNTTAB to prevent reading stale data from open file */ + if (freopen(MNTTAB, "r", mnttab_file) == NULL) + return (ENOENT); + while (getmntent(mnttab_file, &entry) == 0) { if (strcmp(entry.mnt_fstype, MNTTYPE_ZFS) != 0 || strchr(entry.mnt_special, '@') != NULL) @@ -5965,7 +5969,11 @@ unshare_unmount_path(int op, char *path, int flags, boolean_t is_manual) /* * Search for the given (major,minor) pair in the mount table. */ - rewind(mnttab_file); + + /* Reopen MNTTAB to prevent reading stale data from open file */ + if (freopen(MNTTAB, "r", mnttab_file) == NULL) + return (ENOENT); + while ((ret = getextmntent(mnttab_file, &entry, 0)) == 0) { if (entry.mnt_major == major(statbuf.st_dev) && entry.mnt_minor == minor(statbuf.st_dev)) @@ -6119,7 +6127,10 @@ unshare_unmount(int op, int argc, char **argv) ((tree = uu_avl_create(pool, NULL, UU_DEFAULT)) == NULL)) nomem(); - rewind(mnttab_file); + /* Reopen MNTTAB to prevent reading stale data from open file */ + if (freopen(MNTTAB, "r", mnttab_file) == NULL) + return (ENOENT); + while (getmntent(mnttab_file, &entry) == 0) { /* ignore non-ZFS entries */ |