Print this page
OS-1566 filesystem limits for ZFS datasets


 600 zfs_secpolicy_setprop(const char *dsname, zfs_prop_t prop, nvpair_t *propval,
 601     cred_t *cr)
 602 {
 603         char *strval;
 604 
 605         /*
 606          * Check permissions for special properties.
 607          */
 608         switch (prop) {
 609         case ZFS_PROP_DEDUP:
 610         case ZFS_PROP_COMPRESSION:
 611         case ZFS_PROP_ZONED:
 612                 /*
 613                  * Disallow setting these properties from within a local zone.
 614                  */
 615                 if (!INGLOBALZONE(curproc))
 616                         return (EPERM);
 617                 break;
 618 
 619         case ZFS_PROP_QUOTA:


 620                 if (!INGLOBALZONE(curproc)) {
 621                         uint64_t zoned;
 622                         char setpoint[MAXNAMELEN];
 623                         /*
 624                          * Unprivileged users are allowed to modify the
 625                          * quota on things *under* (ie. contained by)
 626                          * the thing they own.
 627                          */
 628                         if (dsl_prop_get_integer(dsname, "zoned", &zoned,
 629                             setpoint))
 630                                 return (EPERM);
 631                         if (!zoned || strlen(dsname) <= strlen(setpoint))
 632                                 return (EPERM);
 633                 }
 634                 break;
 635 
 636         case ZFS_PROP_MLSLABEL:
 637                 if (!is_system_labeled())
 638                         return (EPERM);
 639 
 640                 if (nvpair_value_string(propval, &strval) == 0) {
 641                         int err;
 642 
 643                         err = zfs_set_slabel_policy(dsname, strval, CRED());
 644                         if (err != 0)
 645                                 return (err);


2367 
2368         if (nvpair_type(pair) == DATA_TYPE_NVLIST) {
2369                 nvlist_t *attrs;
2370                 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0);
2371                 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE,
2372                     &pair) == 0);
2373         }
2374 
2375         if (zfs_prop_get_type(prop) == PROP_TYPE_STRING)
2376                 return (-1);
2377 
2378         VERIFY(0 == nvpair_value_uint64(pair, &intval));
2379 
2380         switch (prop) {
2381         case ZFS_PROP_QUOTA:
2382                 err = dsl_dir_set_quota(dsname, source, intval);
2383                 break;
2384         case ZFS_PROP_REFQUOTA:
2385                 err = dsl_dataset_set_quota(dsname, source, intval);
2386                 break;








2387         case ZFS_PROP_RESERVATION:
2388                 err = dsl_dir_set_reservation(dsname, source, intval);
2389                 break;
2390         case ZFS_PROP_REFRESERVATION:
2391                 err = dsl_dataset_set_reservation(dsname, source, intval);
2392                 break;
2393         case ZFS_PROP_VOLSIZE:
2394                 err = zvol_set_volsize(dsname, ddi_driver_major(zfs_dip),
2395                     intval);
2396                 break;
2397         case ZFS_PROP_VERSION:
2398         {
2399                 zfsvfs_t *zfsvfs;
2400 
2401                 if ((err = zfsvfs_hold(dsname, FTAG, &zfsvfs, B_TRUE)) != 0)
2402                         break;
2403 
2404                 err = zfs_set_version(zfsvfs, intval);
2405                 zfsvfs_rele(zfsvfs, FTAG);
2406 




 600 zfs_secpolicy_setprop(const char *dsname, zfs_prop_t prop, nvpair_t *propval,
 601     cred_t *cr)
 602 {
 603         char *strval;
 604 
 605         /*
 606          * Check permissions for special properties.
 607          */
 608         switch (prop) {
 609         case ZFS_PROP_DEDUP:
 610         case ZFS_PROP_COMPRESSION:
 611         case ZFS_PROP_ZONED:
 612                 /*
 613                  * Disallow setting these properties from within a local zone.
 614                  */
 615                 if (!INGLOBALZONE(curproc))
 616                         return (EPERM);
 617                 break;
 618 
 619         case ZFS_PROP_QUOTA:
 620         case ZFS_PROP_FILESYSTEM_LIMIT:
 621         case ZFS_PROP_SNAPSHOT_LIMIT:
 622                 if (!INGLOBALZONE(curproc)) {
 623                         uint64_t zoned;
 624                         char setpoint[MAXNAMELEN];
 625                         /*
 626                          * Unprivileged users are allowed to modify the
 627                          * limit on things *under* (ie. contained by)
 628                          * the thing they own.
 629                          */
 630                         if (dsl_prop_get_integer(dsname, "zoned", &zoned,
 631                             setpoint))
 632                                 return (EPERM);
 633                         if (!zoned || strlen(dsname) <= strlen(setpoint))
 634                                 return (EPERM);
 635                 }
 636                 break;
 637 
 638         case ZFS_PROP_MLSLABEL:
 639                 if (!is_system_labeled())
 640                         return (EPERM);
 641 
 642                 if (nvpair_value_string(propval, &strval) == 0) {
 643                         int err;
 644 
 645                         err = zfs_set_slabel_policy(dsname, strval, CRED());
 646                         if (err != 0)
 647                                 return (err);


2369 
2370         if (nvpair_type(pair) == DATA_TYPE_NVLIST) {
2371                 nvlist_t *attrs;
2372                 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0);
2373                 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE,
2374                     &pair) == 0);
2375         }
2376 
2377         if (zfs_prop_get_type(prop) == PROP_TYPE_STRING)
2378                 return (-1);
2379 
2380         VERIFY(0 == nvpair_value_uint64(pair, &intval));
2381 
2382         switch (prop) {
2383         case ZFS_PROP_QUOTA:
2384                 err = dsl_dir_set_quota(dsname, source, intval);
2385                 break;
2386         case ZFS_PROP_REFQUOTA:
2387                 err = dsl_dataset_set_quota(dsname, source, intval);
2388                 break;
2389         case ZFS_PROP_FILESYSTEM_LIMIT:
2390                 err = dsl_dir_validate_fs_ss_limit(dsname, intval,
2391                     ZFS_PROP_FILESYSTEM_LIMIT);
2392                 break;
2393         case ZFS_PROP_SNAPSHOT_LIMIT:
2394                 err = dsl_dir_validate_fs_ss_limit(dsname, intval,
2395                     ZFS_PROP_SNAPSHOT_LIMIT);
2396                 break;
2397         case ZFS_PROP_RESERVATION:
2398                 err = dsl_dir_set_reservation(dsname, source, intval);
2399                 break;
2400         case ZFS_PROP_REFRESERVATION:
2401                 err = dsl_dataset_set_reservation(dsname, source, intval);
2402                 break;
2403         case ZFS_PROP_VOLSIZE:
2404                 err = zvol_set_volsize(dsname, ddi_driver_major(zfs_dip),
2405                     intval);
2406                 break;
2407         case ZFS_PROP_VERSION:
2408         {
2409                 zfsvfs_t *zfsvfs;
2410 
2411                 if ((err = zfsvfs_hold(dsname, FTAG, &zfsvfs, B_TRUE)) != 0)
2412                         break;
2413 
2414                 err = zfs_set_version(zfsvfs, intval);
2415                 zfsvfs_rele(zfsvfs, FTAG);
2416