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