Lines Matching refs:zhp
79 match_mountpoint(zfs_handle_t *zhp, void *data) in match_mountpoint() argument
85 if (zfs_get_type(zhp) != ZFS_TYPE_FILESYSTEM) { in match_mountpoint()
86 zfs_close(zhp); in match_mountpoint()
91 if (zfs_prop_get(zhp, ZFS_PROP_MOUNTED, mp, sizeof (mp), NULL, NULL, in match_mountpoint()
93 zfs_close(zhp); in match_mountpoint()
98 if (zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mp, sizeof (mp), NULL, NULL, in match_mountpoint()
100 zfs_close(zhp); in match_mountpoint()
112 nm = zfs_get_name(zhp); in match_mountpoint()
114 zfs_close(zhp); in match_mountpoint()
123 cbp->match_handle = zhp; in match_mountpoint()
132 cbp->match_handle = zhp; in match_mountpoint()
137 res = zfs_iter_filesystems(zhp, match_mountpoint, data); in match_mountpoint()
138 zfs_close(zhp); in match_mountpoint()
227 get_snap_max(zfs_handle_t *zhp, void *data) in get_snap_max() argument
232 if (zfs_get_type(zhp) != ZFS_TYPE_SNAPSHOT) { in get_snap_max()
233 zfs_close(zhp); in get_snap_max()
239 if (strncmp(zfs_get_name(zhp), cbp->match_name, cbp->len) == 0) { in get_snap_max()
244 nump = (char *)(zfs_get_name(zhp) + cbp->len); in get_snap_max()
250 res = zfs_iter_snapshots(zhp, get_snap_max, data); in get_snap_max()
251 zfs_close(zhp); in get_snap_max()
259 take_snapshot(zfs_handle_t *zhp, char *snapshot_name, int snap_size, in take_snapshot() argument
272 zfs_get_name(zhp)) >= sizeof (template)) in take_snapshot()
279 if (zfs_iter_snapshots(zhp, get_snap_max, &cb) != 0) in take_snapshot()
285 zfs_get_name(zhp), cb.max) >= snap_size) in take_snapshot()
365 zfs_handle_t *zhp; in clone_snap() local
369 if ((zhp = zfs_open(g_zfs, snapshot_name, ZFS_TYPE_SNAPSHOT)) == NULL) in clone_snap()
390 err = zfs_clone(zhp, zonepath, props); in clone_snap()
391 zfs_close(zhp); in clone_snap()
455 zfs_handle_t *zhp; in path2name() local
486 if ((zhp = mount2zhandle(dname)) == NULL) { in path2name()
496 res = snprintf(zfs_name, len, "%s/%s", zfs_get_name(zhp), bname); in path2name()
500 zfs_close(zhp); in path2name()
513 has_dependent(zfs_handle_t *zhp, void *data) in has_dependent() argument
515 zfs_close(zhp); in has_dependent()
529 zfs_handle_t *zhp; in snap2path() local
537 zhp = zfs_open(g_zfs, snap_name, ZFS_TYPE_DATASET); in snap2path()
539 if (zhp == NULL) in snap2path()
543 if (zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mp, sizeof (mp), NULL, NULL, in snap2path()
545 zfs_close(zhp); in snap2path()
548 zfs_close(zhp); in snap2path()
562 get_direct_clone(zfs_handle_t *zhp, void *data) in get_direct_clone() argument
568 if (zfs_get_type(zhp) != ZFS_TYPE_FILESYSTEM) { in get_direct_clone()
569 zfs_close(zhp); in get_direct_clone()
573 (void) strlcpy(ds_path, zfs_get_name(zhp), sizeof (ds_path)); in get_direct_clone()
576 if (zfs_prop_get(zhp, ZFS_PROP_ORIGIN, origin, sizeof (origin), NULL, in get_direct_clone()
578 zfs_close(zhp); in get_direct_clone()
585 cd->clone_zhp = zhp; in get_direct_clone()
596 find_clone(zfs_handle_t *zhp, void *data) in find_clone() argument
603 if (zfs_prop_get_int(zhp, ZFS_PROP_NUMCLONES) == 0) { in find_clone()
604 zfs_close(zhp); in find_clone()
608 cd->snapshot = zfs_get_name(zhp); in find_clone()
611 snap_creation = (time_t)zfs_prop_get_int(zhp, ZFS_PROP_CREATION); in find_clone()
623 if ((zret = zfs_iter_dependents(zhp, B_FALSE, get_direct_clone, in find_clone()
625 zfs_close(zhp); in find_clone()
636 zfs_close(zhp); in find_clone()
646 rm_snap(zfs_handle_t *zhp, void *data) in rm_snap() argument
649 if (zfs_prop_get_int(zhp, ZFS_PROP_NUMCLONES) != 0) { in rm_snap()
650 zfs_close(zhp); in rm_snap()
654 if (zfs_unmount(zhp, NULL, 0) == 0) { in rm_snap()
655 (void) zfs_destroy(zhp, B_FALSE); in rm_snap()
658 zfs_close(zhp); in rm_snap()
666 rename_snap(zfs_handle_t *zhp, void *data) in rename_snap() argument
681 zfs_close(zhp); in rename_snap()
685 if (zfs_get_type(zhp) != ZFS_TYPE_SNAPSHOT) { in rename_snap()
686 zfs_close(zhp); in rename_snap()
691 if (strncmp(zfs_get_name(zhp), cbp->match_name, cbp->len) != 0) { in rename_snap()
692 zfs_close(zhp); in rename_snap()
699 res = (zfs_rename(zhp, template, B_FALSE, B_FALSE) != 0); in rename_snap()
702 "to %s: %s\n"), zfs_get_name(zhp), template, in rename_snap()
707 zfs_close(zhp); in rename_snap()
784 promote_all_clones(zfs_handle_t *zhp) in promote_all_clones() argument
793 if (zfs_iter_snapshots(zhp, find_clone, &cd) != 0) { in promote_all_clones()
794 zfs_close(zhp); in promote_all_clones()
803 if (promote_clone(zhp, cd.clone_zhp) != 0) { in promote_all_clones()
805 zfs_close(zhp); in promote_all_clones()
810 (void) strlcpy(nm, zfs_get_name(zhp), sizeof (nm)); in promote_all_clones()
811 zfs_close(zhp); in promote_all_clones()
812 if ((zhp = zfs_open(g_zfs, nm, ZFS_TYPE_FILESYSTEM)) == NULL) in promote_all_clones()
892 zfs_handle_t *zhp; in clone_zfs() local
900 if ((zhp = mount2zhandle(source_zonepath)) == NULL) in clone_zfs()
908 zfs_close(zhp); in clone_zfs()
929 zfs_close(zhp); in clone_zfs()
933 if (take_snapshot(zhp, snap_name, sizeof (snap_name), presnapbuf, in clone_zfs()
935 zfs_close(zhp); in clone_zfs()
938 zfs_close(zhp); in clone_zfs()
942 if ((zhp = zfs_open(g_zfs, snap_name, ZFS_TYPE_SNAPSHOT)) in clone_zfs()
944 if (zfs_unmount(zhp, NULL, 0) == 0) in clone_zfs()
945 (void) zfs_destroy(zhp, B_FALSE); in clone_zfs()
946 zfs_close(zhp); in clone_zfs()
967 zfs_handle_t *zhp; in create_zfs_zonepath() local
975 if ((zhp = zfs_open(g_zfs, zfs_name, ZFS_TYPE_DATASET)) != NULL) { in create_zfs_zonepath()
976 zfs_close(zhp); in create_zfs_zonepath()
996 (zhp = zfs_open(g_zfs, zfs_name, ZFS_TYPE_DATASET)) == NULL) { in create_zfs_zonepath()
1005 if (zfs_mount(zhp, NULL, 0) != 0) { in create_zfs_zonepath()
1008 (void) zfs_destroy(zhp, B_FALSE); in create_zfs_zonepath()
1021 zfs_close(zhp); in create_zfs_zonepath()
1033 zfs_handle_t *zhp; in destroy_zfs() local
1037 if ((zhp = mount2zhandle(zonepath)) == NULL) in destroy_zfs()
1040 if (promote_all_clones(zhp) != 0) in destroy_zfs()
1044 if (zfs_iter_snapshots(zhp, rm_snap, NULL) != 0) { in destroy_zfs()
1045 zfs_close(zhp); in destroy_zfs()
1053 if (zfs_iter_dependents(zhp, B_TRUE, has_dependent, NULL) != 0) { in destroy_zfs()
1055 "dataset still has dependents\n"), zfs_get_name(zhp)); in destroy_zfs()
1056 zfs_close(zhp); in destroy_zfs()
1064 if (zfs_prop_get(zhp, ZFS_PROP_ORIGIN, origin, sizeof (origin), NULL, in destroy_zfs()
1068 if (zfs_unmount(zhp, NULL, 0) != 0) { in destroy_zfs()
1070 zfs_get_name(zhp), libzfs_error_description(g_zfs)); in destroy_zfs()
1071 zfs_close(zhp); in destroy_zfs()
1075 if (zfs_destroy(zhp, B_FALSE) != 0) { in destroy_zfs()
1082 zfs_get_name(zhp), libzfs_error_description(g_zfs)); in destroy_zfs()
1083 (void) zfs_mount(zhp, NULL, 0); in destroy_zfs()
1084 zfs_close(zhp); in destroy_zfs()
1113 zfs_close(zhp); in destroy_zfs()
1161 zfs_handle_t *zhp; in move_zfs() local
1163 if ((zhp = mount2zhandle(zonepath)) == NULL) in move_zfs()
1166 if (zfs_prop_set(zhp, zfs_prop_to_name(ZFS_PROP_MOUNTPOINT), in move_zfs()
1176 zfs_close(zhp); in move_zfs()
1195 zfs_handle_t *zhp; in verify_datasets() local
1212 if ((zhp = zfs_open(g_zfs, dstab.zone_dataset_name, in verify_datasets()
1221 if (zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, propbuf, in verify_datasets()
1229 zfs_close(zhp); in verify_datasets()
1233 zfs_close(zhp); in verify_datasets()
1247 zfs_handle_t *zhp; in verify_fs_zfs() local
1250 if ((zhp = zfs_open(g_zfs, fstab->zone_fs_special, in verify_fs_zfs()
1258 if (zfs_get_type(zhp) != ZFS_TYPE_FILESYSTEM) { in verify_fs_zfs()
1262 zfs_close(zhp); in verify_fs_zfs()
1266 if (zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, propbuf, sizeof (propbuf), in verify_fs_zfs()
1271 zfs_close(zhp); in verify_fs_zfs()
1275 zfs_close(zhp); in verify_fs_zfs()
1362 zfs_handle_t *zhp; in get_zfs_non_legacy_mountpoint() local
1368 if ((zhp = zfs_open(g_zfs, dataset_name, ZFS_TYPE_DATASET)) == NULL) { in get_zfs_non_legacy_mountpoint()
1372 if (zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, propbuf, sizeof (propbuf), in get_zfs_non_legacy_mountpoint()
1374 zfs_close(zhp); in get_zfs_non_legacy_mountpoint()
1378 zfs_close(zhp); in get_zfs_non_legacy_mountpoint()
1540 zfs_handle_t *zhp; in zone_mount_rootfs() local
1542 if ((zhp = zfs_open(g_zfs, mtab->mnt_special, in zone_mount_rootfs()
1548 if (zfs_prop_set(zhp, zfs_prop_to_name(ZFS_PROP_MOUNTPOINT), in zone_mount_rootfs()
1552 zfs_close(zhp); in zone_mount_rootfs()
1555 if (zfs_mount(zhp, mtab->mnt_mntopts, 0) != 0) { in zone_mount_rootfs()
1558 if (zfs_prop_set(zhp, in zone_mount_rootfs()
1563 zfs_close(zhp); in zone_mount_rootfs()
1566 zfs_close(zhp); in zone_mount_rootfs()
1630 zfs_handle_t *zhp; in zone_unmount_rootfs() local
1632 if ((zhp = zfs_open(g_zfs, mtab->mnt_special, in zone_unmount_rootfs()
1638 if (zfs_unmount(zhp, zoneroot, 0) != 0) { in zone_unmount_rootfs()
1639 if (force && zfs_unmount(zhp, zoneroot, MS_FORCE) == in zone_unmount_rootfs()
1641 zfs_close(zhp); in zone_unmount_rootfs()
1646 zfs_close(zhp); in zone_unmount_rootfs()
1649 zfs_close(zhp); in zone_unmount_rootfs()