Solaris 10 资源管理器开发者指南

设置 pool.comment 属性并添加新属性

以下示例设置了 psetpool.comment 属性。该示例还在 pool.newprop 中创建了新的属性。

该示例的要点包括以下内容:

pool_set_comment(const char *pool_name, const char *comment)

{

  pool_t *pool;

  pool_elem_t *pool_elem;

  pool_value_t *pval = pool_value_alloc(); 

  pool_conf_t  *conf = pool_conf_alloc();

  /* NOTE: need to be root to use PO_RDWR on static configuration file */

  pool_conf_open(conf, pool_static_location(), PO_RDWR);

  pool = pool_get_pool(conf,  pool_name);

  pool_value_set_string(pval, comment);

  pool_elem = pool_to_elem(conf, pool);

  pool_put_property(conf, pool_elem, "pool.comment", pval);

  printf("pool %s: pool.comment set to %s\n:" pool_name, comment);

  /* Now, create a new property, customized to installation site */

  pool_value_set_string(pval, "New String Property");

  pool_put_property(conf, pool_elem, "pool.newprop", pval);

  pool_conf_commit(conf, 0); /* NOTE: use 0 to ensure only */

                             /* static file gets updated */

  pool_value_free(pval);

  pool_conf_close(conf);

  pool_conf_free(conf);

  /* NOTE: Use "pooladm -c" later, or pool_conf_commit(conf, 1) */

  /* above for changes to the running system */

}

另一种修改池的注释并添加新的池属性的方法是使用 poolcfg(1M)。

poolcfg -c 'modify pool pool-name (string pool.comment = "cmt-string")'

poolcfg -c 'modify pool pool-name (string pool.newprop = 

                                   "New String Property")'