/* * This function returns the property information */ static void picld_get_attrinfo(picl_service_t *in) { picl_retattrinfo_t ret; int err; ptree_propinfo_t pinfo; picl_prophdl_t ptreeh; err = cvt_picl2ptree(in->req_attrinfo.attr, &ptreeh); if (err != PICL_SUCCESS) picld_return_error(in->in.cnum, err); ret.cnum = PICL_CNUM_GETATTRINFO; ret.attr = in->req_attrinfo.attr; err = ptree_get_propinfo(ptreeh, &pinfo); if (err != PICL_SUCCESS) picld_return_error(in->in.cnum, err); ret.type = pinfo.piclinfo.type; ret.accessmode = pinfo.piclinfo.accessmode; ret.size = (uint32_t)pinfo.piclinfo.size; (void) strcpy(ret.name, pinfo.piclinfo.name); (void) rw_unlock(&init_lk); (void) door_return((char *)&ret, sizeof (picl_retattrinfo_t), NULL, 0); }
/* * This function returns the value of the PICL property */ static void picld_get_attrval(picl_service_t *in) { picl_retattrval_t *ret; int err; size_t vbufsize; size_t len; door_cred_t cred; picl_prophdl_t ptreeh; ptree_propinfo_t pinfo; if (door_cred(&cred) < 0) picld_return_error(in->in.cnum, PICL_FAILURE); err = cvt_picl2ptree(in->req_attrval.attr, &ptreeh); if (err != PICL_SUCCESS) picld_return_error(in->in.cnum, err); err = ptree_get_propinfo(ptreeh, &pinfo); if (err != PICL_SUCCESS) picld_return_error(in->in.cnum, err); if (!(pinfo.piclinfo.accessmode & PICL_READ)) picld_return_error(in->in.cnum, PICL_NOTREADABLE); vbufsize = pinfo.piclinfo.size; vbufsize = MIN((size_t)in->req_attrval.bufsize, vbufsize); len = sizeof (picl_retattrval_t) + vbufsize; ret = alloca(len); if (ret == NULL) picld_return_error(in->in.cnum, PICL_FAILURE); ret->cnum = PICL_CNUM_GETATTRVAL; ret->attr = in->req_attrval.attr; ret->nbytes = (uint32_t)vbufsize; err = xptree_get_propval_with_cred(ptreeh, ret->ret_buf, vbufsize, cred); if (err != PICL_SUCCESS) picld_return_error(in->in.cnum, err); /* * adjust returned bytes for charstrings */ if (pinfo.piclinfo.type == PICL_PTYPE_CHARSTRING) ret->nbytes = (uint32_t)strlen(ret->ret_buf) + 1; /* * convert handle values to picl handles */ if ((pinfo.piclinfo.type == PICL_PTYPE_TABLE) || (pinfo.piclinfo.type == PICL_PTYPE_REFERENCE)) cvt_ptree2picl(&ret->ret_nodeh); (void) rw_unlock(&init_lk); (void) door_return((char *)ret, sizeof (picl_retattrval_t) + (size_t)ret->nbytes, NULL, 0); }
/* * This function sets a property value */ static void picld_set_attrval(picl_service_t *in) { picl_retsetattrval_t ret; int err; door_cred_t cred; picl_prophdl_t ptreeh; ptree_propinfo_t pinfo; if (door_cred(&cred) < 0) picld_return_error(in->in.cnum, PICL_FAILURE); err = cvt_picl2ptree(in->req_setattrval.attr, &ptreeh); if (err != PICL_SUCCESS) picld_return_error(in->in.cnum, err); err = ptree_get_propinfo(ptreeh, &pinfo); if (err != PICL_SUCCESS) picld_return_error(in->in.cnum, err); if (!(pinfo.piclinfo.accessmode & PICL_WRITE)) picld_return_error(in->in.cnum, PICL_NOTWRITABLE); /* * For non-volatile prop, only super user can set its value. */ if (!(pinfo.piclinfo.accessmode & PICL_VOLATILE) && (cred.dc_euid != SUPER_USER)) picld_return_error(in->in.cnum, PICL_PERMDENIED); ret.cnum = PICL_CNUM_SETATTRVAL; ret.attr = in->req_setattrval.attr; err = xptree_update_propval_with_cred(ptreeh, in->req_setattrval.valbuf, (size_t)in->req_setattrval.bufsize, cred); if (err != PICL_SUCCESS) picld_return_error(in->in.cnum, err); (void) rw_unlock(&init_lk); (void) door_return((char *)&ret, sizeof (picl_retsetattrval_t), NULL, 0); }
/* * Get PICL_PTYPE_CHARSTRING "UnitAddress" property */ static int get_unit_address_prop(picl_nodehdl_t nodeh, void *buf, size_t len) { int err; picl_prophdl_t proph; ptree_propinfo_t pinfo; err = ptree_get_prop_by_name(nodeh, PICL_PROP_UNIT_ADDRESS, &proph); if (err == PICL_SUCCESS) err = ptree_get_propinfo(proph, &pinfo); if (err != PICL_SUCCESS) return (err); if (pinfo.piclinfo.type != PICL_PTYPE_CHARSTRING || pinfo.piclinfo.size > len) return (PICL_FAILURE); err = ptree_get_propval(proph, buf, pinfo.piclinfo.size); return (err); }