X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=lib%2Flibzfs%2Flibzfs_util.c;h=de4bb72de4f146200c09468f90119b045f2884fc;hb=fc24f7c887a040b6dc9f2a3dd3d5ae0c03a5d639;hp=982a6f05fd97d87fea28ad1bec6b83208f42a34c;hpb=b04c9fc009ca0a0cabb7550625ff273b9edd9729;p=zfs.git diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index 982a6f0..de4bb72 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011 by Delphix. All rights reserved. */ /* @@ -346,6 +347,7 @@ zfs_standard_error_fmt(libzfs_handle_t *hdl, int error, const char *fmt, ...) switch (error) { case ENXIO: case ENODEV: + case EPIPE: zfs_verror(hdl, EZFS_IO, fmt, ap); break; @@ -608,27 +610,13 @@ libzfs_print_on_error(libzfs_handle_t *hdl, boolean_t printerr) static int libzfs_module_loaded(const char *module) { - FILE *f; - int result = 0; - char name[256]; + const char path_prefix[] = "/sys/module/"; + char path[256]; - f = fopen("/proc/modules", "r"); - if (f == NULL) - return -1; + memcpy(path, path_prefix, sizeof(path_prefix) - 1); + strcpy(path + sizeof(path_prefix) - 1, module); - while (fgets(name, sizeof(name), f)) { - char *c = strchr(name, ' '); - if (!c) - continue; - *c = 0; - if (strcmp(module, name) == 0) { - result = 1; - break; - } - } - fclose(f); - - return result; + return (access(path, F_OK) == 0); } int @@ -1434,7 +1422,8 @@ addlist(libzfs_handle_t *hdl, char *propname, zprop_list_t **listp, * dataset property, */ if (prop == ZPROP_INVAL && (type == ZFS_TYPE_POOL || - (!zfs_prop_user(propname) && !zfs_prop_userquota(propname)))) { + (!zfs_prop_user(propname) && !zfs_prop_userquota(propname) && + !zfs_prop_written(propname)))) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "invalid property '%s'"), propname); return (zfs_error(hdl, EZFS_BADPROP,