1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2002-2003 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 27*0Sstevel@tonic-gate /* All Rights Reserved */ 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate /* 33*0Sstevel@tonic-gate * Implements the main body of the "getdgrp" command. 34*0Sstevel@tonic-gate */ 35*0Sstevel@tonic-gate #include <sys/types.h> 36*0Sstevel@tonic-gate #include <stdio.h> 37*0Sstevel@tonic-gate #include <errno.h> 38*0Sstevel@tonic-gate #include <stdlib.h> 39*0Sstevel@tonic-gate #include <string.h> 40*0Sstevel@tonic-gate #include <devmgmt.h> 41*0Sstevel@tonic-gate #include <devtab.h> 42*0Sstevel@tonic-gate #include <fmtmsg.h> 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate /* 46*0Sstevel@tonic-gate * Local Definitions 47*0Sstevel@tonic-gate * TRUE Boolean TRUE value 48*0Sstevel@tonic-gate * FALSE Boolean FALSE value 49*0Sstevel@tonic-gate * NULL Null address 50*0Sstevel@tonic-gate */ 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate #ifndef TRUE 53*0Sstevel@tonic-gate #define TRUE 1 54*0Sstevel@tonic-gate #endif 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate #ifndef FALSE 57*0Sstevel@tonic-gate #define FALSE 0 58*0Sstevel@tonic-gate #endif 59*0Sstevel@tonic-gate 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gate /* 62*0Sstevel@tonic-gate * Exit codes: 63*0Sstevel@tonic-gate * EX_OK All's well that ends well 64*0Sstevel@tonic-gate * EX_ERROR Some other error occurred 65*0Sstevel@tonic-gate * EX_DTAB Device table couldn't be opened 66*0Sstevel@tonic-gate * EX_DGRP Device-group table couldn't be open. 67*0Sstevel@tonic-gate */ 68*0Sstevel@tonic-gate 69*0Sstevel@tonic-gate #define EX_OK 0 70*0Sstevel@tonic-gate #define EX_ERROR 1 71*0Sstevel@tonic-gate #define EX_DTAB 2 72*0Sstevel@tonic-gate #define EX_DGRP 2 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate /* 76*0Sstevel@tonic-gate * Messages: 77*0Sstevel@tonic-gate * M_USAGE Command usage error 78*0Sstevel@tonic-gate * M_ERROR Some unexpected error 79*0Sstevel@tonic-gate * M_DEVTAB Device table couldn't be opened 80*0Sstevel@tonic-gate * M_DGROUP Device-group table couldn't be opened 81*0Sstevel@tonic-gate */ 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate #define M_USAGE "usage: getdgrp [-ael] [criterion [...]] [dgroup [...]]" 84*0Sstevel@tonic-gate #define M_ERROR "Internal error, errno=%d" 85*0Sstevel@tonic-gate #define M_DEVTAB "Cannot open the device table: %s" 86*0Sstevel@tonic-gate #define M_DGROUP "Cannot open the device-group table: %s" 87*0Sstevel@tonic-gate 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate /* 90*0Sstevel@tonic-gate * Internal References 91*0Sstevel@tonic-gate * buildcriterialist() Builds a list of the criteria on the 92*0Sstevel@tonic-gate * command line 93*0Sstevel@tonic-gate * buildgrouplist() Builds a list of the device-groups mentioned 94*0Sstevel@tonic-gate * on the command line 95*0Sstevel@tonic-gate */ 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate static char **buildcriterialist(); /* Builds criteria list from command line */ 98*0Sstevel@tonic-gate static char **builddgrouplist(); /* Builds dgroup list from command line */ 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gate 101*0Sstevel@tonic-gate /* 102*0Sstevel@tonic-gate * Macros 103*0Sstevel@tonic-gate * stdmsg(r,l,s,t) Generate a standard message 104*0Sstevel@tonic-gate * r Recoverability flag 105*0Sstevel@tonic-gate * l Standard label 106*0Sstevel@tonic-gate * s Severity 107*0Sstevel@tonic-gate * t Text 108*0Sstevel@tonic-gate * isacriterion(p) Returns TRUE if *p is a criterion, FALSE otherwise 109*0Sstevel@tonic-gate */ 110*0Sstevel@tonic-gate 111*0Sstevel@tonic-gate #define stdmsg(r,l,s,t) (void) fmtmsg(MM_PRINT|MM_UTIL|r,l,s,t,MM_NULLACT,MM_NULLTAG) 112*0Sstevel@tonic-gate #define isacriterion(p) (strchr(*arglist,'=')||strchr(*arglist,':')) 113*0Sstevel@tonic-gate 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate /* 116*0Sstevel@tonic-gate * Static Variables 117*0Sstevel@tonic-gate * lbl Buffer for standard message label 118*0Sstevel@tonic-gate * txt Buffer for standard message text 119*0Sstevel@tonic-gate */ 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gate static char lbl[MM_MXLABELLN+1]; 122*0Sstevel@tonic-gate static char txt[MM_MXTXTLN+1]; 123*0Sstevel@tonic-gate 124*0Sstevel@tonic-gate /* 125*0Sstevel@tonic-gate * getdgrp [-ael] [criterion [...]] [dgroup [...]] 126*0Sstevel@tonic-gate * 127*0Sstevel@tonic-gate * This function gets the device groups that contain as members devices 128*0Sstevel@tonic-gate * that match the given criteria. 129*0Sstevel@tonic-gate * 130*0Sstevel@tonic-gate * Options: 131*0Sstevel@tonic-gate * -a A device must meet all criteria before the device-group in 132*0Sstevel@tonic-gate * which it is a member can be selected for inclusion in the 133*0Sstevel@tonic-gate * generated list. If this option is missing, a device must 134*0Sstevel@tonic-gate * meet at least one criterion before it's group can be 135*0Sstevel@tonic-gate * selected. This option has no affect if there are no criterion 136*0Sstevel@tonic-gate * on the command-line. 137*0Sstevel@tonic-gate * -e The list of device groups specifies groups to exclude from 138*0Sstevel@tonic-gate * the generated list. If this option is omitted, the list 139*0Sstevel@tonic-gate * of groups is the set of groups that can be selected. This 140*0Sstevel@tonic-gate * option has no effect if there are no device-groups on the 141*0Sstevel@tonic-gate * command-line. 142*0Sstevel@tonic-gate * -l List all device groups, even those that have no valid 143*0Sstevel@tonic-gate * members (this option has no effect if criterion are specified 144*0Sstevel@tonic-gate * 145*0Sstevel@tonic-gate * Arguments: 146*0Sstevel@tonic-gate * criterion A device criterion of the form <attr><op><val> where 147*0Sstevel@tonic-gate * <attr> is the name of an attribute, <op> is "=", "!=", 148*0Sstevel@tonic-gate * ":", or "!:" for "is equal to", "is not equal to", 149*0Sstevel@tonic-gate * "is defined," or "is not defined." <val> is the value 150*0Sstevel@tonic-gate * that the attribute must be equal to or not equal to. 151*0Sstevel@tonic-gate * (<val> must be "*" if <op> is ":" or "!:"). 152*0Sstevel@tonic-gate * dgroup A device group that is to be exclude selected for the 153*0Sstevel@tonic-gate * generated list or excluded from the the generated 154*0Sstevel@tonic-gate * list. 155*0Sstevel@tonic-gate * 156*0Sstevel@tonic-gate * Exit values: 157*0Sstevel@tonic-gate * 0 Success 158*0Sstevel@tonic-gate * 1 Usage or an internal error 159*0Sstevel@tonic-gate * 2 The device table or the device-group table could not be 160*0Sstevel@tonic-gate * opened for reading 161*0Sstevel@tonic-gate */ 162*0Sstevel@tonic-gate 163*0Sstevel@tonic-gate main(argc, argv) 164*0Sstevel@tonic-gate int argc; /* Number of items on the command line */ 165*0Sstevel@tonic-gate char **argv; /* List of pointers to the arguments */ 166*0Sstevel@tonic-gate { 167*0Sstevel@tonic-gate 168*0Sstevel@tonic-gate /* 169*0Sstevel@tonic-gate * Automatic data 170*0Sstevel@tonic-gate */ 171*0Sstevel@tonic-gate 172*0Sstevel@tonic-gate char **arglist; /* List of arguments (subset of argv) */ 173*0Sstevel@tonic-gate char **criterialist; /* List of criteria */ 174*0Sstevel@tonic-gate char **dgrouplist; /* List of device groups to search or ignore */ 175*0Sstevel@tonic-gate char **fitgrouplist; /* List of device groups that fit criteria */ 176*0Sstevel@tonic-gate char *cmdname; /* Simple command name */ 177*0Sstevel@tonic-gate char *dgroup; /* Pointer to device group name in list */ 178*0Sstevel@tonic-gate char *filename; /* Pointer to filename in "error" */ 179*0Sstevel@tonic-gate int exitcode; /* Value to return to the caller */ 180*0Sstevel@tonic-gate int sev; /* Message severity */ 181*0Sstevel@tonic-gate int optchar; /* Option character (returned by getopt()) */ 182*0Sstevel@tonic-gate int andflag; /* TRUE if anding criteria, FALSE if or'ed */ 183*0Sstevel@tonic-gate int excludeflag; /* TRUE if the dgroups list those to exclude */ 184*0Sstevel@tonic-gate int allflag; /* TRUE if all device grps are to be displayed */ 185*0Sstevel@tonic-gate int options; /* Options to pass to getdgrp() */ 186*0Sstevel@tonic-gate int usageerr; /* TRUE if syntax error */ 187*0Sstevel@tonic-gate 188*0Sstevel@tonic-gate 189*0Sstevel@tonic-gate /* Build the message label from the (simple) command name */ 190*0Sstevel@tonic-gate if (cmdname = strrchr(argv[0], '/')) cmdname++; 191*0Sstevel@tonic-gate else cmdname = argv[0]; 192*0Sstevel@tonic-gate (void) strlcat(strcpy(lbl, "UX:"), cmdname, sizeof(lbl)); 193*0Sstevel@tonic-gate 194*0Sstevel@tonic-gate /* Only write the text-component of messages (this goes away in SVR4.1) */ 195*0Sstevel@tonic-gate (void) putenv("MSGVERB=text"); 196*0Sstevel@tonic-gate 197*0Sstevel@tonic-gate /* 198*0Sstevel@tonic-gate * Parse the command line: 199*0Sstevel@tonic-gate * - Options 200*0Sstevel@tonic-gate * - Selection criteria 201*0Sstevel@tonic-gate * - Device groups to include or exclude 202*0Sstevel@tonic-gate */ 203*0Sstevel@tonic-gate 204*0Sstevel@tonic-gate /* 205*0Sstevel@tonic-gate * Extract options from the command line 206*0Sstevel@tonic-gate */ 207*0Sstevel@tonic-gate 208*0Sstevel@tonic-gate /* Initializations */ 209*0Sstevel@tonic-gate andflag = FALSE; /* No -a */ 210*0Sstevel@tonic-gate excludeflag = FALSE; /* No -e */ 211*0Sstevel@tonic-gate allflag = FALSE; /* No -l */ 212*0Sstevel@tonic-gate usageerr = FALSE; /* No errors yet */ 213*0Sstevel@tonic-gate 214*0Sstevel@tonic-gate /* 215*0Sstevel@tonic-gate * Loop until all of the command line options have been parced 216*0Sstevel@tonic-gate */ 217*0Sstevel@tonic-gate opterr = FALSE; /* Don't let getopt() write messages */ 218*0Sstevel@tonic-gate while ((optchar = getopt(argc, argv, "ael")) != EOF) switch (optchar) { 219*0Sstevel@tonic-gate 220*0Sstevel@tonic-gate /* -a List device groups that fit all of the criteria listed */ 221*0Sstevel@tonic-gate case 'a': 222*0Sstevel@tonic-gate if (andflag) usageerr = TRUE; 223*0Sstevel@tonic-gate else andflag = TRUE; 224*0Sstevel@tonic-gate break; 225*0Sstevel@tonic-gate 226*0Sstevel@tonic-gate /* -e Exclude those device groups mentioned on the command line */ 227*0Sstevel@tonic-gate case 'e': 228*0Sstevel@tonic-gate if (excludeflag) usageerr = TRUE; 229*0Sstevel@tonic-gate else excludeflag = TRUE; 230*0Sstevel@tonic-gate break; 231*0Sstevel@tonic-gate 232*0Sstevel@tonic-gate /* -l List all device groups (if no criteria is specified) */ 233*0Sstevel@tonic-gate case 'l': 234*0Sstevel@tonic-gate if (allflag) usageerr = TRUE; 235*0Sstevel@tonic-gate else allflag = TRUE; 236*0Sstevel@tonic-gate break; 237*0Sstevel@tonic-gate 238*0Sstevel@tonic-gate /* Default case -- command usage error */ 239*0Sstevel@tonic-gate case '?': 240*0Sstevel@tonic-gate default: 241*0Sstevel@tonic-gate usageerr = TRUE; 242*0Sstevel@tonic-gate break; 243*0Sstevel@tonic-gate } 244*0Sstevel@tonic-gate 245*0Sstevel@tonic-gate /* If there is a usage error, write an appropriate message and exit */ 246*0Sstevel@tonic-gate if (usageerr) { 247*0Sstevel@tonic-gate stdmsg(MM_NRECOV, lbl, MM_ERROR, M_USAGE); 248*0Sstevel@tonic-gate exit(EX_ERROR); 249*0Sstevel@tonic-gate } 250*0Sstevel@tonic-gate 251*0Sstevel@tonic-gate /* Open the device file (if there's one to be opened) */ 252*0Sstevel@tonic-gate if (!_opendevtab("r")) { 253*0Sstevel@tonic-gate if (filename = _devtabpath()) { 254*0Sstevel@tonic-gate (void) snprintf(txt, sizeof(txt), M_DEVTAB, filename); 255*0Sstevel@tonic-gate exitcode = EX_DTAB; 256*0Sstevel@tonic-gate sev = MM_ERROR; 257*0Sstevel@tonic-gate } else { 258*0Sstevel@tonic-gate (void) sprintf(txt, M_ERROR, errno); 259*0Sstevel@tonic-gate exitcode = EX_ERROR; 260*0Sstevel@tonic-gate sev = MM_HALT; 261*0Sstevel@tonic-gate } 262*0Sstevel@tonic-gate stdmsg(MM_NRECOV, lbl, sev, txt); 263*0Sstevel@tonic-gate exit(exitcode); 264*0Sstevel@tonic-gate } 265*0Sstevel@tonic-gate 266*0Sstevel@tonic-gate /* Open the device file (if there's one to be opened) */ 267*0Sstevel@tonic-gate if (!_opendgrptab("r")) { 268*0Sstevel@tonic-gate if (filename = _dgrptabpath()) { 269*0Sstevel@tonic-gate (void) snprintf(txt, sizeof(txt), M_DGROUP, filename); 270*0Sstevel@tonic-gate exitcode = EX_DGRP; 271*0Sstevel@tonic-gate sev = MM_ERROR; 272*0Sstevel@tonic-gate } else { 273*0Sstevel@tonic-gate (void) sprintf(txt, M_ERROR, errno); 274*0Sstevel@tonic-gate exitcode = EX_ERROR; 275*0Sstevel@tonic-gate sev = MM_HALT; 276*0Sstevel@tonic-gate } 277*0Sstevel@tonic-gate stdmsg(MM_NRECOV, lbl, sev, txt); 278*0Sstevel@tonic-gate exit(exitcode); 279*0Sstevel@tonic-gate } 280*0Sstevel@tonic-gate 281*0Sstevel@tonic-gate /* Build the list of criteria and device groups */ 282*0Sstevel@tonic-gate arglist = argv + optind; 283*0Sstevel@tonic-gate criterialist = buildcriterialist(arglist); 284*0Sstevel@tonic-gate dgrouplist = builddgrouplist(arglist); 285*0Sstevel@tonic-gate options = (excludeflag ? DTAB_EXCLUDEFLAG : 0) | 286*0Sstevel@tonic-gate (andflag ? DTAB_ANDCRITERIA : 0) | 287*0Sstevel@tonic-gate (allflag ? DTAB_LISTALL : 0) ; 288*0Sstevel@tonic-gate 289*0Sstevel@tonic-gate /* 290*0Sstevel@tonic-gate * Get the list of device groups that meets the criteria requested. 291*0Sstevel@tonic-gate * If we got a list (that might be empty), write that list to the 292*0Sstevel@tonic-gate * standard output file (stdout). 293*0Sstevel@tonic-gate */ 294*0Sstevel@tonic-gate 295*0Sstevel@tonic-gate exitcode = EX_OK; 296*0Sstevel@tonic-gate if (!(fitgrouplist = getdgrp(dgrouplist, criterialist, options))) { 297*0Sstevel@tonic-gate exitcode = EX_ERROR; 298*0Sstevel@tonic-gate } 299*0Sstevel@tonic-gate else for (dgroup = *fitgrouplist++ ; dgroup ; dgroup = *fitgrouplist++) 300*0Sstevel@tonic-gate (void) puts(dgroup); 301*0Sstevel@tonic-gate 302*0Sstevel@tonic-gate /* Finished */ 303*0Sstevel@tonic-gate return(exitcode); 304*0Sstevel@tonic-gate } 305*0Sstevel@tonic-gate 306*0Sstevel@tonic-gate /* 307*0Sstevel@tonic-gate * char **buildcriterialist(arglist) 308*0Sstevel@tonic-gate * char **arglist 309*0Sstevel@tonic-gate * 310*0Sstevel@tonic-gate * This function builds a list of criteria descriptions from the 311*0Sstevel@tonic-gate * list of arguments given. The list returned is in malloc()ed 312*0Sstevel@tonic-gate * space. 313*0Sstevel@tonic-gate * 314*0Sstevel@tonic-gate * Arguments: 315*0Sstevel@tonic-gate * arglist The address of the first element in the list 316*0Sstevel@tonic-gate * of arguments (possibly) containing criterion 317*0Sstevel@tonic-gate * 318*0Sstevel@tonic-gate * Returns: char ** 319*0Sstevel@tonic-gate * A pointer to the first element in the list of criterion. 320*0Sstevel@tonic-gate * If there was a problem, the function returns (char **) NULL. 321*0Sstevel@tonic-gate * If there are no criteria in the list, the function returns 322*0Sstevel@tonic-gate * an empty list. 323*0Sstevel@tonic-gate */ 324*0Sstevel@tonic-gate 325*0Sstevel@tonic-gate static char ** 326*0Sstevel@tonic-gate buildcriterialist(arglist) 327*0Sstevel@tonic-gate char **arglist; /* Pointer to the list of argument pointers */ 328*0Sstevel@tonic-gate { 329*0Sstevel@tonic-gate /* 330*0Sstevel@tonic-gate * Automatic data 331*0Sstevel@tonic-gate */ 332*0Sstevel@tonic-gate 333*0Sstevel@tonic-gate char **pp; /* Pointer to a criteria */ 334*0Sstevel@tonic-gate void *allocbuf; /* Pointer to the allocated data */ 335*0Sstevel@tonic-gate int ncriteria; /* Number of criteria found */ 336*0Sstevel@tonic-gate 337*0Sstevel@tonic-gate 338*0Sstevel@tonic-gate /* 339*0Sstevel@tonic-gate * Search the argument list, looking for the end of the list or 340*0Sstevel@tonic-gate * the first thing that's not a criteria. (A criteria is a 341*0Sstevel@tonic-gate * character-string that contains a colon (':') or an equal-sign ('=') 342*0Sstevel@tonic-gate */ 343*0Sstevel@tonic-gate 344*0Sstevel@tonic-gate pp = arglist; 345*0Sstevel@tonic-gate ncriteria = 1; 346*0Sstevel@tonic-gate while (*pp && (strchr(*pp, '=') || strchr(*pp, ':'))) { 347*0Sstevel@tonic-gate ncriteria++; 348*0Sstevel@tonic-gate pp++; 349*0Sstevel@tonic-gate } 350*0Sstevel@tonic-gate 351*0Sstevel@tonic-gate /* Allocate space for the list of criteria pointers */ 352*0Sstevel@tonic-gate if (allocbuf = malloc(ncriteria*sizeof(char **))) { 353*0Sstevel@tonic-gate 354*0Sstevel@tonic-gate /* Build the list of criteria arguments */ 355*0Sstevel@tonic-gate pp = (char **) allocbuf; 356*0Sstevel@tonic-gate while ((*arglist != (char *) NULL) && isacriterion(*arglist)) *pp++ = *arglist++; 357*0Sstevel@tonic-gate *pp = (char *) NULL; 358*0Sstevel@tonic-gate } 359*0Sstevel@tonic-gate 360*0Sstevel@tonic-gate return ((char **) allocbuf); 361*0Sstevel@tonic-gate } 362*0Sstevel@tonic-gate 363*0Sstevel@tonic-gate /* 364*0Sstevel@tonic-gate * char **builddgrouplist(arglist) 365*0Sstevel@tonic-gate * char **arglist 366*0Sstevel@tonic-gate * 367*0Sstevel@tonic-gate * This function returns a pointer to the first element in a list of 368*0Sstevel@tonic-gate * device-groups (i.e. not criteria) specified in the list of arguments 369*0Sstevel@tonic-gate * whose first element is pointed to by <arglist>. 370*0Sstevel@tonic-gate * 371*0Sstevel@tonic-gate * Arguments: 372*0Sstevel@tonic-gate * arglist The address of the first element in the list of 373*0Sstevel@tonic-gate * arguments to be searched for non-criteria 374*0Sstevel@tonic-gate * 375*0Sstevel@tonic-gate * Returns: char ** 376*0Sstevel@tonic-gate * The address of the first item in the list of arguments that are 377*0Sstevel@tonic-gate * not criteria. If none, the function returns a pointer to a 378*0Sstevel@tonic-gate * null list. 379*0Sstevel@tonic-gate * 380*0Sstevel@tonic-gate * Note: 381*0Sstevel@tonic-gate * - The current implementation returns a pointer to an element in 382*0Sstevel@tonic-gate * <arglist>. 383*0Sstevel@tonic-gate */ 384*0Sstevel@tonic-gate 385*0Sstevel@tonic-gate static char ** 386*0Sstevel@tonic-gate builddgrouplist(arglist) 387*0Sstevel@tonic-gate char **arglist; /* First item in the list of arguments */ 388*0Sstevel@tonic-gate { 389*0Sstevel@tonic-gate /* 390*0Sstevel@tonic-gate * Automatic data 391*0Sstevel@tonic-gate */ 392*0Sstevel@tonic-gate 393*0Sstevel@tonic-gate /* 394*0Sstevel@tonic-gate * Search the argument list, looking for the end of the list or 395*0Sstevel@tonic-gate * the first thing that's not a criteria. It is the first device 396*0Sstevel@tonic-gate * group in the list of device groups (if any). 397*0Sstevel@tonic-gate */ 398*0Sstevel@tonic-gate 399*0Sstevel@tonic-gate while (*arglist && isacriterion(*arglist)) arglist++; 400*0Sstevel@tonic-gate 401*0Sstevel@tonic-gate /* Return a pointer to the argument list. */ 402*0Sstevel@tonic-gate return(arglist); 403*0Sstevel@tonic-gate } 404