1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> 30*7c478bd9Sstevel@tonic-gate #include <ctf_impl.h> 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate /* 33*7c478bd9Sstevel@tonic-gate * Compare the given input string and length against a table of known C storage 34*7c478bd9Sstevel@tonic-gate * qualifier keywords. We just ignore these in ctf_lookup_by_name, below. 35*7c478bd9Sstevel@tonic-gate */ 36*7c478bd9Sstevel@tonic-gate static int 37*7c478bd9Sstevel@tonic-gate isqualifier(const char *s, size_t len) 38*7c478bd9Sstevel@tonic-gate { 39*7c478bd9Sstevel@tonic-gate static const struct qual { 40*7c478bd9Sstevel@tonic-gate const char *q_name; 41*7c478bd9Sstevel@tonic-gate size_t q_len; 42*7c478bd9Sstevel@tonic-gate } q[] = { 43*7c478bd9Sstevel@tonic-gate { "auto", 4 }, 44*7c478bd9Sstevel@tonic-gate { "const", 5 }, 45*7c478bd9Sstevel@tonic-gate { "extern", 6 }, 46*7c478bd9Sstevel@tonic-gate { "register", 8 }, 47*7c478bd9Sstevel@tonic-gate { "restrict", 8 }, 48*7c478bd9Sstevel@tonic-gate { "_Restrict", 9 }, 49*7c478bd9Sstevel@tonic-gate { "static", 6 }, 50*7c478bd9Sstevel@tonic-gate { "volatile", 8 }, 51*7c478bd9Sstevel@tonic-gate { NULL, 0 } 52*7c478bd9Sstevel@tonic-gate }; 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate int i; 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gate for (i = 0; q[i].q_name != NULL; i++) { 57*7c478bd9Sstevel@tonic-gate if (len == q[i].q_len && strncmp(s, q[i].q_name, len) == 0) 58*7c478bd9Sstevel@tonic-gate return (1); 59*7c478bd9Sstevel@tonic-gate } 60*7c478bd9Sstevel@tonic-gate 61*7c478bd9Sstevel@tonic-gate return (0); 62*7c478bd9Sstevel@tonic-gate } 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate /* 65*7c478bd9Sstevel@tonic-gate * Attempt to convert the given C type name into the corresponding CTF type ID. 66*7c478bd9Sstevel@tonic-gate * It is not possible to do complete and proper conversion of type names 67*7c478bd9Sstevel@tonic-gate * without implementing a more full-fledged parser, which is necessary to 68*7c478bd9Sstevel@tonic-gate * handle things like types that are function pointers to functions that 69*7c478bd9Sstevel@tonic-gate * have arguments that are function pointers, and fun stuff like that. 70*7c478bd9Sstevel@tonic-gate * Instead, this function implements a very simple conversion algorithm that 71*7c478bd9Sstevel@tonic-gate * finds the things that we actually care about: structs, unions, enums, 72*7c478bd9Sstevel@tonic-gate * integers, floats, typedefs, and pointers to any of these named types. 73*7c478bd9Sstevel@tonic-gate */ 74*7c478bd9Sstevel@tonic-gate ctf_id_t 75*7c478bd9Sstevel@tonic-gate ctf_lookup_by_name(ctf_file_t *fp, const char *name) 76*7c478bd9Sstevel@tonic-gate { 77*7c478bd9Sstevel@tonic-gate static const char delimiters[] = " \t\n\r\v\f*"; 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate const ctf_lookup_t *lp; 80*7c478bd9Sstevel@tonic-gate const ctf_helem_t *hp; 81*7c478bd9Sstevel@tonic-gate const char *p, *q, *end; 82*7c478bd9Sstevel@tonic-gate ctf_id_t type = 0; 83*7c478bd9Sstevel@tonic-gate ctf_id_t ntype, ptype; 84*7c478bd9Sstevel@tonic-gate 85*7c478bd9Sstevel@tonic-gate if (name == NULL) 86*7c478bd9Sstevel@tonic-gate return (ctf_set_errno(fp, EINVAL)); 87*7c478bd9Sstevel@tonic-gate 88*7c478bd9Sstevel@tonic-gate for (p = name, end = name + strlen(name); *p != '\0'; p = q) { 89*7c478bd9Sstevel@tonic-gate while (isspace(*p)) 90*7c478bd9Sstevel@tonic-gate p++; /* skip leading ws */ 91*7c478bd9Sstevel@tonic-gate 92*7c478bd9Sstevel@tonic-gate if (p == end) 93*7c478bd9Sstevel@tonic-gate break; 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate if ((q = strpbrk(p + 1, delimiters)) == NULL) 96*7c478bd9Sstevel@tonic-gate q = end; /* compare until end */ 97*7c478bd9Sstevel@tonic-gate 98*7c478bd9Sstevel@tonic-gate if (*p == '*') { 99*7c478bd9Sstevel@tonic-gate /* 100*7c478bd9Sstevel@tonic-gate * Find a pointer to type by looking in fp->ctf_ptrtab. 101*7c478bd9Sstevel@tonic-gate * If we can't find a pointer to the given type, see if 102*7c478bd9Sstevel@tonic-gate * we can compute a pointer to the type resulting from 103*7c478bd9Sstevel@tonic-gate * resolving the type down to its base type and use 104*7c478bd9Sstevel@tonic-gate * that instead. This helps with cases where the CTF 105*7c478bd9Sstevel@tonic-gate * data includes "struct foo *" but not "foo_t *" and 106*7c478bd9Sstevel@tonic-gate * the user tries to access "foo_t *" in the debugger. 107*7c478bd9Sstevel@tonic-gate */ 108*7c478bd9Sstevel@tonic-gate ntype = fp->ctf_ptrtab[CTF_TYPE_TO_INDEX(type)]; 109*7c478bd9Sstevel@tonic-gate if (ntype == 0) { 110*7c478bd9Sstevel@tonic-gate ntype = ctf_type_resolve(fp, type); 111*7c478bd9Sstevel@tonic-gate if (ntype == CTF_ERR || (ntype = fp->ctf_ptrtab[ 112*7c478bd9Sstevel@tonic-gate CTF_TYPE_TO_INDEX(ntype)]) == 0) { 113*7c478bd9Sstevel@tonic-gate (void) ctf_set_errno(fp, ECTF_NOTYPE); 114*7c478bd9Sstevel@tonic-gate goto err; 115*7c478bd9Sstevel@tonic-gate } 116*7c478bd9Sstevel@tonic-gate } 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate type = CTF_INDEX_TO_TYPE(ntype, 119*7c478bd9Sstevel@tonic-gate (fp->ctf_flags & LCTF_CHILD)); 120*7c478bd9Sstevel@tonic-gate 121*7c478bd9Sstevel@tonic-gate q = p + 1; 122*7c478bd9Sstevel@tonic-gate continue; 123*7c478bd9Sstevel@tonic-gate } 124*7c478bd9Sstevel@tonic-gate 125*7c478bd9Sstevel@tonic-gate if (isqualifier(p, (size_t)(q - p))) 126*7c478bd9Sstevel@tonic-gate continue; /* skip qualifier keyword */ 127*7c478bd9Sstevel@tonic-gate 128*7c478bd9Sstevel@tonic-gate for (lp = fp->ctf_lookups; lp->ctl_prefix != NULL; lp++) { 129*7c478bd9Sstevel@tonic-gate if (lp->ctl_prefix[0] == '\0' || 130*7c478bd9Sstevel@tonic-gate strncmp(p, lp->ctl_prefix, (size_t)(q - p)) == 0) { 131*7c478bd9Sstevel@tonic-gate for (p += lp->ctl_len; isspace(*p); p++) 132*7c478bd9Sstevel@tonic-gate continue; /* skip prefix and next ws */ 133*7c478bd9Sstevel@tonic-gate 134*7c478bd9Sstevel@tonic-gate if ((q = strchr(p, '*')) == NULL) 135*7c478bd9Sstevel@tonic-gate q = end; /* compare until end */ 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate while (isspace(q[-1])) 138*7c478bd9Sstevel@tonic-gate q--; /* exclude trailing ws */ 139*7c478bd9Sstevel@tonic-gate 140*7c478bd9Sstevel@tonic-gate if ((hp = ctf_hash_lookup(lp->ctl_hash, fp, p, 141*7c478bd9Sstevel@tonic-gate (size_t)(q - p))) == NULL) { 142*7c478bd9Sstevel@tonic-gate (void) ctf_set_errno(fp, ECTF_NOTYPE); 143*7c478bd9Sstevel@tonic-gate goto err; 144*7c478bd9Sstevel@tonic-gate } 145*7c478bd9Sstevel@tonic-gate 146*7c478bd9Sstevel@tonic-gate type = hp->h_type; 147*7c478bd9Sstevel@tonic-gate break; 148*7c478bd9Sstevel@tonic-gate } 149*7c478bd9Sstevel@tonic-gate } 150*7c478bd9Sstevel@tonic-gate 151*7c478bd9Sstevel@tonic-gate if (lp->ctl_prefix == NULL) { 152*7c478bd9Sstevel@tonic-gate (void) ctf_set_errno(fp, ECTF_NOTYPE); 153*7c478bd9Sstevel@tonic-gate goto err; 154*7c478bd9Sstevel@tonic-gate } 155*7c478bd9Sstevel@tonic-gate } 156*7c478bd9Sstevel@tonic-gate 157*7c478bd9Sstevel@tonic-gate if (*p != '\0' || type == 0) 158*7c478bd9Sstevel@tonic-gate return (ctf_set_errno(fp, ECTF_SYNTAX)); 159*7c478bd9Sstevel@tonic-gate 160*7c478bd9Sstevel@tonic-gate return (type); 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate err: 163*7c478bd9Sstevel@tonic-gate if (fp->ctf_parent != NULL && 164*7c478bd9Sstevel@tonic-gate (ptype = ctf_lookup_by_name(fp->ctf_parent, name)) != CTF_ERR) 165*7c478bd9Sstevel@tonic-gate return (ptype); 166*7c478bd9Sstevel@tonic-gate 167*7c478bd9Sstevel@tonic-gate return (CTF_ERR); 168*7c478bd9Sstevel@tonic-gate } 169*7c478bd9Sstevel@tonic-gate 170*7c478bd9Sstevel@tonic-gate /* 171*7c478bd9Sstevel@tonic-gate * Given a symbol table index, return the type of the data object described 172*7c478bd9Sstevel@tonic-gate * by the corresponding entry in the symbol table. 173*7c478bd9Sstevel@tonic-gate */ 174*7c478bd9Sstevel@tonic-gate ctf_id_t 175*7c478bd9Sstevel@tonic-gate ctf_lookup_by_symbol(ctf_file_t *fp, ulong_t symidx) 176*7c478bd9Sstevel@tonic-gate { 177*7c478bd9Sstevel@tonic-gate const ctf_sect_t *sp = &fp->ctf_symtab; 178*7c478bd9Sstevel@tonic-gate ctf_id_t type; 179*7c478bd9Sstevel@tonic-gate 180*7c478bd9Sstevel@tonic-gate if (sp->cts_data == NULL) 181*7c478bd9Sstevel@tonic-gate return (ctf_set_errno(fp, ECTF_NOSYMTAB)); 182*7c478bd9Sstevel@tonic-gate 183*7c478bd9Sstevel@tonic-gate if (symidx >= fp->ctf_nsyms) 184*7c478bd9Sstevel@tonic-gate return (ctf_set_errno(fp, EINVAL)); 185*7c478bd9Sstevel@tonic-gate 186*7c478bd9Sstevel@tonic-gate if (sp->cts_entsize == sizeof (Elf32_Sym)) { 187*7c478bd9Sstevel@tonic-gate const Elf32_Sym *symp = (Elf32_Sym *)sp->cts_data + symidx; 188*7c478bd9Sstevel@tonic-gate if (ELF32_ST_TYPE(symp->st_info) != STT_OBJECT) 189*7c478bd9Sstevel@tonic-gate return (ctf_set_errno(fp, ECTF_NOTDATA)); 190*7c478bd9Sstevel@tonic-gate } else { 191*7c478bd9Sstevel@tonic-gate const Elf64_Sym *symp = (Elf64_Sym *)sp->cts_data + symidx; 192*7c478bd9Sstevel@tonic-gate if (ELF64_ST_TYPE(symp->st_info) != STT_OBJECT) 193*7c478bd9Sstevel@tonic-gate return (ctf_set_errno(fp, ECTF_NOTDATA)); 194*7c478bd9Sstevel@tonic-gate } 195*7c478bd9Sstevel@tonic-gate 196*7c478bd9Sstevel@tonic-gate if (fp->ctf_sxlate[symidx] == -1u) 197*7c478bd9Sstevel@tonic-gate return (ctf_set_errno(fp, ECTF_NOTYPEDAT)); 198*7c478bd9Sstevel@tonic-gate 199*7c478bd9Sstevel@tonic-gate type = *(ushort_t *)((uintptr_t)fp->ctf_buf + fp->ctf_sxlate[symidx]); 200*7c478bd9Sstevel@tonic-gate if (type == 0) 201*7c478bd9Sstevel@tonic-gate return (ctf_set_errno(fp, ECTF_NOTYPEDAT)); 202*7c478bd9Sstevel@tonic-gate 203*7c478bd9Sstevel@tonic-gate return (type); 204*7c478bd9Sstevel@tonic-gate } 205*7c478bd9Sstevel@tonic-gate 206*7c478bd9Sstevel@tonic-gate /* 207*7c478bd9Sstevel@tonic-gate * Return the pointer to the internal CTF type data corresponding to the 208*7c478bd9Sstevel@tonic-gate * given type ID. If the ID is invalid, the function returns NULL. 209*7c478bd9Sstevel@tonic-gate * This function is not exported outside of the library. 210*7c478bd9Sstevel@tonic-gate */ 211*7c478bd9Sstevel@tonic-gate const ctf_type_t * 212*7c478bd9Sstevel@tonic-gate ctf_lookup_by_id(ctf_file_t **fpp, ctf_id_t type) 213*7c478bd9Sstevel@tonic-gate { 214*7c478bd9Sstevel@tonic-gate ctf_file_t *fp = *fpp; /* caller passes in starting CTF container */ 215*7c478bd9Sstevel@tonic-gate 216*7c478bd9Sstevel@tonic-gate if ((fp->ctf_flags & LCTF_CHILD) && CTF_TYPE_ISPARENT(type) && 217*7c478bd9Sstevel@tonic-gate (fp = fp->ctf_parent) == NULL) { 218*7c478bd9Sstevel@tonic-gate (void) ctf_set_errno(*fpp, ECTF_NOPARENT); 219*7c478bd9Sstevel@tonic-gate return (NULL); 220*7c478bd9Sstevel@tonic-gate } 221*7c478bd9Sstevel@tonic-gate 222*7c478bd9Sstevel@tonic-gate type = CTF_TYPE_TO_INDEX(type); 223*7c478bd9Sstevel@tonic-gate if (type > 0 && type <= fp->ctf_typemax) { 224*7c478bd9Sstevel@tonic-gate *fpp = fp; /* function returns ending CTF container */ 225*7c478bd9Sstevel@tonic-gate return (LCTF_INDEX_TO_TYPEPTR(fp, type)); 226*7c478bd9Sstevel@tonic-gate } 227*7c478bd9Sstevel@tonic-gate 228*7c478bd9Sstevel@tonic-gate (void) ctf_set_errno(fp, ECTF_BADID); 229*7c478bd9Sstevel@tonic-gate return (NULL); 230*7c478bd9Sstevel@tonic-gate } 231*7c478bd9Sstevel@tonic-gate 232*7c478bd9Sstevel@tonic-gate /* 233*7c478bd9Sstevel@tonic-gate * Given a symbol table index, return the info for the function described 234*7c478bd9Sstevel@tonic-gate * by the corresponding entry in the symbol table. 235*7c478bd9Sstevel@tonic-gate */ 236*7c478bd9Sstevel@tonic-gate int 237*7c478bd9Sstevel@tonic-gate ctf_func_info(ctf_file_t *fp, ulong_t symidx, ctf_funcinfo_t *fip) 238*7c478bd9Sstevel@tonic-gate { 239*7c478bd9Sstevel@tonic-gate const ctf_sect_t *sp = &fp->ctf_symtab; 240*7c478bd9Sstevel@tonic-gate const ushort_t *dp; 241*7c478bd9Sstevel@tonic-gate ushort_t info, kind, n; 242*7c478bd9Sstevel@tonic-gate 243*7c478bd9Sstevel@tonic-gate if (sp->cts_data == NULL) 244*7c478bd9Sstevel@tonic-gate return (ctf_set_errno(fp, ECTF_NOSYMTAB)); 245*7c478bd9Sstevel@tonic-gate 246*7c478bd9Sstevel@tonic-gate if (symidx >= fp->ctf_nsyms) 247*7c478bd9Sstevel@tonic-gate return (ctf_set_errno(fp, EINVAL)); 248*7c478bd9Sstevel@tonic-gate 249*7c478bd9Sstevel@tonic-gate if (sp->cts_entsize == sizeof (Elf32_Sym)) { 250*7c478bd9Sstevel@tonic-gate const Elf32_Sym *symp = (Elf32_Sym *)sp->cts_data + symidx; 251*7c478bd9Sstevel@tonic-gate if (ELF32_ST_TYPE(symp->st_info) != STT_FUNC) 252*7c478bd9Sstevel@tonic-gate return (ctf_set_errno(fp, ECTF_NOTFUNC)); 253*7c478bd9Sstevel@tonic-gate } else { 254*7c478bd9Sstevel@tonic-gate const Elf64_Sym *symp = (Elf64_Sym *)sp->cts_data + symidx; 255*7c478bd9Sstevel@tonic-gate if (ELF64_ST_TYPE(symp->st_info) != STT_FUNC) 256*7c478bd9Sstevel@tonic-gate return (ctf_set_errno(fp, ECTF_NOTFUNC)); 257*7c478bd9Sstevel@tonic-gate } 258*7c478bd9Sstevel@tonic-gate 259*7c478bd9Sstevel@tonic-gate if (fp->ctf_sxlate[symidx] == -1u) 260*7c478bd9Sstevel@tonic-gate return (ctf_set_errno(fp, ECTF_NOFUNCDAT)); 261*7c478bd9Sstevel@tonic-gate 262*7c478bd9Sstevel@tonic-gate dp = (ushort_t *)((uintptr_t)fp->ctf_buf + fp->ctf_sxlate[symidx]); 263*7c478bd9Sstevel@tonic-gate 264*7c478bd9Sstevel@tonic-gate info = *dp++; 265*7c478bd9Sstevel@tonic-gate kind = LCTF_INFO_KIND(fp, info); 266*7c478bd9Sstevel@tonic-gate n = LCTF_INFO_VLEN(fp, info); 267*7c478bd9Sstevel@tonic-gate 268*7c478bd9Sstevel@tonic-gate if (kind == CTF_K_UNKNOWN && n == 0) 269*7c478bd9Sstevel@tonic-gate return (ctf_set_errno(fp, ECTF_NOFUNCDAT)); 270*7c478bd9Sstevel@tonic-gate 271*7c478bd9Sstevel@tonic-gate if (kind != CTF_K_FUNCTION) 272*7c478bd9Sstevel@tonic-gate return (ctf_set_errno(fp, ECTF_CORRUPT)); 273*7c478bd9Sstevel@tonic-gate 274*7c478bd9Sstevel@tonic-gate fip->ctc_return = *dp++; 275*7c478bd9Sstevel@tonic-gate fip->ctc_argc = n; 276*7c478bd9Sstevel@tonic-gate fip->ctc_flags = 0; 277*7c478bd9Sstevel@tonic-gate 278*7c478bd9Sstevel@tonic-gate if (n != 0 && dp[n - 1] == 0) { 279*7c478bd9Sstevel@tonic-gate fip->ctc_flags |= CTF_FUNC_VARARG; 280*7c478bd9Sstevel@tonic-gate fip->ctc_argc--; 281*7c478bd9Sstevel@tonic-gate } 282*7c478bd9Sstevel@tonic-gate 283*7c478bd9Sstevel@tonic-gate return (0); 284*7c478bd9Sstevel@tonic-gate } 285*7c478bd9Sstevel@tonic-gate 286*7c478bd9Sstevel@tonic-gate /* 287*7c478bd9Sstevel@tonic-gate * Given a symbol table index, return the arguments for the function described 288*7c478bd9Sstevel@tonic-gate * by the corresponding entry in the symbol table. 289*7c478bd9Sstevel@tonic-gate */ 290*7c478bd9Sstevel@tonic-gate int 291*7c478bd9Sstevel@tonic-gate ctf_func_args(ctf_file_t *fp, ulong_t symidx, uint_t argc, ctf_id_t *argv) 292*7c478bd9Sstevel@tonic-gate { 293*7c478bd9Sstevel@tonic-gate const ushort_t *dp; 294*7c478bd9Sstevel@tonic-gate ctf_funcinfo_t f; 295*7c478bd9Sstevel@tonic-gate 296*7c478bd9Sstevel@tonic-gate if (ctf_func_info(fp, symidx, &f) == CTF_ERR) 297*7c478bd9Sstevel@tonic-gate return (CTF_ERR); /* errno is set for us */ 298*7c478bd9Sstevel@tonic-gate 299*7c478bd9Sstevel@tonic-gate /* 300*7c478bd9Sstevel@tonic-gate * The argument data is two ushort_t's past the translation table 301*7c478bd9Sstevel@tonic-gate * offset: one for the function info, and one for the return type. 302*7c478bd9Sstevel@tonic-gate */ 303*7c478bd9Sstevel@tonic-gate dp = (ushort_t *)((uintptr_t)fp->ctf_buf + fp->ctf_sxlate[symidx]) + 2; 304*7c478bd9Sstevel@tonic-gate 305*7c478bd9Sstevel@tonic-gate for (argc = MIN(argc, f.ctc_argc); argc != 0; argc--) 306*7c478bd9Sstevel@tonic-gate *argv++ = *dp++; 307*7c478bd9Sstevel@tonic-gate 308*7c478bd9Sstevel@tonic-gate return (0); 309*7c478bd9Sstevel@tonic-gate } 310