The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/openzfs/module/zfs/zcp_set.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * CDDL HEADER START
    3  *
    4  * This file and its contents are supplied under the terms of the
    5  * Common Development and Distribution License ("CDDL"), version 1.0.
    6  * You may only use this file in accordance with the terms of version
    7  * 1.0 of the CDDL.
    8  *
    9  * A full copy of the text of the CDDL should have accompanied this
   10  * source.  A copy of the CDDL is also available via the Internet at
   11  * http://www.illumos.org/license/CDDL.
   12  *
   13  * CDDL HEADER END
   14  */
   15 
   16 /*
   17  * Copyright (c) 2016 by Delphix. All rights reserved.
   18  * Copyrigh 2020 Joyent, Inc.
   19  */
   20 
   21 #include <sys/lua/lua.h>
   22 #include <sys/lua/lualib.h>
   23 #include <sys/lua/lauxlib.h>
   24 
   25 #include <sys/dsl_prop.h>
   26 #include <sys/dsl_dir.h>
   27 #include <sys/dsl_synctask.h>
   28 #include <sys/dsl_dataset.h>
   29 #include <sys/zcp.h>
   30 #include <sys/zcp_set.h>
   31 #include <sys/zcp_iter.h>
   32 #include <sys/zcp_global.h>
   33 #include <sys/zvol.h>
   34 
   35 #include <zfs_prop.h>
   36 
   37 static void
   38 zcp_set_user_prop(lua_State *state, dsl_pool_t *dp, const char *dsname,
   39     const char *prop_name, const char *prop_val, dmu_tx_t *tx)
   40 {
   41         dsl_dataset_t *ds = zcp_dataset_hold(state, dp, dsname, FTAG);
   42         if (ds == NULL)
   43                 return; /* not reached; zcp_dataset_hold() longjmp'd */
   44 
   45         nvlist_t *nvl = fnvlist_alloc();
   46         fnvlist_add_string(nvl, prop_name, prop_val);
   47 
   48         dsl_props_set_sync_impl(ds, ZPROP_SRC_LOCAL, nvl, tx);
   49 
   50         fnvlist_free(nvl);
   51         dsl_dataset_rele(ds, FTAG);
   52 }
   53 
   54 int
   55 zcp_set_prop_check(void *arg, dmu_tx_t *tx)
   56 {
   57         zcp_set_prop_arg_t *args = arg;
   58         const char *prop_name = args->prop;
   59         dsl_props_set_arg_t dpsa = {
   60                 .dpsa_dsname = args->dsname,
   61                 .dpsa_source = ZPROP_SRC_LOCAL,
   62         };
   63         nvlist_t *nvl = NULL;
   64         int ret = 0;
   65 
   66         /*
   67          * Only user properties are currently supported. When non-user
   68          * properties are supported, we will want to use
   69          * zfs_valid_proplist() to verify the properties.
   70          */
   71         if (!zfs_prop_user(prop_name)) {
   72                 return (EINVAL);
   73         }
   74 
   75         nvl = fnvlist_alloc();
   76         fnvlist_add_string(nvl, args->prop, args->val);
   77         dpsa.dpsa_props = nvl;
   78 
   79         ret = dsl_props_set_check(&dpsa, tx);
   80         nvlist_free(nvl);
   81 
   82         return (ret);
   83 }
   84 
   85 void
   86 zcp_set_prop_sync(void *arg, dmu_tx_t *tx)
   87 {
   88         zcp_set_prop_arg_t *args = arg;
   89         zcp_run_info_t *ri = zcp_run_info(args->state);
   90         dsl_pool_t *dp = ri->zri_pool;
   91 
   92         const char *dsname = args->dsname;
   93         const char *prop_name = args->prop;
   94         const char *prop_val = args->val;
   95 
   96         if (zfs_prop_user(prop_name)) {
   97                 zcp_set_user_prop(args->state, dp, dsname, prop_name,
   98                     prop_val, tx);
   99         }
  100 }

Cache object: dd5e878327f85c083fce0e55ea99786a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.