X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=lib%2Flibzfs%2Flibzfs_dataset.c;h=87ee1826c44087fa8c073c5bb0690a2dac8d4f52;hb=266852767f42781821c1d62544c9b9e985828304;hp=089be7e041b500ddfe5f15f4bb8e749799e69b42;hpb=2598c0012dc33496539ce893a0af601c66cbb7e2;p=zfs.git diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 089be7e..87ee182 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -72,55 +72,14 @@ zfs_type_to_name(zfs_type_t type) return (dgettext(TEXT_DOMAIN, "snapshot")); case ZFS_TYPE_VOLUME: return (dgettext(TEXT_DOMAIN, "volume")); + default: + break; } return (NULL); } /* - * Given a path and mask of ZFS types, return a string describing this dataset. - * This is used when we fail to open a dataset and we cannot get an exact type. - * We guess what the type would have been based on the path and the mask of - * acceptable types. - */ -static const char * -path_to_str(const char *path, int types) -{ - /* - * When given a single type, always report the exact type. - */ - if (types == ZFS_TYPE_SNAPSHOT) - return (dgettext(TEXT_DOMAIN, "snapshot")); - if (types == ZFS_TYPE_FILESYSTEM) - return (dgettext(TEXT_DOMAIN, "filesystem")); - if (types == ZFS_TYPE_VOLUME) - return (dgettext(TEXT_DOMAIN, "volume")); - - /* - * The user is requesting more than one type of dataset. If this is the - * case, consult the path itself. If we're looking for a snapshot, and - * a '@' is found, then report it as "snapshot". Otherwise, remove the - * snapshot attribute and try again. - */ - if (types & ZFS_TYPE_SNAPSHOT) { - if (strchr(path, '@') != NULL) - return (dgettext(TEXT_DOMAIN, "snapshot")); - return (path_to_str(path, types & ~ZFS_TYPE_SNAPSHOT)); - } - - /* - * The user has requested either filesystems or volumes. - * We have no way of knowing a priori what type this would be, so always - * report it as "filesystem" or "volume", our two primitive types. - */ - if (types & ZFS_TYPE_FILESYSTEM) - return (dgettext(TEXT_DOMAIN, "filesystem")); - - assert(types & ZFS_TYPE_VOLUME); - return (dgettext(TEXT_DOMAIN, "volume")); -} - -/* * Validate a ZFS path. This is used even before trying to open the dataset, to * provide a more meaningful error message. We call zfs_error_aux() to * explain exactly why the name was not valid. @@ -180,6 +139,8 @@ zfs_validate_name(libzfs_handle_t *hdl, const char *path, int type, zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "reserved disk name")); break; + default: + break; } } @@ -619,7 +580,7 @@ libzfs_mnttab_fini(libzfs_handle_t *hdl) void *cookie = NULL; mnttab_node_t *mtn; - while (mtn = avl_destroy_nodes(&hdl->libzfs_mnttab_cache, &cookie)) { + while ((mtn = avl_destroy_nodes(&hdl->libzfs_mnttab_cache, &cookie))) { free(mtn->mtn_mt.mnt_special); free(mtn->mtn_mt.mnt_mountp); free(mtn->mtn_mt.mnt_fstype); @@ -691,7 +652,7 @@ libzfs_mnttab_remove(libzfs_handle_t *hdl, const char *fsname) mnttab_node_t *ret; find.mtn_mt.mnt_special = (char *)fsname; - if (ret = avl_find(&hdl->libzfs_mnttab_cache, (void *)&find, NULL)) { + if ((ret = avl_find(&hdl->libzfs_mnttab_cache, (void *)&find, NULL))) { avl_remove(&hdl->libzfs_mnttab_cache, ret); free(ret->mtn_mt.mnt_special); free(ret->mtn_mt.mnt_mountp); @@ -1015,6 +976,8 @@ badlabel: "component of '%s' is too long"), propname); break; + default: + break; } (void) zfs_error(hdl, EZFS_BADPROP, errbuf); goto error; @@ -1139,6 +1102,8 @@ badlabel: case ZFS_PROP_NORMALIZE: chosen_normal = (int)intval; break; + default: + break; } /* @@ -1187,6 +1152,8 @@ badlabel: goto error; } break; + default: + break; } } } @@ -1352,7 +1319,7 @@ zfs_prop_set(zfs_handle_t *zhp, const char *propname, const char *propval) zfs_prop_t prop; boolean_t do_prefix; uint64_t idx; - int added_resv; + int added_resv = 0; (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, "cannot set property for '%s'"), @@ -1674,6 +1641,8 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src, mntopt_on = MNTOPT_NBMAND; mntopt_off = MNTOPT_NONBMAND; break; + default: + break; } /* @@ -2722,7 +2691,7 @@ create_parents(libzfs_handle_t *hdl, char *target, int prefixlen) * up to the prefixlen-long one. */ for (cp = target + prefixlen + 1; - cp = strchr(cp, '/'); *cp = '/', cp++) { + (cp = strchr(cp, '/')); *cp = '/', cp++) { char *logstr; *cp = '\0'; @@ -2779,7 +2748,7 @@ zfs_create_ancestors(libzfs_handle_t *hdl, const char *path) { int prefix; char *path_copy; - int rc; + int rc = 0; if (check_parents(hdl, path, NULL, B_TRUE, &prefix) != 0) return (-1); @@ -3336,8 +3305,8 @@ zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force) int err; zfs_cmd_t zc = { "\0", "\0", "\0", "\0", 0 }; boolean_t restore_resv = 0; - uint64_t old_volsize, new_volsize; - zfs_prop_t resv_prop; + uint64_t old_volsize = 0, new_volsize; + zfs_prop_t resv_prop = { 0 }; assert(zhp->zfs_type == ZFS_TYPE_FILESYSTEM || zhp->zfs_type == ZFS_TYPE_VOLUME); @@ -3567,6 +3536,7 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive) "child dataset with inherited mountpoint is used " "in a non-global zone")); (void) zfs_error(hdl, EZFS_ZONED, errbuf); + ret = -1; goto error; } @@ -3817,7 +3787,7 @@ zfs_smb_acl_mgmt(libzfs_handle_t *hdl, char *dataset, char *path, if (cmd == ZFS_SMB_ACL_RENAME) { if (nvlist_alloc(&nvlist, NV_UNIQUE_NAME, 0) != 0) { (void) no_memory(hdl); - return (NULL); + return (-1); } }