/* * dadef_interpret - * parses val and initializes pointers in da_defs_t. * returns pointer to parsed da_defs_t entry, else returns NULL on error. */ static da_defs_t * dadef_interpret(char *val) { struct _dadefbuff *_df = _dadefalloc(); int i; char *opts; kva_t *kvap; kv_t *kvp; if (_df == NULL) return (NULL); (void) strcpy(interpdadefline, val); interpdadefs.devtype = getdadmfield(interpdadefline, KV_TOKEN_DELIMIT); opts = getdadmfield(NULL, KV_TOKEN_DELIMIT); interpdadefs.devopts = NULL; if (interpdadefs.devtype == NULL) return (NULL); if (opts != NULL) interpdadefs.devopts = _str2kva(opts, KV_ASSIGN, KV_DELIMITER); /* remove any extraneous whitespace in the options */ if ((kvap = interpdadefs.devopts) != NULL) { for (i = 0, kvp = kvap->data; i < kvap->length; i++, kvp++) { (void) pack_white(kvp->key); (void) pack_white(kvp->value); } } return (&interpdadefs); }
/* * da_interpret - * parses val and initializes pointers in devalloc_t. * returns pointer to parsed devalloc_t entry, else returns NULL on error. */ static devalloc_t * da_interpret(char *val) { struct _dabuff *_da = _daalloc(); char *opts; int i; kva_t *kvap; kv_t *kvp; if (_da == NULL) return (NULL); (void) strcpy(interpdaline, val); interpdevalloc.da_devname = getdadmfield(interpdaline, KV_DELIMITER); interpdevalloc.da_devtype = getdadmfield(NULL, KV_DELIMITER); opts = getdadmfield(NULL, KV_DELIMITER); (void) getdadmfield(NULL, KV_DELIMITER); /* reserved field */ interpdevalloc.da_devauth = getdadmfield(NULL, KV_DELIMITER); interpdevalloc.da_devexec = getdadmfield(NULL, KV_DELIMITER); interpdevalloc.da_devopts = NULL; if (interpdevalloc.da_devname == NULL || interpdevalloc.da_devtype == NULL) return (NULL); if ((opts != NULL) && (strncmp(opts, DA_RESERVED, strlen(DA_RESERVED)) != 0)) { interpdevalloc.da_devopts = _str2kva(opts, KV_ASSIGN, KV_TOKEN_DELIMIT); } /* remove any extraneous whitespace in the options */ if ((kvap = interpdevalloc.da_devopts) != NULL) { for (i = 0, kvp = kvap->data; i < kvap->length; i++, kvp++) { (void) pack_white(kvp->key); (void) pack_white(kvp->value); } } if (system_labeled) { /* if label range is not defined, use the default range. */ int i = 0, nlen = 0; char *minstr = NULL, *maxstr = NULL; kva_t *nkvap = NULL; kv_t *ndata = NULL, *odata = NULL; if (kvap == NULL) { nlen = 2; /* minlabel, maxlabel */ } else { nlen += kvap->length; if ((minstr = kva_match(kvap, DAOPT_MINLABEL)) == NULL) nlen++; if ((maxstr = kva_match(kvap, DAOPT_MAXLABEL)) == NULL) nlen++; } if ((minstr != NULL) && (maxstr != NULL)) /* * label range provided; we don't need to construct * default range. */ goto out; nkvap = _new_kva(nlen); ndata = nkvap->data; if (kvap != NULL) { for (i = 0; i < kvap->length; i++) { odata = kvap->data; ndata[i].key = _strdup_null(odata[i].key); ndata[i].value = _strdup_null(odata[i].value); nkvap->length++; } } if (minstr == NULL) { ndata[i].key = strdup(DAOPT_MINLABEL); ndata[i].value = strdup(DA_DEFAULT_MIN); nkvap->length++; i++; } if (maxstr == NULL) { ndata[i].key = strdup(DAOPT_MAXLABEL); ndata[i].value = strdup(DA_DEFAULT_MAX); nkvap->length++; } interpdevalloc.da_devopts = nkvap; } out: return (&interpdevalloc); }