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 2004 Sun Microsystems, Inc. All rights reserved.
24*0Sstevel@tonic-gate * Use is subject to license terms.
25*0Sstevel@tonic-gate */
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28*0Sstevel@tonic-gate /* All Rights Reserved */
29*0Sstevel@tonic-gate
30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
31*0Sstevel@tonic-gate
32*0Sstevel@tonic-gate #include <stdio.h>
33*0Sstevel@tonic-gate #include <stdlib.h>
34*0Sstevel@tonic-gate #include <string.h>
35*0Sstevel@tonic-gate #include <unistd.h>
36*0Sstevel@tonic-gate #include <errno.h>
37*0Sstevel@tonic-gate #include <sys/types.h>
38*0Sstevel@tonic-gate #include <sys/priocntl.h>
39*0Sstevel@tonic-gate #include <sys/iapriocntl.h>
40*0Sstevel@tonic-gate #include <sys/param.h>
41*0Sstevel@tonic-gate #include <sys/ia.h>
42*0Sstevel@tonic-gate
43*0Sstevel@tonic-gate #include "dispadmin.h"
44*0Sstevel@tonic-gate
45*0Sstevel@tonic-gate /*
46*0Sstevel@tonic-gate * This file contains the class specific code implementing
47*0Sstevel@tonic-gate * the interactive dispadmin sub-command.
48*0Sstevel@tonic-gate */
49*0Sstevel@tonic-gate
50*0Sstevel@tonic-gate #define BASENMSZ 16
51*0Sstevel@tonic-gate
52*0Sstevel@tonic-gate extern char *basename();
53*0Sstevel@tonic-gate
54*0Sstevel@tonic-gate static void get_iadptbl(), set_iadptbl();
55*0Sstevel@tonic-gate
56*0Sstevel@tonic-gate static char usage[] =
57*0Sstevel@tonic-gate "usage: dispadmin -l\n\
58*0Sstevel@tonic-gate dispadmin -c IA -g [-r res]\n\
59*0Sstevel@tonic-gate dispadmin -c IA -s infile\n";
60*0Sstevel@tonic-gate
61*0Sstevel@tonic-gate static char basenm[BASENMSZ];
62*0Sstevel@tonic-gate static char cmdpath[256];
63*0Sstevel@tonic-gate
64*0Sstevel@tonic-gate
65*0Sstevel@tonic-gate int
main(int argc,char ** argv)66*0Sstevel@tonic-gate main(int argc, char **argv)
67*0Sstevel@tonic-gate {
68*0Sstevel@tonic-gate extern char *optarg;
69*0Sstevel@tonic-gate
70*0Sstevel@tonic-gate int c;
71*0Sstevel@tonic-gate int lflag, gflag, rflag, sflag;
72*0Sstevel@tonic-gate ulong_t res;
73*0Sstevel@tonic-gate char *infile;
74*0Sstevel@tonic-gate
75*0Sstevel@tonic-gate (void) strcpy(cmdpath, argv[0]);
76*0Sstevel@tonic-gate (void) strcpy(basenm, basename(argv[0]));
77*0Sstevel@tonic-gate lflag = gflag = rflag = sflag = 0;
78*0Sstevel@tonic-gate while ((c = getopt(argc, argv, "lc:gr:s:")) != -1) {
79*0Sstevel@tonic-gate switch (c) {
80*0Sstevel@tonic-gate
81*0Sstevel@tonic-gate case 'l':
82*0Sstevel@tonic-gate lflag++;
83*0Sstevel@tonic-gate break;
84*0Sstevel@tonic-gate
85*0Sstevel@tonic-gate case 'c':
86*0Sstevel@tonic-gate if (strcmp(optarg, "IA") != 0)
87*0Sstevel@tonic-gate fatalerr("error: %s executed for %s class, "
88*0Sstevel@tonic-gate "%s is actually sub-command for IA class\n",
89*0Sstevel@tonic-gate cmdpath, optarg, cmdpath);
90*0Sstevel@tonic-gate break;
91*0Sstevel@tonic-gate
92*0Sstevel@tonic-gate case 'g':
93*0Sstevel@tonic-gate gflag++;
94*0Sstevel@tonic-gate break;
95*0Sstevel@tonic-gate
96*0Sstevel@tonic-gate case 'r':
97*0Sstevel@tonic-gate rflag++;
98*0Sstevel@tonic-gate res = strtoul(optarg, (char **)NULL, 10);
99*0Sstevel@tonic-gate break;
100*0Sstevel@tonic-gate
101*0Sstevel@tonic-gate case 's':
102*0Sstevel@tonic-gate sflag++;
103*0Sstevel@tonic-gate infile = optarg;
104*0Sstevel@tonic-gate break;
105*0Sstevel@tonic-gate
106*0Sstevel@tonic-gate case '?':
107*0Sstevel@tonic-gate fatalerr(usage);
108*0Sstevel@tonic-gate
109*0Sstevel@tonic-gate default:
110*0Sstevel@tonic-gate break;
111*0Sstevel@tonic-gate }
112*0Sstevel@tonic-gate }
113*0Sstevel@tonic-gate
114*0Sstevel@tonic-gate if (lflag) {
115*0Sstevel@tonic-gate if (gflag || rflag || sflag)
116*0Sstevel@tonic-gate fatalerr(usage);
117*0Sstevel@tonic-gate
118*0Sstevel@tonic-gate (void) printf("IA\t(Interactive)\n");
119*0Sstevel@tonic-gate return (0);
120*0Sstevel@tonic-gate
121*0Sstevel@tonic-gate } else if (gflag) {
122*0Sstevel@tonic-gate if (lflag || sflag)
123*0Sstevel@tonic-gate fatalerr(usage);
124*0Sstevel@tonic-gate
125*0Sstevel@tonic-gate if (rflag == 0)
126*0Sstevel@tonic-gate res = 1000;
127*0Sstevel@tonic-gate
128*0Sstevel@tonic-gate get_iadptbl(res);
129*0Sstevel@tonic-gate return (0);
130*0Sstevel@tonic-gate
131*0Sstevel@tonic-gate } else if (sflag) {
132*0Sstevel@tonic-gate if (lflag || gflag || rflag)
133*0Sstevel@tonic-gate fatalerr(usage);
134*0Sstevel@tonic-gate
135*0Sstevel@tonic-gate set_iadptbl(infile);
136*0Sstevel@tonic-gate return (0);
137*0Sstevel@tonic-gate
138*0Sstevel@tonic-gate } else {
139*0Sstevel@tonic-gate fatalerr(usage);
140*0Sstevel@tonic-gate }
141*0Sstevel@tonic-gate return (1);
142*0Sstevel@tonic-gate }
143*0Sstevel@tonic-gate
144*0Sstevel@tonic-gate
145*0Sstevel@tonic-gate /*
146*0Sstevel@tonic-gate * Retrieve the current ia_dptbl from memory, convert the time quantum
147*0Sstevel@tonic-gate * values to the resolution specified by res and write the table to stdout.
148*0Sstevel@tonic-gate */
149*0Sstevel@tonic-gate static void
get_iadptbl(ulong_t res)150*0Sstevel@tonic-gate get_iadptbl(ulong_t res)
151*0Sstevel@tonic-gate {
152*0Sstevel@tonic-gate int i;
153*0Sstevel@tonic-gate int iadpsz;
154*0Sstevel@tonic-gate pcinfo_t pcinfo;
155*0Sstevel@tonic-gate pcadmin_t pcadmin;
156*0Sstevel@tonic-gate iaadmin_t iaadmin;
157*0Sstevel@tonic-gate iadpent_t *ia_dptbl;
158*0Sstevel@tonic-gate hrtimer_t hrtime;
159*0Sstevel@tonic-gate
160*0Sstevel@tonic-gate (void) strcpy(pcinfo.pc_clname, "IA");
161*0Sstevel@tonic-gate if (priocntl(0, 0, PC_GETCID, (caddr_t)&pcinfo) == -1)
162*0Sstevel@tonic-gate fatalerr("%s: Can't get IA class ID, priocntl system "
163*0Sstevel@tonic-gate "call failed with errno %d\n",
164*0Sstevel@tonic-gate basenm, errno);
165*0Sstevel@tonic-gate
166*0Sstevel@tonic-gate pcadmin.pc_cid = pcinfo.pc_cid;
167*0Sstevel@tonic-gate pcadmin.pc_cladmin = (char *)&iaadmin;
168*0Sstevel@tonic-gate iaadmin.ia_cmd = IA_GETDPSIZE;
169*0Sstevel@tonic-gate
170*0Sstevel@tonic-gate if (priocntl(0, 0, PC_ADMIN, (caddr_t)&pcadmin) == -1)
171*0Sstevel@tonic-gate fatalerr("%s: Can't get ia_dptbl size, priocntl system "
172*0Sstevel@tonic-gate "call failed with errno %d\n",
173*0Sstevel@tonic-gate basenm, errno);
174*0Sstevel@tonic-gate
175*0Sstevel@tonic-gate iadpsz = iaadmin.ia_ndpents * sizeof (iadpent_t);
176*0Sstevel@tonic-gate if ((ia_dptbl = (iadpent_t *)malloc(iadpsz)) == NULL)
177*0Sstevel@tonic-gate fatalerr("%s: Can't allocate memory for ia_dptbl\n", basenm);
178*0Sstevel@tonic-gate
179*0Sstevel@tonic-gate iaadmin.ia_dpents = ia_dptbl;
180*0Sstevel@tonic-gate
181*0Sstevel@tonic-gate iaadmin.ia_cmd = IA_GETDPTBL;
182*0Sstevel@tonic-gate if (priocntl(0, 0, PC_ADMIN, (caddr_t)&pcadmin) == -1)
183*0Sstevel@tonic-gate fatalerr("%s: Can't get ia_dptbl, priocntl system call "
184*0Sstevel@tonic-gate "call failed with errno %d\n",
185*0Sstevel@tonic-gate basenm, errno);
186*0Sstevel@tonic-gate
187*0Sstevel@tonic-gate (void) printf("# Interactive Dispatcher Configuration\n");
188*0Sstevel@tonic-gate (void) printf("RES=%ld\n\n", res);
189*0Sstevel@tonic-gate (void) printf("# ia_quantum ia_tqexp ia_slpret ia_maxwait ia_lwait \
190*0Sstevel@tonic-gate PRIORITY LEVEL\n");
191*0Sstevel@tonic-gate
192*0Sstevel@tonic-gate for (i = 0; i < iaadmin.ia_ndpents; i++) {
193*0Sstevel@tonic-gate if (res != HZ) {
194*0Sstevel@tonic-gate hrtime.hrt_secs = 0;
195*0Sstevel@tonic-gate hrtime.hrt_rem = ia_dptbl[i].ia_quantum;
196*0Sstevel@tonic-gate hrtime.hrt_res = HZ;
197*0Sstevel@tonic-gate if (_hrtnewres(&hrtime, res, HRT_RNDUP) == -1)
198*0Sstevel@tonic-gate fatalerr("%s: Can't convert to requested "
199*0Sstevel@tonic-gate "resolution\n", basenm);
200*0Sstevel@tonic-gate if ((ia_dptbl[i].ia_quantum = hrtconvert(&hrtime))
201*0Sstevel@tonic-gate == -1)
202*0Sstevel@tonic-gate fatalerr("%s: Can't express time quantum in "
203*0Sstevel@tonic-gate "requested resolution,\n"
204*0Sstevel@tonic-gate "try coarser resolution\n",
205*0Sstevel@tonic-gate basenm);
206*0Sstevel@tonic-gate }
207*0Sstevel@tonic-gate (void) printf("%10ld%10d%10d%12d%10d # %3d\n",
208*0Sstevel@tonic-gate ia_dptbl[i].ia_quantum, ia_dptbl[i].ia_tqexp,
209*0Sstevel@tonic-gate ia_dptbl[i].ia_slpret, ia_dptbl[i].ia_maxwait,
210*0Sstevel@tonic-gate ia_dptbl[i].ia_lwait, i);
211*0Sstevel@tonic-gate }
212*0Sstevel@tonic-gate }
213*0Sstevel@tonic-gate
214*0Sstevel@tonic-gate
215*0Sstevel@tonic-gate /*
216*0Sstevel@tonic-gate * Read the ia_dptbl values from infile, convert the time quantum values
217*0Sstevel@tonic-gate * to HZ resolution, do a little sanity checking and overwrite the table
218*0Sstevel@tonic-gate * in memory with the values from the file.
219*0Sstevel@tonic-gate */
220*0Sstevel@tonic-gate static void
set_iadptbl(infile)221*0Sstevel@tonic-gate set_iadptbl(infile)
222*0Sstevel@tonic-gate char *infile;
223*0Sstevel@tonic-gate {
224*0Sstevel@tonic-gate int i;
225*0Sstevel@tonic-gate int niadpents;
226*0Sstevel@tonic-gate char *tokp;
227*0Sstevel@tonic-gate pcinfo_t pcinfo;
228*0Sstevel@tonic-gate pcadmin_t pcadmin;
229*0Sstevel@tonic-gate iaadmin_t iaadmin;
230*0Sstevel@tonic-gate iadpent_t *ia_dptbl;
231*0Sstevel@tonic-gate int linenum;
232*0Sstevel@tonic-gate ulong_t res;
233*0Sstevel@tonic-gate hrtimer_t hrtime;
234*0Sstevel@tonic-gate FILE *fp;
235*0Sstevel@tonic-gate char buf[512];
236*0Sstevel@tonic-gate int wslength;
237*0Sstevel@tonic-gate
238*0Sstevel@tonic-gate (void) strcpy(pcinfo.pc_clname, "IA");
239*0Sstevel@tonic-gate if (priocntl(0, 0, PC_GETCID, (caddr_t)&pcinfo) == -1)
240*0Sstevel@tonic-gate fatalerr("%s: Can't get IA class ID, priocntl system "
241*0Sstevel@tonic-gate "call failed with errno %d\n", basenm, errno);
242*0Sstevel@tonic-gate
243*0Sstevel@tonic-gate pcadmin.pc_cid = pcinfo.pc_cid;
244*0Sstevel@tonic-gate pcadmin.pc_cladmin = (char *)&iaadmin;
245*0Sstevel@tonic-gate iaadmin.ia_cmd = IA_GETDPSIZE;
246*0Sstevel@tonic-gate
247*0Sstevel@tonic-gate if (priocntl(0, 0, PC_ADMIN, (caddr_t)&pcadmin) == -1)
248*0Sstevel@tonic-gate fatalerr("%s: Can't get ia_dptbl size, priocntl system "
249*0Sstevel@tonic-gate "call failed with errno %d\n", basenm, errno);
250*0Sstevel@tonic-gate
251*0Sstevel@tonic-gate niadpents = iaadmin.ia_ndpents;
252*0Sstevel@tonic-gate if ((ia_dptbl =
253*0Sstevel@tonic-gate (iadpent_t *)malloc(niadpents * sizeof (iadpent_t))) == NULL)
254*0Sstevel@tonic-gate fatalerr("%s: Can't allocate memory for ia_dptbl\n", basenm);
255*0Sstevel@tonic-gate
256*0Sstevel@tonic-gate if ((fp = fopen(infile, "r")) == NULL)
257*0Sstevel@tonic-gate fatalerr("%s: Can't open %s for input\n", basenm, infile);
258*0Sstevel@tonic-gate
259*0Sstevel@tonic-gate linenum = 0;
260*0Sstevel@tonic-gate
261*0Sstevel@tonic-gate /*
262*0Sstevel@tonic-gate * Find the first non-blank, non-comment line. A comment line
263*0Sstevel@tonic-gate * is any line with '#' as the first non-white-space character.
264*0Sstevel@tonic-gate */
265*0Sstevel@tonic-gate do {
266*0Sstevel@tonic-gate if (fgets(buf, sizeof (buf), fp) == NULL)
267*0Sstevel@tonic-gate fatalerr("%s: Too few lines in input table\n", basenm);
268*0Sstevel@tonic-gate linenum++;
269*0Sstevel@tonic-gate } while (buf[0] == '#' || buf[0] == '\0' ||
270*0Sstevel@tonic-gate (wslength = strspn(buf, " \t\n")) == strlen(buf) ||
271*0Sstevel@tonic-gate strchr(buf, '#') == buf + wslength);
272*0Sstevel@tonic-gate
273*0Sstevel@tonic-gate if ((tokp = strtok(buf, " \t")) == NULL)
274*0Sstevel@tonic-gate fatalerr("%s: Bad RES specification, line %d of input file\n",
275*0Sstevel@tonic-gate basenm, linenum);
276*0Sstevel@tonic-gate if ((int)strlen(tokp) > 4) {
277*0Sstevel@tonic-gate if (strncmp(tokp, "RES=", 4) != 0)
278*0Sstevel@tonic-gate fatalerr("%s: Bad RES specification, \
279*0Sstevel@tonic-gate line %d of input file\n", basenm, linenum);
280*0Sstevel@tonic-gate if (tokp[4] == '-')
281*0Sstevel@tonic-gate fatalerr("%s: Bad RES specification, \
282*0Sstevel@tonic-gate line %d of input file\n", basenm, linenum);
283*0Sstevel@tonic-gate res = strtoul(&tokp[4], (char **)NULL, 10);
284*0Sstevel@tonic-gate } else if (strlen(tokp) == 4) {
285*0Sstevel@tonic-gate if (strcmp(tokp, "RES=") != 0)
286*0Sstevel@tonic-gate fatalerr("%s: Bad RES specification, \
287*0Sstevel@tonic-gate line %d of input file\n", basenm, linenum);
288*0Sstevel@tonic-gate if ((tokp = strtok(NULL, " \t")) == NULL)
289*0Sstevel@tonic-gate fatalerr("%s: Bad RES specification, \
290*0Sstevel@tonic-gate line %d of input file\n", basenm, linenum);
291*0Sstevel@tonic-gate if (tokp[0] == '-')
292*0Sstevel@tonic-gate fatalerr("%s: Bad RES specification, \
293*0Sstevel@tonic-gate line %d of input file\n", basenm, linenum);
294*0Sstevel@tonic-gate res = strtoul(tokp, (char **)NULL, 10);
295*0Sstevel@tonic-gate } else if (strlen(tokp) == 3) {
296*0Sstevel@tonic-gate if (strcmp(tokp, "RES") != 0)
297*0Sstevel@tonic-gate fatalerr("%s: Bad RES specification, \
298*0Sstevel@tonic-gate line %d of input file\n", basenm, linenum);
299*0Sstevel@tonic-gate if ((tokp = strtok(NULL, " \t")) == NULL)
300*0Sstevel@tonic-gate fatalerr("%s: Bad RES specification, \
301*0Sstevel@tonic-gate line %d of input file\n", basenm, linenum);
302*0Sstevel@tonic-gate if ((int)strlen(tokp) > 1) {
303*0Sstevel@tonic-gate if (strncmp(tokp, "=", 1) != 0)
304*0Sstevel@tonic-gate fatalerr("%s: Bad RES specification, \
305*0Sstevel@tonic-gate line %d of input file\n", basenm, linenum);
306*0Sstevel@tonic-gate if (tokp[1] == '-')
307*0Sstevel@tonic-gate fatalerr("%s: Bad RES specification, \
308*0Sstevel@tonic-gate line %d of input file\n", basenm, linenum);
309*0Sstevel@tonic-gate res = strtoul(&tokp[1], (char **)NULL, 10);
310*0Sstevel@tonic-gate } else if (strlen(tokp) == 1) {
311*0Sstevel@tonic-gate if ((tokp = strtok(NULL, " \t")) == NULL)
312*0Sstevel@tonic-gate fatalerr("%s: Bad RES specification, \
313*0Sstevel@tonic-gate line %d of input file\n", basenm, linenum);
314*0Sstevel@tonic-gate if (tokp[0] == '-')
315*0Sstevel@tonic-gate fatalerr("%s: Bad RES specification, \
316*0Sstevel@tonic-gate line %d of input file\n", basenm, linenum);
317*0Sstevel@tonic-gate res = strtoul(tokp, (char **)NULL, 10);
318*0Sstevel@tonic-gate }
319*0Sstevel@tonic-gate } else {
320*0Sstevel@tonic-gate fatalerr("%s: Bad RES specification, line %d of input file\n",
321*0Sstevel@tonic-gate basenm, linenum);
322*0Sstevel@tonic-gate }
323*0Sstevel@tonic-gate
324*0Sstevel@tonic-gate /*
325*0Sstevel@tonic-gate * The remainder of the input file should contain exactly enough
326*0Sstevel@tonic-gate * non-blank, non-comment lines to fill the table (ia_ndpents lines).
327*0Sstevel@tonic-gate * We assume that any non-blank, non-comment line is data for the
328*0Sstevel@tonic-gate * table and fail if we find more or less than we need.
329*0Sstevel@tonic-gate */
330*0Sstevel@tonic-gate for (i = 0; i < iaadmin.ia_ndpents; i++) {
331*0Sstevel@tonic-gate
332*0Sstevel@tonic-gate /*
333*0Sstevel@tonic-gate * Get the next non-blank, non-comment line.
334*0Sstevel@tonic-gate */
335*0Sstevel@tonic-gate do {
336*0Sstevel@tonic-gate if (fgets(buf, sizeof (buf), fp) == NULL)
337*0Sstevel@tonic-gate fatalerr("%s: Too few lines in input table\n",
338*0Sstevel@tonic-gate basenm);
339*0Sstevel@tonic-gate linenum++;
340*0Sstevel@tonic-gate } while (buf[0] == '#' || buf[0] == '\0' ||
341*0Sstevel@tonic-gate (wslength = strspn(buf, " \t\n")) == strlen(buf) ||
342*0Sstevel@tonic-gate strchr(buf, '#') == buf + wslength);
343*0Sstevel@tonic-gate
344*0Sstevel@tonic-gate if ((tokp = strtok(buf, " \t")) == NULL)
345*0Sstevel@tonic-gate fatalerr("%s: Too few values, line %d of input file\n",
346*0Sstevel@tonic-gate basenm, linenum);
347*0Sstevel@tonic-gate
348*0Sstevel@tonic-gate if (res != HZ) {
349*0Sstevel@tonic-gate hrtime.hrt_secs = 0;
350*0Sstevel@tonic-gate hrtime.hrt_rem = atol(tokp);
351*0Sstevel@tonic-gate hrtime.hrt_res = res;
352*0Sstevel@tonic-gate if (_hrtnewres(&hrtime, HZ, HRT_RNDUP) == -1)
353*0Sstevel@tonic-gate fatalerr("%s: Can't convert specified \
354*0Sstevel@tonic-gate resolution to ticks\n", basenm);
355*0Sstevel@tonic-gate if ((ia_dptbl[i].ia_quantum = hrtconvert(&hrtime))
356*0Sstevel@tonic-gate == -1)
357*0Sstevel@tonic-gate fatalerr("%s: ia_quantum value out of "
358*0Sstevel@tonic-gate "valid range; line %d of input,\n"
359*0Sstevel@tonic-gate "table not overwritten\n",
360*0Sstevel@tonic-gate basenm, linenum);
361*0Sstevel@tonic-gate } else {
362*0Sstevel@tonic-gate ia_dptbl[i].ia_quantum = atol(tokp);
363*0Sstevel@tonic-gate }
364*0Sstevel@tonic-gate if (ia_dptbl[i].ia_quantum <= 0)
365*0Sstevel@tonic-gate fatalerr("%s: ia_quantum value out of valid range; "
366*0Sstevel@tonic-gate "line %d of input,\ntable not overwritten\n",
367*0Sstevel@tonic-gate basenm, linenum);
368*0Sstevel@tonic-gate
369*0Sstevel@tonic-gate if ((tokp = strtok(NULL, " \t")) == NULL || tokp[0] == '#')
370*0Sstevel@tonic-gate fatalerr("%s: Too few values, line %d of input file\n",
371*0Sstevel@tonic-gate basenm, linenum);
372*0Sstevel@tonic-gate ia_dptbl[i].ia_tqexp = (short)atoi(tokp);
373*0Sstevel@tonic-gate if (ia_dptbl[i].ia_tqexp < 0 ||
374*0Sstevel@tonic-gate ia_dptbl[i].ia_tqexp > iaadmin.ia_ndpents)
375*0Sstevel@tonic-gate fatalerr("%s: ia_tqexp value out of valid range; "
376*0Sstevel@tonic-gate "line %d of input,\ntable not overwritten\n",
377*0Sstevel@tonic-gate basenm, linenum);
378*0Sstevel@tonic-gate
379*0Sstevel@tonic-gate if ((tokp = strtok(NULL, " \t")) == NULL || tokp[0] == '#')
380*0Sstevel@tonic-gate fatalerr("%s: Too few values, line %d of input file\n",
381*0Sstevel@tonic-gate basenm, linenum);
382*0Sstevel@tonic-gate ia_dptbl[i].ia_slpret = (short)atoi(tokp);
383*0Sstevel@tonic-gate if (ia_dptbl[i].ia_slpret < 0 ||
384*0Sstevel@tonic-gate ia_dptbl[i].ia_slpret > iaadmin.ia_ndpents)
385*0Sstevel@tonic-gate fatalerr("%s: ia_slpret value out of valid range; "
386*0Sstevel@tonic-gate "line %d of input,\ntable not overwritten\n",
387*0Sstevel@tonic-gate basenm, linenum);
388*0Sstevel@tonic-gate
389*0Sstevel@tonic-gate if ((tokp = strtok(NULL, " \t")) == NULL || tokp[0] == '#')
390*0Sstevel@tonic-gate fatalerr("%s: Too few values, line %d of input file\n",
391*0Sstevel@tonic-gate basenm, linenum);
392*0Sstevel@tonic-gate ia_dptbl[i].ia_maxwait = (short)atoi(tokp);
393*0Sstevel@tonic-gate if (ia_dptbl[i].ia_maxwait < 0)
394*0Sstevel@tonic-gate fatalerr("%s: ia_maxwait value out of valid range; "
395*0Sstevel@tonic-gate "line %d of input,\ntable not overwritten\n",
396*0Sstevel@tonic-gate basenm, linenum);
397*0Sstevel@tonic-gate
398*0Sstevel@tonic-gate if ((tokp = strtok(NULL, " \t")) == NULL || tokp[0] == '#')
399*0Sstevel@tonic-gate fatalerr("%s: Too few values, line %d of input file\n",
400*0Sstevel@tonic-gate basenm, linenum);
401*0Sstevel@tonic-gate ia_dptbl[i].ia_lwait = (short)atoi(tokp);
402*0Sstevel@tonic-gate if (ia_dptbl[i].ia_lwait < 0 ||
403*0Sstevel@tonic-gate ia_dptbl[i].ia_lwait > iaadmin.ia_ndpents)
404*0Sstevel@tonic-gate fatalerr("%s: ia_lwait value out of valid range; "
405*0Sstevel@tonic-gate "line %d of input,\ntable not overwritten\n",
406*0Sstevel@tonic-gate basenm, linenum);
407*0Sstevel@tonic-gate
408*0Sstevel@tonic-gate if ((tokp = strtok(NULL, " \t")) != NULL && tokp[0] != '#')
409*0Sstevel@tonic-gate fatalerr("%s: Too many values, line %d of input file\n",
410*0Sstevel@tonic-gate basenm, linenum);
411*0Sstevel@tonic-gate }
412*0Sstevel@tonic-gate
413*0Sstevel@tonic-gate /*
414*0Sstevel@tonic-gate * We've read enough lines to fill the table. We fail
415*0Sstevel@tonic-gate * if the input file contains any more.
416*0Sstevel@tonic-gate */
417*0Sstevel@tonic-gate while (fgets(buf, sizeof (buf), fp) != NULL) {
418*0Sstevel@tonic-gate if (buf[0] != '#' && buf[0] != '\0' &&
419*0Sstevel@tonic-gate (wslength = strspn(buf, " \t\n")) != strlen(buf) &&
420*0Sstevel@tonic-gate strchr(buf, '#') != buf + wslength)
421*0Sstevel@tonic-gate fatalerr("%s: Too many lines in input table\n",
422*0Sstevel@tonic-gate basenm);
423*0Sstevel@tonic-gate }
424*0Sstevel@tonic-gate
425*0Sstevel@tonic-gate iaadmin.ia_dpents = ia_dptbl;
426*0Sstevel@tonic-gate iaadmin.ia_cmd = IA_SETDPTBL;
427*0Sstevel@tonic-gate if (priocntl(0, 0, PC_ADMIN, (caddr_t)&pcadmin) == -1)
428*0Sstevel@tonic-gate fatalerr("%s: Can't set ia_dptbl, priocntl system call \
429*0Sstevel@tonic-gate failed with errno %d\n", basenm, errno);
430*0Sstevel@tonic-gate }
431