X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=contrib%2Fgsc%2Ftstinq.c;fp=contrib%2Fgsc%2Ftstinq.c;h=bea4dde360b90c5e3143000df733046f228b3431;hb=1194fb66aa28d9929c3f2bef3cc6c1c3f40a60a4;hp=0000000000000000000000000000000000000000;hpb=2df780bff19c457b0debb7adc29972a0bc2a5dc2;p=debian%2Famanda diff --git a/contrib/gsc/tstinq.c b/contrib/gsc/tstinq.c new file mode 100644 index 0000000..bea4dde --- /dev/null +++ b/contrib/gsc/tstinq.c @@ -0,0 +1,90 @@ +/* + * %W% %G% + * $Id: tstinq.c,v 1.1 2001/04/15 11:12:37 ant Exp $ + * Copyright (c) 1997 by Matthew Jacob + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; version 2. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * The author may be reached via electronic communications at + * + * mjacob@feral.com + * + * or, via United States Postal Address + * + * Matthew Jacob + * 1831 Castro Street + * San Francisco, CA, 94131 + */ + +#include +#include +#include "gscdds.h" + +static void process(char *, int); + +int +main(int a, char **v) +{ + int fd; + + while (*++v) { + fd = open(*v, 0); + if (fd < 0) { + perror(*v); + continue; + } + process(*v, fd); + (void) close(fd); + } + return (0); +} + +static void +process(char *name, int fd) +{ + scmd_t scmd; + char sb[32], iqd[256], sbyte, c, dt; + static char cdb[6] = { 0x12, 0, 0, 0, 255, 0 }; + + scmd.cdb = cdb; + scmd.cdblen = sizeof (cdb); + scmd.data_buf = iqd; + scmd.datalen = 255; + scmd.sense_buf = sb; + scmd.senselen = sizeof (sb); + scmd.statusp = &sbyte; + scmd.rw = 1; + scmd.timeval = 5; + + if (ioctl(fd, GSC_CMD, (caddr_t) &scmd) < 0) { + perror("GSC_CMD"); + return; + } + dt = iqd[0] & 0x1f; + c = iqd[8+28]; + iqd[8+28] = 0; + (void) fprintf(stdout, "%s:%-28s|Device Type %d\n", name, &iqd[8], dt); +} +/* + * mode: c + * Local variables: + * c-indent-level: 4 + * c-brace-imaginary-offset: 0 + * c-brace-offset: -4 + * c-argdecl-indent: 4 + * c-label-offset: -4 + * c-continued-statement-offset: 4 + * c-continued-brace-offset: 0 + * End: + */