1 1.22 joerg /* $NetBSD: iopctl.c,v 1.22 2011/08/30 19:03:25 joerg Exp $ */ 2 1.1 ad 3 1.1 ad /*- 4 1.1 ad * Copyright (c) 2000 The NetBSD Foundation, Inc. 5 1.1 ad * All rights reserved. 6 1.1 ad * 7 1.1 ad * This code is derived from software contributed to The NetBSD Foundation 8 1.1 ad * by Andrew Doran. 9 1.1 ad * 10 1.1 ad * Redistribution and use in source and binary forms, with or without 11 1.1 ad * modification, are permitted provided that the following conditions 12 1.1 ad * are met: 13 1.1 ad * 1. Redistributions of source code must retain the above copyright 14 1.1 ad * notice, this list of conditions and the following disclaimer. 15 1.1 ad * 2. Redistributions in binary form must reproduce the above copyright 16 1.1 ad * notice, this list of conditions and the following disclaimer in the 17 1.1 ad * documentation and/or other materials provided with the distribution. 18 1.1 ad * 19 1.1 ad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 1.1 ad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 1.1 ad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 1.1 ad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 1.1 ad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 1.1 ad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 1.1 ad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.1 ad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 1.1 ad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 1.1 ad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 1.1 ad * POSSIBILITY OF SUCH DAMAGE. 30 1.1 ad */ 31 1.1 ad 32 1.1 ad #ifndef lint 33 1.1 ad #include <sys/cdefs.h> 34 1.22 joerg __RCSID("$NetBSD: iopctl.c,v 1.22 2011/08/30 19:03:25 joerg Exp $"); 35 1.1 ad #endif /* not lint */ 36 1.1 ad 37 1.1 ad #include <sys/param.h> 38 1.1 ad #include <sys/ioctl.h> 39 1.1 ad #include <sys/uio.h> 40 1.1 ad 41 1.1 ad #include <err.h> 42 1.1 ad #include <errno.h> 43 1.1 ad #include <fcntl.h> 44 1.1 ad #include <stdio.h> 45 1.1 ad #include <stdlib.h> 46 1.1 ad #include <stdarg.h> 47 1.1 ad #include <string.h> 48 1.1 ad #include <unistd.h> 49 1.1 ad #include <util.h> 50 1.1 ad 51 1.1 ad #include <dev/i2o/i2o.h> 52 1.8 ad #include <dev/i2o/iopio.h> 53 1.1 ad 54 1.22 joerg static const char *class2str(int); 55 1.22 joerg static void getparam(int, int, void *, int); 56 1.22 joerg static int gettid(char **); 57 1.22 joerg static int show(const char *, const char *, ...) __printflike(2, 3); 58 1.22 joerg static void i2ostrvis(const u_char *, int, char *, int); 59 1.22 joerg static void usage(void) __dead; 60 1.22 joerg 61 1.22 joerg static void reconfig(char **); 62 1.22 joerg static void showdevid(char **); 63 1.22 joerg static void showddmid(char **); 64 1.22 joerg static void showlct(char **); 65 1.22 joerg static void showstatus(char **); 66 1.22 joerg static void showtidmap(char **); 67 1.1 ad 68 1.22 joerg static struct { 69 1.1 ad int class; 70 1.1 ad const char *caption; 71 1.1 ad } const i2oclass[] = { 72 1.1 ad { I2O_CLASS_EXECUTIVE, "executive" }, 73 1.1 ad { I2O_CLASS_DDM, "device driver module" }, 74 1.1 ad { I2O_CLASS_RANDOM_BLOCK_STORAGE, "random block storage" }, 75 1.1 ad { I2O_CLASS_SEQUENTIAL_STORAGE, "sequential storage" }, 76 1.1 ad { I2O_CLASS_LAN, "LAN port" }, 77 1.1 ad { I2O_CLASS_WAN, "WAN port" }, 78 1.1 ad { I2O_CLASS_FIBRE_CHANNEL_PORT, "fibrechannel port" }, 79 1.1 ad { I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL, "fibrechannel peripheral" }, 80 1.1 ad { I2O_CLASS_SCSI_PERIPHERAL, "SCSI peripheral" }, 81 1.1 ad { I2O_CLASS_ATE_PORT, "ATE port" }, 82 1.1 ad { I2O_CLASS_ATE_PERIPHERAL, "ATE peripheral" }, 83 1.1 ad { I2O_CLASS_FLOPPY_CONTROLLER, "floppy controller" }, 84 1.1 ad { I2O_CLASS_FLOPPY_DEVICE, "floppy device" }, 85 1.1 ad { I2O_CLASS_BUS_ADAPTER_PORT, "bus adapter port" }, 86 1.1 ad }; 87 1.1 ad 88 1.22 joerg static struct { 89 1.1 ad const char *label; 90 1.1 ad int takesargs; 91 1.1 ad void (*func)(char **); 92 1.1 ad } const cmdtab[] = { 93 1.1 ad { "reconfig", 0, reconfig }, 94 1.1 ad { "showddmid", 1, showddmid }, 95 1.1 ad { "showdevid", 1, showdevid }, 96 1.1 ad { "showlct", 0, showlct }, 97 1.1 ad { "showstatus", 0, showstatus }, 98 1.8 ad { "showtidmap", 0, showtidmap }, 99 1.1 ad }; 100 1.1 ad 101 1.22 joerg static int fd; 102 1.22 joerg static char buf[32768]; 103 1.22 joerg static struct i2o_status status; 104 1.1 ad 105 1.1 ad int 106 1.1 ad main(int argc, char **argv) 107 1.1 ad { 108 1.19 lukem int ch; 109 1.19 lukem size_t i; 110 1.1 ad const char *dv; 111 1.1 ad struct iovec iov; 112 1.1 ad 113 1.1 ad dv = "/dev/iop0"; 114 1.1 ad 115 1.1 ad while ((ch = getopt(argc, argv, "f:")) != -1) { 116 1.1 ad switch (ch) { 117 1.1 ad case 'f': 118 1.1 ad dv = optarg; 119 1.1 ad break; 120 1.1 ad default: 121 1.1 ad usage(); 122 1.1 ad /* NOTREACHED */ 123 1.1 ad } 124 1.1 ad } 125 1.1 ad 126 1.1 ad if (argv[optind] == NULL) 127 1.1 ad usage(); 128 1.1 ad 129 1.1 ad if ((fd = open(dv, O_RDWR)) < 0) 130 1.1 ad err(EXIT_FAILURE, "%s", dv); 131 1.1 ad 132 1.1 ad iov.iov_base = &status; 133 1.1 ad iov.iov_len = sizeof(status); 134 1.1 ad if (ioctl(fd, IOPIOCGSTATUS, &iov) < 0) 135 1.1 ad err(EXIT_FAILURE, "IOPIOCGSTATUS"); 136 1.1 ad 137 1.1 ad for (i = 0; i < sizeof(cmdtab) / sizeof(cmdtab[0]); i++) 138 1.1 ad if (strcmp(argv[optind], cmdtab[i].label) == 0) { 139 1.1 ad if (cmdtab[i].takesargs == 0 && 140 1.1 ad argv[optind + 1] != NULL) 141 1.1 ad usage(); 142 1.1 ad (*cmdtab[i].func)(argv + optind + 1); 143 1.1 ad break; 144 1.1 ad } 145 1.1 ad 146 1.1 ad if (i == sizeof(cmdtab) / sizeof(cmdtab[0])) 147 1.8 ad errx(EXIT_FAILURE, "unknown command ``%s''", argv[optind]); 148 1.1 ad 149 1.1 ad close(fd); 150 1.1 ad exit(EXIT_SUCCESS); 151 1.1 ad /* NOTREACHED */ 152 1.1 ad } 153 1.1 ad 154 1.22 joerg static void 155 1.1 ad usage(void) 156 1.1 ad { 157 1.1 ad 158 1.1 ad (void)fprintf(stderr, "usage: %s [-f dev] <command> [target]\n", 159 1.7 cgd getprogname()); 160 1.1 ad exit(EXIT_FAILURE); 161 1.1 ad /* NOTREACHED */ 162 1.1 ad } 163 1.1 ad 164 1.22 joerg static int 165 1.1 ad show(const char *hdr, const char *fmt, ...) 166 1.1 ad { 167 1.1 ad int i; 168 1.1 ad va_list va; 169 1.1 ad 170 1.1 ad for (i = printf("%s", hdr); i < 25; i++) 171 1.1 ad putchar(' '); 172 1.1 ad va_start(va, fmt); 173 1.1 ad i += vprintf(fmt, va); 174 1.1 ad va_end(va); 175 1.1 ad putchar('\n'); 176 1.1 ad return (i); 177 1.1 ad } 178 1.1 ad 179 1.22 joerg static const char * 180 1.1 ad class2str(int class) 181 1.1 ad { 182 1.19 lukem size_t i; 183 1.1 ad 184 1.1 ad for (i = 0; i < sizeof(i2oclass) / sizeof(i2oclass[0]); i++) 185 1.1 ad if (class == i2oclass[i].class) 186 1.1 ad return (i2oclass[i].caption); 187 1.1 ad 188 1.1 ad return ("unknown"); 189 1.1 ad } 190 1.1 ad 191 1.22 joerg static void 192 1.1 ad getparam(int tid, int group, void *pbuf, int pbufsize) 193 1.1 ad { 194 1.1 ad struct ioppt pt; 195 1.1 ad struct i2o_util_params_op mb; 196 1.8 ad struct i2o_reply *rf; 197 1.1 ad struct { 198 1.1 ad struct i2o_param_op_list_header olh; 199 1.1 ad struct i2o_param_op_all_template oat; 200 1.15 perry } __packed req; 201 1.1 ad 202 1.1 ad mb.msgflags = I2O_MSGFLAGS(i2o_util_params_op); 203 1.1 ad mb.msgfunc = I2O_MSGFUNC(tid, I2O_UTIL_PARAMS_GET); 204 1.1 ad mb.flags = 0; 205 1.1 ad 206 1.1 ad req.olh.count = htole16(1); 207 1.1 ad req.olh.reserved = htole16(0); 208 1.1 ad req.oat.operation = htole16(I2O_PARAMS_OP_FIELD_GET); 209 1.1 ad req.oat.fieldcount = htole16(0xffff); 210 1.1 ad req.oat.group = htole16(group); 211 1.1 ad 212 1.1 ad pt.pt_msg = &mb; 213 1.1 ad pt.pt_msglen = sizeof(mb); 214 1.1 ad pt.pt_reply = buf; 215 1.1 ad pt.pt_replylen = sizeof(buf); 216 1.1 ad pt.pt_timo = 10000; 217 1.1 ad pt.pt_nbufs = 2; 218 1.1 ad 219 1.1 ad pt.pt_bufs[0].ptb_data = &req; 220 1.1 ad pt.pt_bufs[0].ptb_datalen = sizeof(req); 221 1.1 ad pt.pt_bufs[0].ptb_out = 1; 222 1.1 ad 223 1.1 ad pt.pt_bufs[1].ptb_data = pbuf; 224 1.1 ad pt.pt_bufs[1].ptb_datalen = pbufsize; 225 1.1 ad pt.pt_bufs[1].ptb_out = 0; 226 1.1 ad 227 1.1 ad if (ioctl(fd, IOPIOCPT, &pt) < 0) 228 1.1 ad err(EXIT_FAILURE, "IOPIOCPT"); 229 1.1 ad 230 1.8 ad rf = (struct i2o_reply *)buf; 231 1.10 ad if ((rf->msgflags & I2O_MSGFLAGS_FAIL) != 0) 232 1.10 ad errx(EXIT_FAILURE, "I2O_UTIL_PARAMS_GET failed (FAIL)"); 233 1.8 ad if (rf->reqstatus != 0) 234 1.1 ad errx(EXIT_FAILURE, "I2O_UTIL_PARAMS_GET failed (%d)", 235 1.20 christos rf->reqstatus); 236 1.1 ad } 237 1.1 ad 238 1.22 joerg static void 239 1.1 ad showlct(char **argv) 240 1.1 ad { 241 1.1 ad struct iovec iov; 242 1.1 ad struct i2o_lct *lct; 243 1.1 ad struct i2o_lct_entry *ent; 244 1.1 ad u_int32_t classid, usertid; 245 1.1 ad int i, nent; 246 1.1 ad char ident[sizeof(ent->identitytag) * 4 + 1]; 247 1.1 ad 248 1.1 ad iov.iov_base = buf; 249 1.1 ad iov.iov_len = sizeof(buf); 250 1.1 ad 251 1.1 ad if (ioctl(fd, IOPIOCGLCT, &iov) < 0) 252 1.1 ad err(EXIT_FAILURE, "IOPIOCGLCT"); 253 1.1 ad 254 1.1 ad lct = (struct i2o_lct *)buf; 255 1.1 ad ent = lct->entry; 256 1.1 ad nent = ((le16toh(lct->tablesize) << 2) - 257 1.1 ad sizeof(struct i2o_lct) + sizeof(struct i2o_lct_entry)) / 258 1.1 ad sizeof(struct i2o_lct_entry); 259 1.12 ad 260 1.12 ad show("flags", "0x%x", le16toh(lct->flags)); 261 1.12 ad show("iop flags", "0x%x", le32toh(lct->iopflags)); 262 1.12 ad show("lct change indicator", "%d", le32toh(lct->changeindicator)); 263 1.12 ad printf("\n"); 264 1.1 ad 265 1.1 ad for (i = 0; i < nent; i++, ent++) { 266 1.1 ad classid = le32toh(ent->classid); 267 1.1 ad usertid = le32toh(ent->usertid); 268 1.1 ad 269 1.1 ad show("lct entry", "%d", i); 270 1.1 ad show("entry size", "%d bytes", le16toh(ent->entrysize) << 2); 271 1.1 ad show("local tid", "%d", le16toh(ent->localtid) & 4095); 272 1.1 ad show("change indicator", "%d", le32toh(ent->changeindicator)); 273 1.1 ad show("flags", "%x", le32toh(ent->deviceflags)); 274 1.1 ad show("class id", "%x (%s)", classid & 4095, 275 1.1 ad class2str(classid & 4095)); 276 1.1 ad show("version", "%x", (classid >> 12) & 15); 277 1.1 ad show("organisation id", "%x", classid >> 16); 278 1.1 ad show("subclass info", "%x", le32toh(ent->subclassinfo)); 279 1.1 ad show("user tid", "%d", usertid & 4095); 280 1.1 ad show("parent tid", "%d", (usertid >> 12) & 4095); 281 1.1 ad show("bios info", "%d", (usertid >> 24) & 255); 282 1.1 ad i2ostrvis(ent->identitytag, sizeof(ent->identitytag), ident, 283 1.1 ad sizeof(ident)); 284 1.1 ad show("identity tag", "<%s>", ident); 285 1.1 ad show("event caps", "%x", le32toh(ent->eventcaps)); 286 1.1 ad 287 1.1 ad if (i != nent - 1) 288 1.1 ad printf("\n"); 289 1.1 ad } 290 1.1 ad } 291 1.1 ad 292 1.22 joerg static void 293 1.1 ad showstatus(char **argv) 294 1.1 ad { 295 1.1 ad char ident[sizeof(status.productid) + 1]; 296 1.1 ad u_int32_t segnumber; 297 1.1 ad 298 1.1 ad i2ostrvis(status.productid, sizeof(status.productid), 299 1.1 ad ident, sizeof(ident)); 300 1.1 ad 301 1.1 ad segnumber = le32toh(status.segnumber); 302 1.1 ad show("organization id", "%d", le16toh(status.orgid)); 303 1.1 ad show("iop id", "%d", le32toh(status.iopid) & 4095); 304 1.1 ad show("host unit id", "%d", (le32toh(status.iopid) >> 16)); 305 1.1 ad show("segment number", "%d", segnumber & 4095); 306 1.1 ad show("i2o version", "%d", (segnumber >> 12) & 15); 307 1.1 ad show("iop state", "%d", (segnumber >> 16) & 255); 308 1.1 ad show("messenger type", "%d", segnumber >> 24); 309 1.18 mhitch show("inbound frame sz", "%d", le16toh(status.inboundmframesize)); 310 1.1 ad show("init code", "%d", status.initcode); 311 1.1 ad show("max inbound queue depth", "%d", 312 1.1 ad le32toh(status.maxinboundmframes)); 313 1.1 ad show("inbound queue depth", "%d", 314 1.1 ad le32toh(status.currentinboundmframes)); 315 1.1 ad show("max outbound queue depth", "%d", 316 1.1 ad le32toh(status.maxoutboundmframes)); 317 1.1 ad show("product id string", "<%s>", ident); 318 1.1 ad show("expected lct size", "%d", le32toh(status.expectedlctsize)); 319 1.1 ad show("iop capabilities", "0x%08x", le32toh(status.iopcaps)); 320 1.1 ad show("desired priv mem sz", "0x%08x", 321 1.1 ad le32toh(status.desiredprivmemsize)); 322 1.1 ad show("current priv mem sz", "0x%08x", 323 1.1 ad le32toh(status.currentprivmemsize)); 324 1.1 ad show("current priv mem base", "0x%08x", 325 1.1 ad le32toh(status.currentprivmembase)); 326 1.1 ad show("desired priv io sz", "0x%08x", 327 1.1 ad le32toh(status.desiredpriviosize)); 328 1.1 ad show("current priv io sz", "0x%08x", 329 1.1 ad le32toh(status.currentpriviosize)); 330 1.1 ad show("current priv io base", "0x%08x", 331 1.1 ad le32toh(status.currentpriviobase)); 332 1.1 ad } 333 1.1 ad 334 1.22 joerg static void 335 1.1 ad showddmid(char **argv) 336 1.1 ad { 337 1.1 ad struct { 338 1.1 ad struct i2o_param_op_results pr; 339 1.1 ad struct i2o_param_read_results prr; 340 1.1 ad struct i2o_param_ddm_identity di; 341 1.9 ad char padding[128]; 342 1.15 perry } __packed p; 343 1.1 ad char ident[128]; 344 1.20 christos uint32_t serial[3]; 345 1.1 ad 346 1.11 ad getparam(gettid(argv), I2O_PARAM_DDM_IDENTITY, &p, sizeof(p)); 347 1.1 ad 348 1.1 ad show("ddm tid", "%d", le16toh(p.di.ddmtid) & 4095); 349 1.1 ad i2ostrvis(p.di.name, sizeof(p.di.name), ident, sizeof(ident)); 350 1.1 ad show("module name", "%s", ident); 351 1.1 ad i2ostrvis(p.di.revlevel, sizeof(p.di.revlevel), ident, sizeof(ident)); 352 1.1 ad show("module revision", "%s", ident); 353 1.1 ad show("serial # format", "%d", p.di.snformat); 354 1.21 dholland __CTASSERT(sizeof(serial) == sizeof(p.di.serialnumber)); 355 1.20 christos memcpy(serial, &p.di.serialnumber, sizeof(serial)); 356 1.20 christos show("serial #", "%08x%08x%08x", serial[0], serial[1], serial[2]); 357 1.1 ad } 358 1.1 ad 359 1.22 joerg static void 360 1.1 ad showdevid(char **argv) 361 1.1 ad { 362 1.1 ad struct { 363 1.1 ad struct i2o_param_op_results pr; 364 1.1 ad struct i2o_param_read_results prr; 365 1.1 ad struct i2o_param_device_identity di; 366 1.9 ad char padding[128]; 367 1.15 perry } __packed p; 368 1.1 ad char ident[128]; 369 1.1 ad 370 1.11 ad getparam(gettid(argv), I2O_PARAM_DEVICE_IDENTITY, &p, sizeof(p)); 371 1.1 ad 372 1.1 ad show("class id", "%d (%s)", le32toh(p.di.classid) & 4095, 373 1.1 ad class2str(le32toh(p.di.classid) & 4095)); 374 1.1 ad show("owner tid", "%d", le32toh(p.di.ownertid) & 4095); 375 1.1 ad show("parent tid", "%d", le32toh(p.di.parenttid) & 4095); 376 1.1 ad 377 1.1 ad i2ostrvis(p.di.vendorinfo, sizeof(p.di.vendorinfo), ident, 378 1.1 ad sizeof(ident)); 379 1.1 ad show("vendor", "<%s>", ident); 380 1.1 ad 381 1.1 ad i2ostrvis(p.di.productinfo, sizeof(p.di.productinfo), ident, 382 1.1 ad sizeof(ident)); 383 1.1 ad show("product", "<%s>", ident); 384 1.1 ad 385 1.1 ad i2ostrvis(p.di.description, sizeof(p.di.description), ident, 386 1.1 ad sizeof(ident)); 387 1.1 ad show("description", "<%s>", ident); 388 1.1 ad 389 1.1 ad i2ostrvis(p.di.revlevel, sizeof(p.di.revlevel), ident, sizeof(ident)); 390 1.1 ad show("revision level", "<%s>", ident); 391 1.1 ad } 392 1.1 ad 393 1.22 joerg static void 394 1.1 ad reconfig(char **argv) 395 1.1 ad { 396 1.1 ad 397 1.1 ad if (ioctl(fd, IOPIOCRECONFIG)) 398 1.1 ad err(EXIT_FAILURE, "IOPIOCRECONFIG"); 399 1.8 ad } 400 1.8 ad 401 1.22 joerg static void 402 1.8 ad showtidmap(char **argv) 403 1.8 ad { 404 1.8 ad struct iovec iov; 405 1.8 ad struct iop_tidmap *it; 406 1.8 ad int nent; 407 1.8 ad 408 1.8 ad iov.iov_base = buf; 409 1.8 ad iov.iov_len = sizeof(buf); 410 1.8 ad 411 1.8 ad if (ioctl(fd, IOPIOCGTIDMAP, &iov) < 0) 412 1.8 ad err(EXIT_FAILURE, "IOPIOCGTIDMAP"); 413 1.8 ad 414 1.8 ad nent = iov.iov_len / sizeof(*it); 415 1.8 ad it = (struct iop_tidmap *)buf; 416 1.8 ad 417 1.11 ad for (; nent-- != 0; it++) 418 1.8 ad if ((it->it_flags & IT_CONFIGURED) != 0) 419 1.8 ad printf("%s\ttid %d\n", it->it_dvname, it->it_tid); 420 1.1 ad } 421 1.1 ad 422 1.22 joerg static void 423 1.13 mrg i2ostrvis(const u_char *src, int slen, char *dst, int dlen) 424 1.1 ad { 425 1.1 ad int hc, lc, i, nit; 426 1.1 ad 427 1.1 ad dlen--; 428 1.1 ad lc = 0; 429 1.1 ad hc = 0; 430 1.1 ad i = 0; 431 1.1 ad 432 1.1 ad /* 433 1.1 ad * DPT use NUL as a space, whereas AMI use it as a terminator. The 434 1.1 ad * spec has nothing to say about it. Since AMI fields are usually 435 1.1 ad * filled with junk after the terminator, ... 436 1.1 ad */ 437 1.1 ad nit = (le16toh(status.orgid) != I2O_ORG_DPT); 438 1.1 ad 439 1.1 ad while (slen-- != 0 && dlen-- != 0) { 440 1.1 ad if (nit && *src == '\0') 441 1.1 ad break; 442 1.1 ad else if (*src <= 0x20 || *src >= 0x7f) { 443 1.1 ad if (hc) 444 1.1 ad dst[i++] = ' '; 445 1.1 ad } else { 446 1.1 ad hc = 1; 447 1.1 ad dst[i++] = *src; 448 1.1 ad lc = i; 449 1.1 ad } 450 1.1 ad src++; 451 1.1 ad } 452 1.1 ad 453 1.1 ad dst[lc] = '\0'; 454 1.11 ad } 455 1.11 ad 456 1.22 joerg static int 457 1.11 ad gettid(char **argv) 458 1.11 ad { 459 1.11 ad char *argp; 460 1.11 ad int tid; 461 1.11 ad 462 1.11 ad if (argv[1] != NULL) 463 1.11 ad usage(); 464 1.11 ad 465 1.11 ad tid = (int)strtol(argv[0], &argp, 0); 466 1.11 ad if (*argp != '\0') 467 1.11 ad usage(); 468 1.11 ad 469 1.11 ad return (tid); 470 1.1 ad } 471