2 * SPDX-License-Identifier: BSD-3-Clause
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 static const char copyright[] =
34 "@(#) Copyright (c) 1993\n\
35 The Regents of the University of California. All rights reserved.\n";
40 static char sccsid[] = "@(#)from: sysctl.c 8.1 (Berkeley) 6/6/93";
42 static const char rcsid[] =
46 #include <sys/param.h>
48 #include <sys/resource.h>
50 #include <sys/sysctl.h>
51 #include <sys/vmmeter.h>
55 #include <machine/metadata.h>
58 #if defined(__amd64__) || defined(__i386__)
59 #include <machine/pc/bios.h>
75 static const char *conffile;
77 static int aflag, bflag, Bflag, dflag, eflag, hflag, iflag;
78 static int Nflag, nflag, oflag, qflag, tflag, Tflag, Wflag, xflag;
80 static int oidfmt(int *, int, char *, u_int *);
81 static int parsefile(const char *);
82 static int parse(const char *, int);
83 static int show_var(int *, int);
84 static int sysctl_all(int *oid, int len);
85 static int name2oid(const char *, int *);
87 static int strIKtoi(const char *, char **, const char *);
89 static int ctl_sign[CTLTYPE+1] = {
98 static int ctl_size[CTLTYPE+1] = {
99 [CTLTYPE_INT] = sizeof(int),
100 [CTLTYPE_UINT] = sizeof(u_int),
101 [CTLTYPE_LONG] = sizeof(long),
102 [CTLTYPE_ULONG] = sizeof(u_long),
103 [CTLTYPE_S8] = sizeof(int8_t),
104 [CTLTYPE_S16] = sizeof(int16_t),
105 [CTLTYPE_S32] = sizeof(int32_t),
106 [CTLTYPE_S64] = sizeof(int64_t),
107 [CTLTYPE_U8] = sizeof(uint8_t),
108 [CTLTYPE_U16] = sizeof(uint16_t),
109 [CTLTYPE_U32] = sizeof(uint32_t),
110 [CTLTYPE_U64] = sizeof(uint64_t),
113 static const char *ctl_typename[CTLTYPE+1] = {
114 [CTLTYPE_INT] = "integer",
115 [CTLTYPE_UINT] = "unsigned integer",
116 [CTLTYPE_LONG] = "long integer",
117 [CTLTYPE_ULONG] = "unsigned long",
118 [CTLTYPE_U8] = "uint8_t",
119 [CTLTYPE_U16] = "uint16_t",
120 [CTLTYPE_U32] = "uint32_t",
121 [CTLTYPE_U64] = "uint64_t",
122 [CTLTYPE_S8] = "int8_t",
123 [CTLTYPE_S16] = "int16_t",
124 [CTLTYPE_S32] = "int32_t",
125 [CTLTYPE_S64] = "int64_t",
126 [CTLTYPE_NODE] = "node",
127 [CTLTYPE_STRING] = "string",
128 [CTLTYPE_OPAQUE] = "opaque",
135 (void)fprintf(stderr, "%s\n%s\n",
136 "usage: sysctl [-bdehiNnoqTtWx] [ -B <bufsize> ] [-f filename] name[=value] ...",
137 " sysctl [-bdehNnoqTtWx] [ -B <bufsize> ] -a");
142 main(int argc, char **argv)
147 setlocale(LC_NUMERIC, "");
151 while ((ch = getopt(argc, argv, "AabB:def:hiNnoqtTwWxX")) != -1) {
164 Bflag = strtol(optarg, NULL, 0);
222 if (aflag && argc == 0)
223 exit(sysctl_all(0, 0));
224 if (argc == 0 && conffile == NULL)
228 if (conffile != NULL)
229 warncount += parsefile(conffile);
232 warncount += parse(*argv++, 0);
238 * Parse a single numeric value, append it to 'newbuf', and update
239 * 'newsize'. Returns true if the value was parsed and false if the
240 * value was invalid. Non-numeric types (strings) are handled
241 * directly in parse().
244 parse_numeric(const char *newvalstr, const char *fmt, u_int kind,
245 void **newbufp, size_t *newsizep)
256 unsigned int uintval;
258 unsigned long ulongval;
266 switch (kind & CTLTYPE) {
268 if (strncmp(fmt, "IK", 2) == 0)
269 intval = strIKtoi(newvalstr, &endptr, fmt);
271 intval = (int)strtol(newvalstr, &endptr, 0);
273 valsize = sizeof(intval);
276 uintval = (int) strtoul(newvalstr, &endptr, 0);
278 valsize = sizeof(uintval);
281 longval = strtol(newvalstr, &endptr, 0);
283 valsize = sizeof(longval);
286 ulongval = strtoul(newvalstr, &endptr, 0);
288 valsize = sizeof(ulongval);
291 i8val = (int8_t)strtol(newvalstr, &endptr, 0);
293 valsize = sizeof(i8val);
296 i16val = (int16_t)strtol(newvalstr, &endptr, 0);
298 valsize = sizeof(i16val);
301 i32val = (int32_t)strtol(newvalstr, &endptr, 0);
303 valsize = sizeof(i32val);
306 i64val = strtoimax(newvalstr, &endptr, 0);
308 valsize = sizeof(i64val);
311 u8val = (uint8_t)strtoul(newvalstr, &endptr, 0);
313 valsize = sizeof(u8val);
316 u16val = (uint16_t)strtoul(newvalstr, &endptr, 0);
318 valsize = sizeof(u16val);
321 u32val = (uint32_t)strtoul(newvalstr, &endptr, 0);
323 valsize = sizeof(u32val);
326 u64val = strtoumax(newvalstr, &endptr, 0);
328 valsize = sizeof(u64val);
335 if (errno != 0 || endptr == newvalstr ||
336 (endptr != NULL && *endptr != '\0'))
339 newbuf = realloc(*newbufp, *newsizep + valsize);
341 err(1, "out of memory");
342 memcpy((char *)newbuf + *newsizep, newval, valsize);
344 *newsizep += valsize;
350 * Parse a name into a MIB entry.
351 * Lookup and print out the MIB entry if it exists.
352 * Set a new value if requested.
355 parse(const char *string, int lineno)
359 char *newvalstr = NULL;
361 size_t newsize = Bflag;
362 int mib[CTL_MAXNAME];
363 char *cp, *bufp, buf[BUFSIZ], fmt[BUFSIZ], line[BUFSIZ];
367 snprintf(line, sizeof(line), " at line %d", lineno);
372 if (snprintf(buf, BUFSIZ, "%s", string) >= BUFSIZ) {
373 warnx("oid too long: '%s'%s", string, line);
376 bufp = strsep(&cp, "=:");
378 /* Tflag just lists tunables, do not allow assignment */
379 if (Tflag || Wflag) {
380 warnx("Can't set variables when using -T or -W");
385 /* Strip a pair of " or ' if any. */
389 if (cp[strlen(cp) - 1] == *cp)
390 cp[strlen(cp) - 1] = '\0';
394 newsize = strlen(cp);
397 cp = bufp + strlen(bufp) - 1;
398 while (cp >= bufp && isspace((int)*cp)) {
402 len = name2oid(bufp, mib);
410 if (errno == ENOENT) {
411 warnx("unknown oid '%s'%s", bufp, line);
413 warn("unknown oid '%s'%s", bufp, line);
419 if (oidfmt(mib, len, fmt, &kind)) {
420 warn("couldn't find format of oid '%s'%s", bufp, line);
427 if (newvalstr == NULL || dflag) {
428 if ((kind & CTLTYPE) == CTLTYPE_NODE) {
430 i = show_var(mib, len);
434 sysctl_all(mib, len);
436 i = show_var(mib, len);
441 if ((kind & CTLTYPE) == CTLTYPE_NODE) {
442 warnx("oid '%s' isn't a leaf node%s", bufp, line);
446 if (!(kind & CTLFLAG_WR)) {
447 if (kind & CTLFLAG_TUN) {
448 warnx("oid '%s' is a read only tunable%s", bufp, line);
449 warnx("Tunable values are set in /boot/loader.conf");
451 warnx("oid '%s' is read only%s", bufp, line);
455 switch (kind & CTLTYPE) {
468 if (strlen(newvalstr) == 0) {
469 warnx("empty numeric value");
476 warnx("oid '%s' is type %d,"
477 " cannot set that%s", bufp,
478 kind & CTLTYPE, line);
484 switch (kind & CTLTYPE) {
490 while ((cp = strsep(&newvalstr, " ,")) != NULL) {
493 if (!parse_numeric(cp, fmt, kind, &newbuf,
495 warnx("invalid %s '%s'%s",
496 ctl_typename[kind & CTLTYPE],
506 i = show_var(mib, len);
507 if (sysctl(mib, len, 0, 0, newval, newsize) == -1) {
513 warnx("%s: value is not available%s",
517 warnx("%s: specification is incomplete%s",
521 warnx("%s: type is unknown to this program%s",
525 warn("%s%s", string, line);
534 j = show_var(mib, len);
544 parsefile(const char *filename)
547 char line[BUFSIZ], *p, *pq, *pdq;
548 int warncount = 0, lineno = 0;
550 file = fopen(filename, "r");
552 err(EX_NOINPUT, "%s", filename);
553 while (fgets(line, sizeof(line), file) != NULL) {
556 pq = strchr(line, '\'');
557 pdq = strchr(line, '\"');
558 /* Replace the first # with \0. */
559 while((p = strchr(p, '#')) != NULL) {
560 if (pq != NULL && p > pq) {
561 if ((p = strchr(pq+1, '\'')) != NULL)
564 } else if (pdq != NULL && p > pdq) {
565 if ((p = strchr(pdq+1, '\"')) != NULL)
568 } else if (p == line || *(p-1) != '\\') {
575 p = line + strlen(line) - 1;
576 while (p >= line && isspace((int)*p)) {
581 while (isspace((int)*p))
586 warncount += parse(p, lineno);
593 /* These functions will dump out various interesting structures. */
596 S_clockinfo(size_t l2, void *p)
598 struct clockinfo *ci = (struct clockinfo*)p;
600 if (l2 != sizeof(*ci)) {
601 warnx("S_clockinfo %zu != %zu", l2, sizeof(*ci));
604 printf(hflag ? "{ hz = %'d, tick = %'d, profhz = %'d, stathz = %'d }" :
605 "{ hz = %d, tick = %d, profhz = %d, stathz = %d }",
606 ci->hz, ci->tick, ci->profhz, ci->stathz);
611 S_loadavg(size_t l2, void *p)
613 struct loadavg *tv = (struct loadavg*)p;
615 if (l2 != sizeof(*tv)) {
616 warnx("S_loadavg %zu != %zu", l2, sizeof(*tv));
619 printf(hflag ? "{ %'.2f %'.2f %'.2f }" : "{ %.2f %.2f %.2f }",
620 (double)tv->ldavg[0]/(double)tv->fscale,
621 (double)tv->ldavg[1]/(double)tv->fscale,
622 (double)tv->ldavg[2]/(double)tv->fscale);
627 S_timeval(size_t l2, void *p)
629 struct timeval *tv = (struct timeval*)p;
633 if (l2 != sizeof(*tv)) {
634 warnx("S_timeval %zu != %zu", l2, sizeof(*tv));
637 printf(hflag ? "{ sec = %'jd, usec = %'ld } " :
638 "{ sec = %jd, usec = %ld } ",
639 (intmax_t)tv->tv_sec, tv->tv_usec);
641 p1 = strdup(ctime(&tv_sec));
642 for (p2=p1; *p2 ; p2++)
651 S_vmtotal(size_t l2, void *p)
656 if (l2 != sizeof(*v)) {
657 warnx("S_vmtotal %zu != %zu", l2, sizeof(*v));
662 pageKilo = getpagesize() / 1024;
664 #define pg2k(a) ((uintmax_t)(a) * pageKilo)
665 printf("\nSystem wide totals computed every five seconds:"
666 " (values in kilobytes)\n");
667 printf("===============================================\n");
668 printf("Processes:\t\t(RUNQ: %d Disk Wait: %d Page Wait: "
670 v->t_rq, v->t_dw, v->t_pw, v->t_sl);
671 printf("Virtual Memory:\t\t(Total: %juK Active: %juK)\n",
672 pg2k(v->t_vm), pg2k(v->t_avm));
673 printf("Real Memory:\t\t(Total: %juK Active: %juK)\n",
674 pg2k(v->t_rm), pg2k(v->t_arm));
675 printf("Shared Virtual Memory:\t(Total: %juK Active: %juK)\n",
676 pg2k(v->t_vmshr), pg2k(v->t_avmshr));
677 printf("Shared Real Memory:\t(Total: %juK Active: %juK)\n",
678 pg2k(v->t_rmshr), pg2k(v->t_armshr));
679 printf("Free Memory:\t%juK", pg2k(v->t_free));
685 S_efi_map(size_t l2, void *p)
687 struct efi_map_header *efihdr;
693 static const char * const types[] = {
694 [EFI_MD_TYPE_NULL] = "Reserved",
695 [EFI_MD_TYPE_CODE] = "LoaderCode",
696 [EFI_MD_TYPE_DATA] = "LoaderData",
697 [EFI_MD_TYPE_BS_CODE] = "BootServicesCode",
698 [EFI_MD_TYPE_BS_DATA] = "BootServicesData",
699 [EFI_MD_TYPE_RT_CODE] = "RuntimeServicesCode",
700 [EFI_MD_TYPE_RT_DATA] = "RuntimeServicesData",
701 [EFI_MD_TYPE_FREE] = "ConventionalMemory",
702 [EFI_MD_TYPE_BAD] = "UnusableMemory",
703 [EFI_MD_TYPE_RECLAIM] = "ACPIReclaimMemory",
704 [EFI_MD_TYPE_FIRMWARE] = "ACPIMemoryNVS",
705 [EFI_MD_TYPE_IOMEM] = "MemoryMappedIO",
706 [EFI_MD_TYPE_IOPORT] = "MemoryMappedIOPortSpace",
707 [EFI_MD_TYPE_PALCODE] = "PalCode",
708 [EFI_MD_TYPE_PERSISTENT] = "PersistentMemory",
712 * Memory map data provided by UEFI via the GetMemoryMap
715 if (l2 < sizeof(*efihdr)) {
716 warnx("S_efi_map length less than header");
720 efisz = (sizeof(struct efi_map_header) + 0xf) & ~0xf;
721 map = (struct efi_md *)((uint8_t *)efihdr + efisz);
723 if (efihdr->descriptor_size == 0)
725 if (l2 != efisz + efihdr->memory_size) {
726 warnx("S_efi_map length mismatch %zu vs %zu", l2, efisz +
727 efihdr->memory_size);
730 ndesc = efihdr->memory_size / efihdr->descriptor_size;
732 printf("\n%23s %12s %12s %8s %4s",
733 "Type", "Physical", "Virtual", "#Pages", "Attr");
735 for (i = 0; i < ndesc; i++,
736 map = efi_next_descriptor(map, efihdr->descriptor_size)) {
738 if (map->md_type < nitems(types))
739 type = types[map->md_type];
742 printf("\n%23s %012jx %12p %08jx ", type,
743 (uintmax_t)map->md_phys, map->md_virt,
744 (uintmax_t)map->md_pages);
745 if (map->md_attr & EFI_MD_ATTR_UC)
747 if (map->md_attr & EFI_MD_ATTR_WC)
749 if (map->md_attr & EFI_MD_ATTR_WT)
751 if (map->md_attr & EFI_MD_ATTR_WB)
753 if (map->md_attr & EFI_MD_ATTR_UCE)
755 if (map->md_attr & EFI_MD_ATTR_WP)
757 if (map->md_attr & EFI_MD_ATTR_RP)
759 if (map->md_attr & EFI_MD_ATTR_XP)
761 if (map->md_attr & EFI_MD_ATTR_RT)
768 #if defined(__amd64__) || defined(__i386__)
770 S_bios_smap_xattr(size_t l2, void *p)
772 struct bios_smap_xattr *smap, *end;
774 if (l2 % sizeof(*smap) != 0) {
775 warnx("S_bios_smap_xattr %zu is not a multiple of %zu", l2,
780 end = (struct bios_smap_xattr *)((char *)p + l2);
781 for (smap = p; smap < end; smap++)
782 printf("\nSMAP type=%02x, xattr=%02x, base=%016jx, len=%016jx",
783 smap->type, smap->xattr, (uintmax_t)smap->base,
784 (uintmax_t)smap->length);
790 strIKtoi(const char *str, char **endptrp, const char *fmt)
801 /* caller already checked this */
805 * A format of "IK" is in deciKelvin. A format of "IK3" is in
806 * milliKelvin. The single digit following IK is log10 of the
807 * multiplying factor to convert Kelvin into the untis of this sysctl,
808 * or the dividing factor to convert the sysctl value to Kelvin. Numbers
809 * larger than 6 will run into precision issues with 32-bit integers.
810 * Characters that aren't ASCII digits after the 'K' are ignored. No
811 * localization is present because this is an interface from the kernel
812 * to this program (eg not an end-user interface), so isdigit() isn't
815 if (fmt[2] != '\0' && fmt[2] >= '0' && fmt[2] <= '9')
820 if (*p == 'C' || *p == 'F' || *p == 'K') {
821 temp = strtof(str, endptrp);
822 if (*endptrp != str && *endptrp == p && errno == 0) {
824 temp = (temp - 32) * 5 / 9;
828 for (i = 0; i < prec; i++)
830 return ((int)(temp + 0.5));
833 /* No unit specified -> treat it as a raw number */
834 kelv = (int)strtol(str, endptrp, 10);
835 if (*endptrp != str && *endptrp == p && errno == 0) {
846 * These functions uses a presently undocumented interface to the kernel
847 * to walk the tree and get the type so it can print the value.
848 * This interface is under work and consideration, and should probably
849 * be killed with a big axe by the first person who can find the time.
850 * (be aware though, that the proper interface isn't as obvious as it
851 * may seem, there are various conflicting requirements.
855 name2oid(const char *name, int *oidp)
864 j = CTL_MAXNAME * sizeof(int);
865 i = sysctl(oid, 2, oidp, &j, name, strlen(name));
873 oidfmt(int *oid, int len, char *fmt, u_int *kind)
875 int qoid[CTL_MAXNAME+2];
882 memcpy(qoid + 2, oid, len * sizeof(int));
885 i = sysctl(qoid, len + 2, buf, &j, 0, 0);
887 err(1, "sysctl fmt %d %zu %d", i, j, errno);
890 *kind = *(u_int *)buf;
893 strcpy(fmt, (char *)(buf + sizeof(u_int)));
898 * This formats and outputs the value of one variable
900 * Returns zero if anything was actually output.
901 * Returns one if didn't know what to do with this.
902 * Return minus one if we had errors.
905 show_var(int *oid, int nlen)
907 u_char buf[BUFSIZ], *val, *oval, *p;
908 char name[BUFSIZ], fmt[BUFSIZ];
909 const char *sep, *sep1, *prntype;
910 int qoid[CTL_MAXNAME+2];
913 int i, hexlen, sign, ctltype;
918 int (*func)(size_t, void *);
922 umv = mv = intlen = 0;
928 memcpy(qoid + 2, oid, nlen * sizeof(int));
932 i = sysctl(qoid, nlen + 2, name, &j, 0, 0);
934 err(1, "sysctl name %d %zu %d", i, j, errno);
936 oidfmt(oid, nlen, fmt, &kind);
937 /* if Wflag then only list sysctls that are writeable and not stats. */
938 if (Wflag && ((kind & CTLFLAG_WR) == 0 || (kind & CTLFLAG_STATS) != 0))
941 /* if Tflag then only list sysctls that are tuneables. */
942 if (Tflag && (kind & CTLFLAG_TUN) == 0)
955 ctltype = (kind & CTLTYPE);
956 if (tflag || dflag) {
958 printf("%s%s", name, sep);
959 if (ctl_typename[ctltype] != NULL)
960 prntype = ctl_typename[ctltype];
964 printf("%s%s", prntype, sep);
966 printf("%s", prntype);
971 i = sysctl(qoid, nlen + 2, buf, &j, 0, 0);
976 /* don't fetch opaques that we don't know how to print */
977 if (ctltype == CTLTYPE_OPAQUE) {
978 if (strcmp(fmt, "S,clockinfo") == 0)
980 else if (strcmp(fmt, "S,timeval") == 0)
982 else if (strcmp(fmt, "S,loadavg") == 0)
984 else if (strcmp(fmt, "S,vmtotal") == 0)
987 else if (strcmp(fmt, "S,efi_map_header") == 0)
990 #if defined(__amd64__) || defined(__i386__)
991 else if (strcmp(fmt, "S,bios_smap_xattr") == 0)
992 func = S_bios_smap_xattr;
996 if (!bflag && !oflag && !xflag)
1001 /* find an estimate of how much we need for this var */
1006 i = sysctl(oid, nlen, 0, &j, 0, 0);
1007 j += j; /* we want to be sure :-) */
1010 val = oval = malloc(j + 1);
1012 warnx("malloc failed");
1016 i = sysctl(oid, nlen, val, &len, 0, 0);
1017 if (i != 0 || (len == 0 && ctltype != CTLTYPE_STRING)) {
1023 fwrite(val, 1, len, stdout);
1029 sign = ctl_sign[ctltype];
1030 intlen = ctl_size[ctltype];
1033 case CTLTYPE_STRING:
1035 printf("%s%s", name, sep);
1036 printf("%.*s", (int)len, p);
1053 printf("%s%s", name, sep);
1054 hexlen = 2 + (intlen * CHAR_BIT + 3) / 4;
1056 while (len >= intlen) {
1057 switch (kind & CTLTYPE) {
1070 umv = *(uint8_t *)p;
1075 umv = *(uint16_t *)p;
1080 umv = *(uint32_t *)p;
1085 umv = *(uint64_t *)p;
1089 fputs(sep1, stdout);
1091 printf("%#0*jx", hexlen, umv);
1093 printf(hflag ? "%'ju" : "%ju", umv);
1094 else if (fmt[1] == 'K') {
1099 * See strIKtoi for details on fmt.
1103 prec = fmt[2] - '0';
1105 for (int i = 0; i < prec; i++)
1107 printf("%.*fC", prec,
1108 (float)mv / base - 273.15);
1111 printf(hflag ? "%'jd" : "%jd", mv);
1119 case CTLTYPE_OPAQUE:
1123 printf("%s%s", name, sep);
1124 i = (*func)(len, p);
1130 if (!oflag && !xflag) {
1135 printf("%s%s", name, sep);
1136 printf("Format:%s Length:%zu Dump:0x", fmt, len);
1137 while (len-- && (xflag || p < val + 16))
1138 printf("%02x", *p++);
1139 if (!xflag && len > 16)
1149 sysctl_all(int *oid, int len)
1151 int name1[22], name2[22];
1159 memcpy(name1+2, oid, len * sizeof(int));
1167 j = sysctl(name1, l1, name2, &l2, 0, 0);
1169 if (errno == ENOENT)
1172 err(1, "sysctl(getnext) %d %zu", j, l2);
1177 if (len < 0 || l2 < (unsigned int)len)
1180 for (i = 0; i < len; i++)
1181 if (name2[i] != oid[i])
1184 i = show_var(name2, l2);
1188 memcpy(name1+2, name2, l2 * sizeof(int));