2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A
2N/A#include "cfga_fp.h"
2N/A
2N/Astatic fpcfga_ret_t fp_rcm_init(char *, cfga_flags_t, char **, uint_t *,
2N/A char **rsrc_fixed);
2N/Astatic int fp_rcm_process_node(di_node_t, void *);
2N/Astatic fpcfga_ret_t fp_rcm_info_table(rcm_info_t *, char **);
2N/Astatic char *chop_minor(char *);
2N/A
2N/A#define MAX_FORMAT 80
2N/A#define DEVICES "/devices"
2N/A
2N/Atypedef struct {
2N/A char *bus_path;
2N/A char *filter;
2N/A char **errstring;
2N/A fpcfga_ret_t ret;
2N/A cfga_flags_t flags;
2N/A fpcfga_ret_t (*func)(char *, char *, char **, cfga_flags_t);
2N/A} walkargs_t;
2N/A
2N/Astatic fpcfga_ret_t fp_rcm_info_table(rcm_info_t *, char **);
2N/Astatic int fp_rcm_process_node(di_node_t, void *);
2N/Astatic fpcfga_ret_t fp_rcm_init(char *, cfga_flags_t, char **, uint_t *,
2N/A char **);
2N/Astatic char *chop_minor(char *);
2N/A
2N/Astatic rcm_handle_t *rcm_handle = NULL;
2N/Astatic mutex_t rcm_handle_lock;
2N/A
2N/A/*
2N/A * fp_rcm_offline()
2N/A *
2N/A * Offline FP resource consumers.
2N/A */
2N/Afpcfga_ret_t
2N/Afp_rcm_offline(char *rsrc, char **errstring, cfga_flags_t flags)
2N/A{
2N/A int rret;
2N/A uint_t rflags = 0;
2N/A char *rsrc_fixed;
2N/A rcm_info_t *rinfo = NULL;
2N/A fpcfga_ret_t ret = FPCFGA_OK;
2N/A
2N/A if ((ret = fp_rcm_init(rsrc, flags, errstring, &rflags, &rsrc_fixed))
2N/A != FPCFGA_OK)
2N/A return (ret);
2N/A
2N/A if ((rret = rcm_request_offline(rcm_handle, rsrc_fixed, rflags, &rinfo))
2N/A != RCM_SUCCESS) {
2N/A cfga_err(errstring, 0, ERRARG_RCM_OFFLINE, rsrc_fixed, 0);
2N/A if (rinfo) {
2N/A (void) fp_rcm_info_table(rinfo, errstring);
2N/A rcm_free_info(rinfo);
2N/A }
2N/A if (rret == RCM_FAILURE)
2N/A (void) fp_rcm_online(rsrc, errstring, flags);
2N/A ret = FPCFGA_BUSY;
2N/A }
2N/A
2N/A S_FREE(rsrc_fixed);
2N/A
2N/A return (ret);
2N/A}
2N/A
2N/A/*
2N/A * fp_rcm_online()
2N/A *
2N/A * Online FP resource consumers that were previously offlined.
2N/A */
2N/Afpcfga_ret_t
2N/Afp_rcm_online(char *rsrc, char **errstring, cfga_flags_t flags)
2N/A{
2N/A char *rsrc_fixed;
2N/A rcm_info_t *rinfo = NULL;
2N/A fpcfga_ret_t ret = FPCFGA_OK;
2N/A
2N/A if ((ret = fp_rcm_init(rsrc, flags, errstring, NULL, &rsrc_fixed))
2N/A != FPCFGA_OK)
2N/A return (ret);
2N/A
2N/A if (rcm_notify_online(rcm_handle, rsrc_fixed, 0, &rinfo)
2N/A != RCM_SUCCESS && rinfo != NULL) {
2N/A cfga_err(errstring, 0, ERRARG_RCM_ONLINE, rsrc_fixed, 0);
2N/A (void) fp_rcm_info_table(rinfo, errstring);
2N/A rcm_free_info(rinfo);
2N/A ret = FPCFGA_ERR;
2N/A }
2N/A
2N/A S_FREE(rsrc_fixed);
2N/A
2N/A return (ret);
2N/A}
2N/A
2N/A/*
2N/A * fp_rcm_remove()
2N/A *
2N/A * Remove FP resource consumers after their kernel removal.
2N/A */
2N/Afpcfga_ret_t
2N/Afp_rcm_remove(char *rsrc, char **errstring, cfga_flags_t flags)
2N/A{
2N/A char *rsrc_fixed;
2N/A rcm_info_t *rinfo = NULL;
2N/A fpcfga_ret_t ret = FPCFGA_OK;
2N/A
2N/A if ((ret = fp_rcm_init(rsrc, flags, errstring, NULL, &rsrc_fixed))
2N/A != FPCFGA_OK)
2N/A return (ret);
2N/A
2N/A if (rcm_notify_remove(rcm_handle, rsrc_fixed, 0, &rinfo)
2N/A != RCM_SUCCESS) {
2N/A cfga_err(errstring, 0, ERRARG_RCM_REMOVE, rsrc_fixed, 0);
2N/A if (rinfo) {
2N/A (void) fp_rcm_info_table(rinfo, errstring);
2N/A rcm_free_info(rinfo);
2N/A }
2N/A ret = FPCFGA_ERR;
2N/A }
2N/A
2N/A S_FREE(rsrc_fixed);
2N/A
2N/A return (ret);
2N/A}
2N/A
2N/A/*
2N/A * fp_rcm_suspend()
2N/A *
2N/A * Suspend FP resource consumers before a bus quiesce.
2N/A */
2N/Afpcfga_ret_t
2N/Afp_rcm_suspend(char *rsrc, char *filter, char **errstring, cfga_flags_t flags)
2N/A{
2N/A int rret;
2N/A uint_t rflags = 0;
2N/A char *rsrc_fixed;
2N/A char *filter_fixed;
2N/A char *rsrc_devpath;
2N/A rcm_info_t *rinfo = NULL;
2N/A di_node_t node;
2N/A fpcfga_ret_t ret = FPCFGA_OK;
2N/A walkargs_t walkargs;
2N/A timespec_t zerotime = { 0, 0 };
2N/A
2N/A if ((ret = fp_rcm_init(rsrc, flags, errstring, &rflags, &rsrc_fixed))
2N/A != FPCFGA_OK)
2N/A return (ret);
2N/A
2N/A /* If a filter is provided, ensure that it makes sense */
2N/A if (filter != NULL && strstr(filter, rsrc) != filter) {
2N/A S_FREE(rsrc_fixed);
2N/A cfga_err(errstring, 0, ERR_APID_INVAL, 0);
2N/A return (FPCFGA_ERR);
2N/A }
2N/A
2N/A /*
2N/A * If no filter is specified: attempt a suspension on the resource,
2N/A * directly.
2N/A */
2N/A if (filter == NULL) {
2N/A if ((rret = rcm_request_suspend(rcm_handle, rsrc_fixed, rflags,
2N/A &zerotime, &rinfo)) != RCM_SUCCESS) {
2N/A cfga_err(errstring, 0, ERRARG_RCM_SUSPEND, rsrc_fixed,
2N/A 0);
2N/A if (rinfo) {
2N/A (void) fp_rcm_info_table(rinfo, errstring);
2N/A rcm_free_info(rinfo);
2N/A }
2N/A if (rret == RCM_FAILURE)
2N/A (void) fp_rcm_resume(rsrc, filter, errstring,
2N/A (flags & (~CFGA_FLAG_FORCE)));
2N/A ret = FPCFGA_BUSY;
2N/A }
2N/A S_FREE(rsrc_fixed);
2N/A return (ret);
2N/A }
2N/A
2N/A /*
2N/A * If a filter is specified: open the resource with libdevinfo, walk
2N/A * through its nodes, and attempt a suspension of each node that
2N/A * mismatches the filter.
2N/A */
2N/A
2N/A /* Chop off the filter's minor name */
2N/A if ((filter_fixed = chop_minor(filter)) == NULL)
2N/A return (FPCFGA_ERR);
2N/A
2N/A /* get a libdevinfo snapshot of the resource's subtree */
2N/A rsrc_devpath = rsrc_fixed;
2N/A if (strstr(rsrc_fixed, DEVICES) != NULL)
2N/A rsrc_devpath += strlen(DEVICES);
2N/A node = di_init(rsrc_devpath, DINFOSUBTREE | DINFOMINOR);
2N/A if (node == DI_NODE_NIL) {
2N/A cfga_err(errstring, 0, ERRARG_DEVINFO, rsrc_fixed, 0);
2N/A ret = FPCFGA_ERR;
2N/A }
2N/A
2N/A /* apply the filter, and suspend all resources not filtered out */
2N/A if (ret == FPCFGA_OK) {
2N/A
2N/A walkargs.bus_path = rsrc_fixed;
2N/A walkargs.filter = filter_fixed;
2N/A walkargs.errstring = errstring;
2N/A walkargs.ret = FPCFGA_OK;
2N/A walkargs.flags = rflags;
2N/A walkargs.func = fp_rcm_suspend;
2N/A
2N/A if (di_walk_node(node, 0, &walkargs, fp_rcm_process_node) < 0)
2N/A cfga_err(errstring, 0, ERRARG_DEVINFO, rsrc_fixed, 0);
2N/A
2N/A ret = walkargs.ret;
2N/A }
2N/A
2N/A if (node != DI_NODE_NIL)
2N/A di_fini(node);
2N/A
2N/A S_FREE(rsrc_fixed);
2N/A S_FREE(filter_fixed);
2N/A
2N/A if (ret != FPCFGA_OK)
2N/A (void) fp_rcm_resume(rsrc, filter, errstring,
2N/A (flags & (~CFGA_FLAG_FORCE)));
2N/A
2N/A return (ret);
2N/A}
2N/A
2N/A/*
2N/A * fp_rcm_resume()
2N/A *
2N/A * Resume FP resource consumers after a bus has been unquiesced.
2N/A */
2N/Afpcfga_ret_t
2N/Afp_rcm_resume(char *rsrc, char *filter, char **errstring, cfga_flags_t flags)
2N/A{
2N/A uint_t rflags = 0;
2N/A char *rsrc_fixed;
2N/A char *filter_fixed;
2N/A char *rsrc_devpath;
2N/A rcm_info_t *rinfo = NULL;
2N/A di_node_t node;
2N/A fpcfga_ret_t ret = FPCFGA_OK;
2N/A walkargs_t walkargs;
2N/A
2N/A if ((ret = fp_rcm_init(rsrc, flags, errstring, &rflags, &rsrc_fixed))
2N/A != FPCFGA_OK)
2N/A return (ret);
2N/A
2N/A /* If a filter is provided, ensure that it makes sense */
2N/A if (filter != NULL && strstr(filter, rsrc) != filter) {
2N/A S_FREE(rsrc_fixed);
2N/A cfga_err(errstring, 0, ERR_APID_INVAL, 0);
2N/A return (FPCFGA_ERR);
2N/A }
2N/A
2N/A /*
2N/A * If no filter is specified: resume the resource directly.
2N/A */
2N/A if (filter == NULL) {
2N/A if (rcm_notify_resume(rcm_handle, rsrc_fixed, rflags, &rinfo)
2N/A != RCM_SUCCESS && rinfo != NULL) {
2N/A cfga_err(errstring, 0, ERRARG_RCM_RESUME, rsrc_fixed,
2N/A 0);
2N/A (void) fp_rcm_info_table(rinfo, errstring);
2N/A rcm_free_info(rinfo);
2N/A ret = FPCFGA_BUSY;
2N/A }
2N/A S_FREE(rsrc_fixed);
2N/A return (ret);
2N/A }
2N/A
2N/A /*
2N/A * If a filter is specified: open the resource with libdevinfo, walk
2N/A * through its nodes, and resume each of its nodes that mismatches
2N/A * the filter.
2N/A */
2N/A
2N/A /* Chop off the filter's minor name */
2N/A if ((filter_fixed = chop_minor(filter)) == NULL)
2N/A return (FPCFGA_ERR);
2N/A
2N/A /* get a libdevinfo snapshot of the resource's subtree */
2N/A rsrc_devpath = rsrc_fixed;
2N/A if (strstr(rsrc_fixed, DEVICES) != NULL)
2N/A rsrc_devpath += strlen(DEVICES);
2N/A node = di_init(rsrc_devpath, DINFOSUBTREE | DINFOMINOR);
2N/A if (node == DI_NODE_NIL) {
2N/A cfga_err(errstring, 0, ERRARG_DEVINFO, rsrc_fixed, 0);
2N/A ret = FPCFGA_ERR;
2N/A }
2N/A
2N/A /* apply the filter, and resume all resources not filtered out */
2N/A if (ret == FPCFGA_OK) {
2N/A
2N/A walkargs.bus_path = rsrc_fixed;
2N/A walkargs.filter = filter_fixed;
2N/A walkargs.errstring = errstring;
2N/A walkargs.ret = FPCFGA_OK;
2N/A walkargs.flags = rflags;
2N/A walkargs.func = fp_rcm_resume;
2N/A
2N/A if (di_walk_node(node, 0, &walkargs, fp_rcm_process_node) < 0)
2N/A cfga_err(errstring, 0, ERRARG_DEVINFO, rsrc_fixed, 0);
2N/A
2N/A ret = walkargs.ret;
2N/A }
2N/A
2N/A if (node != DI_NODE_NIL)
2N/A di_fini(node);
2N/A
2N/A S_FREE(rsrc_fixed);
2N/A S_FREE(filter_fixed);
2N/A
2N/A return (ret);
2N/A}
2N/A
2N/A/*
2N/A * fp_rcm_info
2N/A *
2N/A * Queries RCM information for resources, and formats it into a table.
2N/A * The table is appended to the info argument. If the info argument is a
2N/A * null pointer, then a new string is malloc'ed. If the info argument is
2N/A * not a null pointer, then it is realloc'ed to the required size.
2N/A */
2N/Afpcfga_ret_t
2N/Afp_rcm_info(char *rsrc, char **errstring, char **info)
2N/A{
2N/A char *rsrc_fixed;
2N/A rcm_info_t *rinfo = NULL;
2N/A fpcfga_ret_t ret = FPCFGA_OK;
2N/A
2N/A if ((ret = fp_rcm_init(rsrc, 0, errstring, NULL, &rsrc_fixed))
2N/A != FPCFGA_OK)
2N/A return (ret);
2N/A
2N/A if (info == NULL) {
2N/A S_FREE(rsrc_fixed);
2N/A return (FPCFGA_ERR);
2N/A }
2N/A
2N/A if (rcm_get_info(rcm_handle, rsrc_fixed, 0, &rinfo)
2N/A != RCM_SUCCESS) {
2N/A cfga_err(errstring, 0, ERRARG_RCM_INFO, rsrc_fixed, 0);
2N/A ret = FPCFGA_ERR;
2N/A } else if (rinfo == NULL)
2N/A ret = FPCFGA_OK;
2N/A
2N/A if (rinfo) {
2N/A if ((ret = fp_rcm_info_table(rinfo, info)) != FPCFGA_OK)
2N/A cfga_err(errstring, 0, ERRARG_RCM_INFO, rsrc_fixed, 0);
2N/A rcm_free_info(rinfo);
2N/A }
2N/A
2N/A S_FREE(rsrc_fixed);
2N/A
2N/A return (ret);
2N/A}
2N/A
2N/A/*
2N/A * fp_rcm_init()
2N/A *
2N/A * Contains common initialization code for entering a fp_rcm_xx()
2N/A * routine.
2N/A */
2N/Astatic fpcfga_ret_t
2N/Afp_rcm_init(char *rsrc, cfga_flags_t flags, char **errstring, uint_t *rflags,
2N/A char **rsrc_fixed)
2N/A{
2N/A /* Validate the rsrc argument */
2N/A if (rsrc == NULL) {
2N/A cfga_err(errstring, 0, ERR_APID_INVAL, 0);
2N/A return (FPCFGA_ERR);
2N/A }
2N/A
2N/A /* Translate the cfgadm flags to RCM flags */
2N/A if (rflags && (flags & CFGA_FLAG_FORCE))
2N/A *rflags |= RCM_FORCE;
2N/A
2N/A /* Get a handle for the RCM operations */
2N/A (void) mutex_lock(&rcm_handle_lock);
2N/A if (rcm_handle == NULL) {
2N/A if (rcm_alloc_handle(NULL, RCM_NOPID, NULL, &rcm_handle) !=
2N/A RCM_SUCCESS) {
2N/A cfga_err(errstring, 0, ERR_RCM_HANDLE, 0);
2N/A (void) mutex_unlock(&rcm_handle_lock);
2N/A return (FPCFGA_LIB_ERR);
2N/A }
2N/A }
2N/A (void) mutex_unlock(&rcm_handle_lock);
2N/A
2N/A /* Chop off the rsrc's minor, if it has one */
2N/A if ((*rsrc_fixed = chop_minor(rsrc)) == NULL)
2N/A return (FPCFGA_ERR);
2N/A
2N/A return (FPCFGA_OK);
2N/A}
2N/A
2N/A/*
2N/A * fp_rcm_process_node
2N/A *
2N/A * Helper routine for fp_rcm_{suspend,resume}. This is a di_walk_node()
2N/A * callback that will apply a filter to every node it sees, and either suspend
2N/A * or resume it if it doesn't match the filter.
2N/A */
2N/Astatic int
2N/Afp_rcm_process_node(di_node_t node, void *argp)
2N/A{
2N/A char *devfs_path;
2N/A walkargs_t *walkargs;
2N/A fpcfga_ret_t ret = FPCFGA_OK;
2N/A char disk_path[MAXPATHLEN];
2N/A
2N/A /* Guard against bad arguments */
2N/A if ((walkargs = (walkargs_t *)argp) == NULL)
2N/A return (DI_WALK_TERMINATE);
2N/A if (walkargs->filter == NULL || walkargs->errstring == NULL) {
2N/A walkargs->ret = FPCFGA_ERR;
2N/A return (DI_WALK_TERMINATE);
2N/A }
2N/A
2N/A /* If the node has no minors, then skip it */
2N/A if (di_minor_next(node, DI_MINOR_NIL) == DI_MINOR_NIL)
2N/A return (DI_WALK_CONTINUE);
2N/A
2N/A /* Construct the devices path */
2N/A if ((devfs_path = di_devfs_path(node)) == NULL)
2N/A return (DI_WALK_CONTINUE);
2N/A (void) snprintf(disk_path, MAXPATHLEN, "%s%s", DEVICES, devfs_path);
2N/A di_devfs_path_free(devfs_path);
2N/A
2N/A /*
2N/A * If the node does not correspond to the targeted FP bus or the
2N/A * disk being filtered out, then use the appropriate suspend/resume
2N/A * function.
2N/A */
2N/A if (strcmp(disk_path, walkargs->bus_path) != 0 &&
2N/A strcmp(disk_path, walkargs->filter) != 0)
2N/A ret = (*walkargs->func)(disk_path, NULL, walkargs->errstring,
2N/A walkargs->flags);
2N/A
2N/A /* Stop the walk early if the above operation failed */
2N/A if (ret != FPCFGA_OK) {
2N/A walkargs->ret = ret;
2N/A return (DI_WALK_TERMINATE);
2N/A }
2N/A
2N/A return (DI_WALK_CONTINUE);
2N/A}
2N/A
2N/A/*
2N/A * fp_rcm_info_table
2N/A *
2N/A * Takes an opaque rcm_info_t pointer and a character pointer, and appends
2N/A * the rcm_info_t data in the form of a table to the given character pointer.
2N/A */
2N/Astatic fpcfga_ret_t
2N/Afp_rcm_info_table(rcm_info_t *rinfo, char **table)
2N/A{
2N/A int i;
2N/A size_t w;
2N/A size_t width = 0;
2N/A size_t w_rsrc = 0;
2N/A size_t w_info = 0;
2N/A size_t table_size = 0;
2N/A uint_t tuples = 0;
2N/A rcm_info_tuple_t *tuple = NULL;
2N/A char *rsrc;
2N/A char *info;
2N/A char *newtable;
2N/A static char format[MAX_FORMAT];
2N/A const char *info_info_str, *info_rsrc_str;
2N/A
2N/A /* Protect against invalid arguments */
2N/A if (rinfo == NULL || table == NULL)
2N/A return (FPCFGA_ERR);
2N/A
2N/A /* Set localized table header strings */
2N/A rsrc = gettext("Resource");
2N/A info = gettext("Information");
2N/A
2N/A /* A first pass, to size up the RCM information */
2N/A while (tuple = rcm_info_next(rinfo, tuple)) {
2N/A info_info_str = rcm_info_info(tuple);
2N/A info_rsrc_str = rcm_info_rsrc(tuple);
2N/A if ((info_info_str != NULL) && (info_rsrc_str != NULL)) {
2N/A tuples++;
2N/A if ((w = strlen(info_rsrc_str)) > w_rsrc)
2N/A w_rsrc = w;
2N/A if ((w = strlen(info_info_str)) > w_info)
2N/A w_info = w;
2N/A }
2N/A }
2N/A
2N/A /* If nothing was sized up above, stop early */
2N/A if (tuples == 0)
2N/A return (FPCFGA_OK);
2N/A
2N/A /* Adjust column widths for column headings */
2N/A if ((w = strlen(rsrc)) > w_rsrc)
2N/A w_rsrc = w;
2N/A else if ((w_rsrc - w) % 2)
2N/A w_rsrc++;
2N/A if ((w = strlen(info)) > w_info)
2N/A w_info = w;
2N/A else if ((w_info - w) % 2)
2N/A w_info++;
2N/A
2N/A /*
2N/A * Compute the total line width of each line,
2N/A * accounting for intercolumn spacing.
2N/A */
2N/A width = w_info + w_rsrc + 4;
2N/A
2N/A /* Allocate space for the table */
2N/A table_size = (2 + tuples) * (width + 1) + 2;
2N/A if (*table == NULL)
2N/A *table = malloc(table_size);
2N/A else {
2N/A newtable = realloc(*table, strlen(*table) + table_size);
2N/A if (newtable != NULL)
2N/A *table = newtable;
2N/A }
2N/A if (*table == NULL)
2N/A return (FPCFGA_ERR);
2N/A
2N/A /* Place a table header into the string */
2N/A
2N/A /* The resource header */
2N/A (void) strcat(*table, "\n");
2N/A w = strlen(rsrc);
2N/A for (i = 0; i < ((w_rsrc - w) / 2); i++)
2N/A (void) strcat(*table, " ");
2N/A (void) strcat(*table, rsrc);
2N/A for (i = 0; i < ((w_rsrc - w) / 2); i++)
2N/A (void) strcat(*table, " ");
2N/A
2N/A /* The information header */
2N/A (void) strcat(*table, " ");
2N/A w = strlen(info);
2N/A for (i = 0; i < ((w_info - w) / 2); i++)
2N/A (void) strcat(*table, " ");
2N/A (void) strcat(*table, info);
2N/A for (i = 0; i < ((w_info - w) / 2); i++)
2N/A (void) strcat(*table, " ");
2N/A
2N/A /* Underline the headers */
2N/A (void) strcat(*table, "\n");
2N/A for (i = 0; i < w_rsrc; i++)
2N/A (void) strcat(*table, "-");
2N/A (void) strcat(*table, " ");
2N/A for (i = 0; i < w_info; i++)
2N/A (void) strcat(*table, "-");
2N/A
2N/A /* Construct the format string */
2N/A (void) snprintf(format, MAX_FORMAT, "%%-%ds %%-%ds", w_rsrc, w_info);
2N/A
2N/A /* Add the tuples to the table string */
2N/A tuple = NULL;
2N/A while ((tuple = rcm_info_next(rinfo, tuple)) != NULL) {
2N/A info_info_str = rcm_info_info(tuple);
2N/A info_rsrc_str = rcm_info_rsrc(tuple);
2N/A if ((info_info_str != NULL) && (info_rsrc_str != NULL)) {
2N/A (void) strcat(*table, "\n");
2N/A (void) sprintf(&((*table)[strlen(*table)]),
2N/A format, info_rsrc_str, info_info_str);
2N/A }
2N/A }
2N/A
2N/A return (FPCFGA_OK);
2N/A}
2N/A
2N/A/*
2N/A * chop_minor()
2N/A *
2N/A * Chops off the minor name portion of a resource. Allocates storage for
2N/A * the returned string. Caller must free the storage if return is non-NULL.
2N/A */
2N/Astatic char *
2N/Achop_minor(char *rsrc)
2N/A{
2N/A char *rsrc_fixed;
2N/A char *cp;
2N/A
2N/A if ((rsrc_fixed = strdup(rsrc)) == NULL)
2N/A return (NULL);
2N/A if ((cp = strrchr(rsrc_fixed, ':')) != NULL)
2N/A *cp = '\0';
2N/A return (rsrc_fixed);
2N/A}