| 3213 | }; |
| 3214 | |
| 3215 | static int |
| 3216 | zfs_ioc_create(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl) |
| 3217 | { |
| 3218 | int error = 0; |
| 3219 | zfs_creat_t zct = { 0 }; |
| 3220 | nvlist_t *nvprops = NULL; |
| 3221 | nvlist_t *hidden_args = NULL; |
| 3222 | void (*cbfunc)(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx); |
| 3223 | dmu_objset_type_t type; |
| 3224 | boolean_t is_insensitive = B_FALSE; |
| 3225 | dsl_crypto_params_t *dcp = NULL; |
| 3226 | |
| 3227 | type = (dmu_objset_type_t)fnvlist_lookup_int32(innvl, "type"); |
| 3228 | (void) nvlist_lookup_nvlist(innvl, "props", &nvprops); |
| 3229 | (void) nvlist_lookup_nvlist(innvl, ZPOOL_HIDDEN_ARGS, &hidden_args); |
| 3230 | |
| 3231 | switch (type) { |
| 3232 | case DMU_OST_ZFS: |
| 3233 | cbfunc = zfs_create_cb; |
| 3234 | break; |
| 3235 | |
| 3236 | case DMU_OST_ZVOL: |
| 3237 | cbfunc = zvol_create_cb; |
| 3238 | break; |
| 3239 | |
| 3240 | default: |
| 3241 | cbfunc = NULL; |
| 3242 | break; |
| 3243 | } |
| 3244 | if (strchr(fsname, '@') || |
| 3245 | strchr(fsname, '%')) |
| 3246 | return (SET_ERROR(EINVAL)); |
| 3247 | |
| 3248 | zct.zct_props = nvprops; |
| 3249 | |
| 3250 | if (cbfunc == NULL) |
| 3251 | return (SET_ERROR(EINVAL)); |
| 3252 | |
| 3253 | if (type == DMU_OST_ZVOL) { |
| 3254 | uint64_t volsize, volblocksize; |
| 3255 | |
| 3256 | if (nvprops == NULL) |
| 3257 | return (SET_ERROR(EINVAL)); |
| 3258 | if (nvlist_lookup_uint64(nvprops, |
| 3259 | zfs_prop_to_name(ZFS_PROP_VOLSIZE), &volsize) != 0) |
| 3260 | return (SET_ERROR(EINVAL)); |
| 3261 | |
| 3262 | if ((error = nvlist_lookup_uint64(nvprops, |
| 3263 | zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), |
| 3264 | &volblocksize)) != 0 && error != ENOENT) |
| 3265 | return (SET_ERROR(EINVAL)); |
| 3266 | |
| 3267 | if (error != 0) |
| 3268 | volblocksize = zfs_prop_default_numeric( |
| 3269 | ZFS_PROP_VOLBLOCKSIZE); |
| 3270 | |
| 3271 | if ((error = zvol_check_volblocksize(fsname, |
| 3272 | volblocksize)) != 0 || |
nothing calls this directly
no test coverage detected