|
|
1.1 root 1: #include <stdio.h>
2: #include "../scsi.h"
3: #include "../scsish.h"
4: #include "../tcl.h"
5: #include "fns.h"
6: #include "wren.h"
7:
8: static Wren *types[] =
9: {
10: &wr_elite,
11: &wr_wren5,
12: 0
13: };
14:
15: static Wren *curtype = 0;
16:
17: static int
18: setwren(char *err)
19: {
20: int n;
21: char product[17];
22: int found;
23: struct scsi_cmd cmd;
24: struct scsi_return ret;
25:
26: /* find drive type */
27: set6(cmd, 0x12, 0, 0, 0, 32, 0);
28: if(s_io(0, &cmd, 0, &ret, 32, err))
29: return(-1);
30: fixedstr(&ret.data[16], 16, product);
31: for(n = 0, found = 0; types[n]; n++)
32: if(strcmp(product, types[n]->ident) == 0){
33: found = 1;
34: break;
35: }
36: if(found){
37: if(types[n] != curtype){
38: curtype = types[n];
39: printf("drive is a %s (%s)\n",
40: curtype->desc, curtype->ident);
41: }
42: } else {
43: curtype = types[0];
44: printf("drive is '%s'; pretending it's a %s\n",
45: product, curtype->desc);
46: }
47: return(0);
48: }
49:
50: int wr_modesense(ClientData cd, Tcl_Interp *it, int argc, char **argv)
51: {
52: if(setwren(cd->err))
53: ERR_RETURN
54: if(curtype->msense == 0){
55: strcpy(cd->err, "modesense not implemented");
56: ERR_RETURN
57: }
58: if((*curtype->msense)(cd, argc, argv))
59: ERR_RETURN
60: return(TCL_OK);
61: }
62:
63: int wr_modeselect(ClientData cd, Tcl_Interp *it, int argc, char **argv)
64: {
65: if(setwren(cd->err))
66: ERR_RETURN
67: if(curtype->mselect == 0){
68: strcpy(cd->err, "modeselect not implemented");
69: ERR_RETURN
70: }
71: if((*curtype->mselect)(cd, argc, argv))
72: ERR_RETURN
73: return(TCL_OK);
74: }
75:
76: int wr_diag(ClientData cd, Tcl_Interp *it, int argc, char **argv)
77: {
78: if(setwren(cd->err))
79: ERR_RETURN
80: if(curtype->diag == 0){
81: strcpy(cd->err, "diagnostics not implemented");
82: ERR_RETURN
83: }
84: if((*curtype->diag)(cd, argc, argv))
85: ERR_RETURN
86: return(TCL_OK);
87: }
88:
89: int wr_logsense(ClientData cd, Tcl_Interp *it, int argc, char **argv)
90: {
91: if(setwren(cd->err))
92: ERR_RETURN
93: if(curtype->lsense == 0){
94: strcpy(cd->err, "logging not implemented");
95: ERR_RETURN
96: }
97: if((*curtype->lsense)(cd, argc, argv))
98: ERR_RETURN
99: return(TCL_OK);
100: }
101:
102: int wr_logselect(ClientData cd, Tcl_Interp *it, int argc, char **argv)
103: {
104: if(setwren(cd->err))
105: ERR_RETURN
106: if(curtype->lselect == 0){
107: strcpy(cd->err, "logging not implemented");
108: ERR_RETURN
109: }
110: if((*curtype->lselect)(cd, argc, argv))
111: ERR_RETURN
112: return(TCL_OK);
113: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.