Lines Matching refs:hdl
56 libzfs_errno(libzfs_handle_t *hdl) in libzfs_errno() argument
58 return (hdl->libzfs_error); in libzfs_errno()
62 libzfs_error_action(libzfs_handle_t *hdl) in libzfs_error_action() argument
64 return (hdl->libzfs_action); in libzfs_error_action()
68 libzfs_error_description(libzfs_handle_t *hdl) in libzfs_error_description() argument
70 if (hdl->libzfs_desc[0] != '\0') in libzfs_error_description()
71 return (hdl->libzfs_desc); in libzfs_error_description()
73 switch (hdl->libzfs_error) { in libzfs_error_description()
236 assert(hdl->libzfs_error == 0); in libzfs_error_description()
243 zfs_error_aux(libzfs_handle_t *hdl, const char *fmt, ...) in zfs_error_aux() argument
249 (void) vsnprintf(hdl->libzfs_desc, sizeof (hdl->libzfs_desc), in zfs_error_aux()
251 hdl->libzfs_desc_active = 1; in zfs_error_aux()
257 zfs_verror(libzfs_handle_t *hdl, int error, const char *fmt, va_list ap) in zfs_verror() argument
259 (void) vsnprintf(hdl->libzfs_action, sizeof (hdl->libzfs_action), in zfs_verror()
261 hdl->libzfs_error = error; in zfs_verror()
263 if (hdl->libzfs_desc_active) in zfs_verror()
264 hdl->libzfs_desc_active = 0; in zfs_verror()
266 hdl->libzfs_desc[0] = '\0'; in zfs_verror()
268 if (hdl->libzfs_printerr) { in zfs_verror()
271 "error: %s\n"), libzfs_error_description(hdl)); in zfs_verror()
275 (void) fprintf(stderr, "%s: %s\n", hdl->libzfs_action, in zfs_verror()
276 libzfs_error_description(hdl)); in zfs_verror()
283 zfs_error(libzfs_handle_t *hdl, int error, const char *msg) in zfs_error() argument
285 return (zfs_error_fmt(hdl, error, "%s", msg)); in zfs_error()
290 zfs_error_fmt(libzfs_handle_t *hdl, int error, const char *fmt, ...) in zfs_error_fmt() argument
296 zfs_verror(hdl, error, fmt, ap); in zfs_error_fmt()
304 zfs_common_error(libzfs_handle_t *hdl, int error, const char *fmt, in zfs_common_error() argument
310 zfs_verror(hdl, EZFS_PERM, fmt, ap); in zfs_common_error()
314 zfs_verror(hdl, EZFS_NODELEGATION, fmt, ap); in zfs_common_error()
318 zfs_verror(hdl, EZFS_IO, fmt, ap); in zfs_common_error()
322 zfs_verror(hdl, EZFS_FAULT, fmt, ap); in zfs_common_error()
326 zfs_verror(hdl, EZFS_INTR, fmt, ap); in zfs_common_error()
334 zfs_standard_error(libzfs_handle_t *hdl, int error, const char *msg) in zfs_standard_error() argument
336 return (zfs_standard_error_fmt(hdl, error, "%s", msg)); in zfs_standard_error()
341 zfs_standard_error_fmt(libzfs_handle_t *hdl, int error, const char *fmt, ...) in zfs_standard_error_fmt() argument
347 if (zfs_common_error(hdl, error, fmt, ap) != 0) { in zfs_standard_error_fmt()
356 zfs_verror(hdl, EZFS_IO, fmt, ap); in zfs_standard_error_fmt()
360 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zfs_standard_error_fmt()
362 zfs_verror(hdl, EZFS_NOENT, fmt, ap); in zfs_standard_error_fmt()
367 zfs_verror(hdl, EZFS_NOSPC, fmt, ap); in zfs_standard_error_fmt()
371 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zfs_standard_error_fmt()
373 zfs_verror(hdl, EZFS_EXISTS, fmt, ap); in zfs_standard_error_fmt()
377 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zfs_standard_error_fmt()
379 zfs_verror(hdl, EZFS_BUSY, fmt, ap); in zfs_standard_error_fmt()
382 zfs_verror(hdl, EZFS_POOLREADONLY, fmt, ap); in zfs_standard_error_fmt()
385 zfs_verror(hdl, EZFS_NAMETOOLONG, fmt, ap); in zfs_standard_error_fmt()
388 zfs_verror(hdl, EZFS_BADVERSION, fmt, ap); in zfs_standard_error_fmt()
391 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zfs_standard_error_fmt()
393 zfs_verror(hdl, EZFS_POOLUNAVAIL, fmt, ap); in zfs_standard_error_fmt()
396 zfs_error_aux(hdl, strerror(error)); in zfs_standard_error_fmt()
397 zfs_verror(hdl, EZFS_UNKNOWN, fmt, ap); in zfs_standard_error_fmt()
406 zpool_standard_error(libzfs_handle_t *hdl, int error, const char *msg) in zpool_standard_error() argument
408 return (zpool_standard_error_fmt(hdl, error, "%s", msg)); in zpool_standard_error()
413 zpool_standard_error_fmt(libzfs_handle_t *hdl, int error, const char *fmt, ...) in zpool_standard_error_fmt() argument
419 if (zfs_common_error(hdl, error, fmt, ap) != 0) { in zpool_standard_error_fmt()
426 zfs_verror(hdl, EZFS_NODEVICE, fmt, ap); in zpool_standard_error_fmt()
430 zfs_error_aux(hdl, in zpool_standard_error_fmt()
432 zfs_verror(hdl, EZFS_NOENT, fmt, ap); in zpool_standard_error_fmt()
436 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zpool_standard_error_fmt()
438 zfs_verror(hdl, EZFS_EXISTS, fmt, ap); in zpool_standard_error_fmt()
442 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "pool is busy")); in zpool_standard_error_fmt()
443 zfs_verror(hdl, EZFS_BUSY, fmt, ap); in zpool_standard_error_fmt()
447 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zpool_standard_error_fmt()
449 zfs_verror(hdl, EZFS_BADDEV, fmt, ap); in zpool_standard_error_fmt()
453 zfs_verror(hdl, EZFS_DEVOVERFLOW, fmt, ap); in zpool_standard_error_fmt()
457 zfs_verror(hdl, EZFS_POOL_NOTSUP, fmt, ap); in zpool_standard_error_fmt()
461 zfs_verror(hdl, EZFS_POOL_INVALARG, fmt, ap); in zpool_standard_error_fmt()
466 zfs_verror(hdl, EZFS_NOSPC, fmt, ap); in zpool_standard_error_fmt()
470 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zpool_standard_error_fmt()
472 zfs_verror(hdl, EZFS_POOLUNAVAIL, fmt, ap); in zpool_standard_error_fmt()
476 zfs_verror(hdl, EZFS_POOLREADONLY, fmt, ap); in zpool_standard_error_fmt()
480 zfs_error_aux(hdl, strerror(error)); in zpool_standard_error_fmt()
481 zfs_verror(hdl, EZFS_UNKNOWN, fmt, ap); in zpool_standard_error_fmt()
492 no_memory(libzfs_handle_t *hdl) in no_memory() argument
494 return (zfs_error(hdl, EZFS_NOMEM, "internal error")); in no_memory()
501 zfs_alloc(libzfs_handle_t *hdl, size_t size) in zfs_alloc() argument
506 (void) no_memory(hdl); in zfs_alloc()
516 zfs_asprintf(libzfs_handle_t *hdl, const char *fmt, ...) in zfs_asprintf() argument
529 (void) no_memory(hdl); in zfs_asprintf()
538 zfs_realloc(libzfs_handle_t *hdl, void *ptr, size_t oldsize, size_t newsize) in zfs_realloc() argument
543 (void) no_memory(hdl); in zfs_realloc()
555 zfs_strdup(libzfs_handle_t *hdl, const char *str) in zfs_strdup() argument
560 (void) no_memory(hdl); in zfs_strdup()
575 libzfs_print_on_error(libzfs_handle_t *hdl, boolean_t printerr) in libzfs_print_on_error() argument
577 hdl->libzfs_printerr = printerr; in libzfs_print_on_error()
583 libzfs_handle_t *hdl; in libzfs_init() local
585 if ((hdl = calloc(1, sizeof (libzfs_handle_t))) == NULL) { in libzfs_init()
589 if ((hdl->libzfs_fd = open(ZFS_DEV, O_RDWR)) < 0) { in libzfs_init()
590 free(hdl); in libzfs_init()
594 if ((hdl->libzfs_mnttab = fopen(MNTTAB, "rF")) == NULL) { in libzfs_init()
595 (void) close(hdl->libzfs_fd); in libzfs_init()
596 free(hdl); in libzfs_init()
600 hdl->libzfs_sharetab = fopen("/etc/dfs/sharetab", "rF"); in libzfs_init()
603 (void) close(hdl->libzfs_fd); in libzfs_init()
604 (void) fclose(hdl->libzfs_mnttab); in libzfs_init()
605 (void) fclose(hdl->libzfs_sharetab); in libzfs_init()
606 free(hdl); in libzfs_init()
613 libzfs_mnttab_init(hdl); in libzfs_init()
615 return (hdl); in libzfs_init()
619 libzfs_fini(libzfs_handle_t *hdl) in libzfs_fini() argument
621 (void) close(hdl->libzfs_fd); in libzfs_fini()
622 if (hdl->libzfs_mnttab) in libzfs_fini()
623 (void) fclose(hdl->libzfs_mnttab); in libzfs_fini()
624 if (hdl->libzfs_sharetab) in libzfs_fini()
625 (void) fclose(hdl->libzfs_sharetab); in libzfs_fini()
626 zfs_uninit_libshare(hdl); in libzfs_fini()
627 zpool_free_handles(hdl); in libzfs_fini()
628 libzfs_fru_clear(hdl, B_TRUE); in libzfs_fini()
629 namespace_clear(hdl); in libzfs_fini()
630 libzfs_mnttab_fini(hdl); in libzfs_fini()
632 free(hdl); in libzfs_fini()
660 zfs_path_to_zhandle(libzfs_handle_t *hdl, char *path, zfs_type_t argtype) in zfs_path_to_zhandle() argument
670 return (zfs_open(hdl, path, argtype)); in zfs_path_to_zhandle()
678 rewind(hdl->libzfs_mnttab); in zfs_path_to_zhandle()
679 while ((ret = getextmntent(hdl->libzfs_mnttab, &entry, 0)) == 0) { in zfs_path_to_zhandle()
695 return (zfs_open(hdl, entry.mnt_special, ZFS_TYPE_FILESYSTEM)); in zfs_path_to_zhandle()
703 zcmd_alloc_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, size_t len) in zcmd_alloc_dst_nvlist() argument
709 (uint64_t)(uintptr_t)zfs_alloc(hdl, zc->zc_nvlist_dst_size); in zcmd_alloc_dst_nvlist()
722 zcmd_expand_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc) in zcmd_expand_dst_nvlist() argument
726 (uint64_t)(uintptr_t)zfs_alloc(hdl, zc->zc_nvlist_dst_size); in zcmd_expand_dst_nvlist()
748 zcmd_write_nvlist_com(libzfs_handle_t *hdl, uint64_t *outnv, uint64_t *outlen, in zcmd_write_nvlist_com() argument
756 if ((packed = zfs_alloc(hdl, len)) == NULL) in zcmd_write_nvlist_com()
768 zcmd_write_conf_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, nvlist_t *nvl) in zcmd_write_conf_nvlist() argument
770 return (zcmd_write_nvlist_com(hdl, &zc->zc_nvlist_conf, in zcmd_write_conf_nvlist()
775 zcmd_write_src_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, nvlist_t *nvl) in zcmd_write_src_nvlist() argument
777 return (zcmd_write_nvlist_com(hdl, &zc->zc_nvlist_src, in zcmd_write_src_nvlist()
785 zcmd_read_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, nvlist_t **nvlp) in zcmd_read_dst_nvlist() argument
789 return (no_memory(hdl)); in zcmd_read_dst_nvlist()
795 zfs_ioctl(libzfs_handle_t *hdl, int request, zfs_cmd_t *zc) in zfs_ioctl() argument
797 return (ioctl(hdl->libzfs_fd, request, zc)); in zfs_ioctl()
1017 str2shift(libzfs_handle_t *hdl, const char *buf) in str2shift() argument
1029 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in str2shift()
1042 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in str2shift()
1053 zfs_nicestrtonum(libzfs_handle_t *hdl, const char *value, uint64_t *num) in zfs_nicestrtonum() argument
1062 if (hdl) in zfs_nicestrtonum()
1063 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zfs_nicestrtonum()
1077 if (hdl) in zfs_nicestrtonum()
1078 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zfs_nicestrtonum()
1090 if ((shift = str2shift(hdl, end)) == -1) in zfs_nicestrtonum()
1096 if (hdl) in zfs_nicestrtonum()
1097 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zfs_nicestrtonum()
1104 if ((shift = str2shift(hdl, end)) == -1) in zfs_nicestrtonum()
1109 if (hdl) in zfs_nicestrtonum()
1110 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zfs_nicestrtonum()
1133 zprop_parse_value(libzfs_handle_t *hdl, nvpair_t *elem, int prop, in zprop_parse_value() argument
1160 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zprop_parse_value()
1166 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zprop_parse_value()
1177 } else if (zfs_nicestrtonum(hdl, value, ivalp) in zprop_parse_value()
1184 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zprop_parse_value()
1194 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zprop_parse_value()
1212 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zprop_parse_value()
1220 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zprop_parse_value()
1236 (void) no_memory(hdl); in zprop_parse_value()
1241 (void) no_memory(hdl); in zprop_parse_value()
1248 (void) zfs_error(hdl, EZFS_BADPROP, errbuf); in zprop_parse_value()
1253 addlist(libzfs_handle_t *hdl, char *propname, zprop_list_t **listp, in addlist() argument
1274 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in addlist()
1276 return (zfs_error(hdl, EZFS_BADPROP, in addlist()
1280 if ((entry = zfs_alloc(hdl, sizeof (zprop_list_t))) == NULL) in addlist()
1285 if ((entry->pl_user_prop = zfs_strdup(hdl, propname)) == in addlist()
1308 zprop_get_list(libzfs_handle_t *hdl, char *props, zprop_list_t **listp, in zprop_get_list() argument
1323 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zprop_get_list()
1325 return (zfs_error(hdl, EZFS_BADPROP, dgettext(TEXT_DOMAIN, in zprop_get_list()
1349 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, in zprop_get_list()
1351 return (zfs_error(hdl, EZFS_BADPROP, in zprop_get_list()
1370 if (addlist(hdl, spaceprops[i], listp, type)) in zprop_get_list()
1375 if (addlist(hdl, props, listp, type)) in zprop_get_list()
1403 libzfs_handle_t *hdl; member
1413 if ((entry = zfs_alloc(edp->hdl, sizeof (zprop_list_t))) == NULL) in zprop_expand_list_cb()
1427 zprop_expand_list(libzfs_handle_t *hdl, zprop_list_t **plp, zfs_type_t type) in zprop_expand_list() argument
1442 exp.hdl = hdl; in zprop_expand_list()
1453 if ((entry = zfs_alloc(hdl, sizeof (zprop_list_t))) == NULL) in zprop_expand_list()