以下示例设置了 pset 的 pool.comment 属性。该示例还在 pool.newprop 中创建了新的属性。
该示例的要点包括以下内容:
在对 pool_conf_open() 的调用中,使用静态配置文件中的 PO_RDWR 要求调用方为超级用户。
要在运行此实用程序后提交对 pset 所做的更改,请发出 pooladm -c 命令。要使实用程序提交更改,请使用第二个非零参数调用 pool_conf_commit()。
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")'