1
2
3
4
5
6
7
8
9
10
11
12 print_devices: proc;
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 dcl argp ptr;
41 dcl arglen fixed bin;
42 dcl arg char (arglen) based (argp);
43
44 dcl bfsw bit (1) aligned;
45 dcl rqt_found bit (1) aligned;
46 dcl an_found bit (1) aligned;
47 dcl select bit (1) aligned;
48 dcl match bit (1) aligned;
49 dcl accname char (32) aligned;
50 dcl req_type char (32) aligned;
51 dcl rqt_name char (32) aligned;
52 dcl dev_name char (32) aligned;
53 dcl sysdir char (168) aligned;
54 dcl ent_name char (32) aligned;
55
56 dcl (i, j, k) fixed bin;
57 dcl did_len fixed bin;
58 dcl code fixed bin (35);
59 dcl star char (1) aligned;
60 dcl count fixed bin;
61 dcl nargs fixed bin;
62
63 dcl system_high bit (72) aligned;
64 dcl auth_string char (170);
65
66 dcl whoami char (13) aligned int static init ("print_devices");
67
68 dcl error_table_$badopt fixed bin (35) ext;
69
70 dcl (addr, substr, ptr, null, before, rtrim, length) builtin;
71
72 dcl cu_$arg_ptr entry (fixed bin, ptr, fixed bin, fixed bin (35));
73 dcl cu_$arg_count entry (fixed bin);
74 dcl com_err_ entry options (variable);
75 dcl expand_pathname_ entry (char (*), char (*) aligned, char (*) aligned, fixed bin (35));
76 dcl hcs_$initiate entry (char (*) aligned, char (*), char (*), fixed bin (1), fixed bin (2), ptr, fixed bin (35));
77 dcl ioa_ entry options (variable);
78 dcl hcs_$terminate_noname entry (ptr, fixed bin (35));
79 dcl convert_authorization_$to_string_short entry (bit (72) aligned, char (*), fixed bin (35));
80 dcl system_info_$access_ceiling entry (bit (72) aligned);
81 %page;
82
83
84
85 bfsw = "0"b;
86 an_found, rqt_found = "1"b;
87 accname, req_type = "";
88 sysdir = ">daemon_dir_dir>io_daemon_dir";
89
90
91
92 call cu_$arg_count (nargs);
93
94 do i = 1 to nargs;
95 call cu_$arg_ptr (i, argp, arglen, code);
96 if code ^= 0 then go to noarg;
97 if arg = "-bf" | arg = "-brief" then bfsw = "1"b;
98 else if arg = "-an" | arg = "-access_name" then do;
99 i = i + 1;
100 call cu_$arg_ptr (i, argp, arglen, code);
101 if code ^= 0 then do;
102 noarg: call com_err_ (code, whoami);
103 return;
104 end;
105 accname = arg;
106 an_found = "0"b;
107 end;
108 else if arg = "-rqt" | arg = "-request_type" then do;
109 i = i + 1;
110 call cu_$arg_ptr (i, argp, arglen, code);
111 if code ^= 0 then go to noarg;
112 req_type = arg;
113 rqt_found = "0"b;
114 end;
115 else if arg = "-dir" | arg = "-directory" then do;
116 i = i + 1;
117 call cu_$arg_ptr (i, argp, arglen, code);
118 if code ^= 0 then go to noarg;
119 call expand_pathname_ (arg, sysdir, ent_name, code);
120 if code ^= 0 then do;
121 call com_err_ (code, whoami, arg);
122 return;
123 end;
124 if sysdir = ">" then sysdir = ">" || ent_name;
125 else sysdir = rtrim (sysdir) || ">" || ent_name;
126 end;
127 else do;
128 call com_err_ (error_table_$badopt, whoami, arg);
129 return;
130 end;
131 end;
132
133 select = ^(an_found & rqt_found);
134
135
136
137 call hcs_$initiate (sysdir, "iod_working_tables", "", 0, 1, ithp, code);
138 if ithp = null then do;
139 call com_err_ (code, whoami, "^a>iod_working_tables", sysdir);
140 return;
141 end;
142
143 if iod_tables_hdr.version ^= IODT_VERSION_5 then do;
144 call com_err_ (0, whoami, "Wrong version number for iod_working_tables.");
145 return;
146 end;
147
148 idtp = ptr (ithp, iod_tables_hdr.device_tab_offset);
149 mdtp = ptr (ithp, iod_tables_hdr.minor_device_tab_offset);
150 dctp = ptr (ithp, iod_tables_hdr.dev_class_tab_offset);
151 qgtp = ptr (ithp, iod_tables_hdr.q_group_tab_offset);
152
153
154
155 call system_info_$access_ceiling (system_high);
156 count = 0;
157
158 do i = 1 to q_group_tab.n_q_groups;
159 qgtep = addr (q_group_tab.entries (i));
160 did_len = length (before (qgte.driver_id, ".*"));
161
162 if select then do;
163 match = "1"b;
164 if req_type ^= "" then
165 if req_type = qgte.name then rqt_found = "1"b;
166 else match = "0"b;
167 if accname ^= "" then
168 if accname = substr (qgte.driver_id, 1, did_len) then an_found = "1"b;
169 else match = "0"b;
170 if ^match then go to next;
171 end;
172
173 do j = qgte.first_dev_class to qgte.last_dev_class;
174 dctep = addr (dev_class_tab.entries (j));
175
176 do k = 1 to minor_device_tab.n_minor;
177 count = count + 1;
178 if substr (dcte.device_list, k, 1) then do;
179 mdtep = addr (minor_device_tab.entries (k));
180 idtep = addr (iod_device_tab.entries (mdte.major_index));
181 dev_name = idte.dev_id;
182 if idte.last_minor > idte.first_minor
183 | dev_name ^= mdte.dev_id then
184 dev_name = rtrim (dev_name) || "." || mdte.dev_id;
185 if mdte.default_dev_class = j then star = "*";
186 else star = " ";
187
188 if count = 1 then
189 if ^bfsw then call ioa_ ("^/ Device^-^-Request type^-Access name^/");
190
191 if substr (dcte.device_list, 1, k - 1) = ""b then do;
192 rqt_name = qgte.name;
193 if qgte.last_dev_class > qgte.first_dev_class
194 | rqt_name ^= dcte.id then
195 rqt_name = rtrim (rqt_name) || "." || dcte.id;
196
197 auth_string = "";
198 call convert_authorization_$to_string_short (dcte.max_access, auth_string, code);
199 if auth_string ^= "" then
200 if dcte.max_access = system_high then auth_string = "system_high";
201
202 call ioa_ ("^1a ^18a^20a^20a^a", star, dev_name, rqt_name,
203 substr (qgte.driver_id, 1, did_len), auth_string);
204 end;
205 else call ioa_ ("^1a ^a", star, dev_name);
206 end;
207 end;
208 end;
209 next: end;
210
211 if ^rqt_found then call com_err_ (0, whoami, "Request type not found: ^a", req_type);
212 if ^an_found then call com_err_ (0, whoami, "Access name not found: ^a", accname);
213 if rqt_found & an_found then
214 if count = 0 then call com_err_ (0, whoami, "No devices.");
215 else call ioa_ ("");
216
217 call hcs_$terminate_noname (ithp, code);
218 %page; %include device_class;
219 %page; %include iod_device_tab;
220 %page; %include iod_tables_hdr;
221 %page; %include q_group_tab;
222
223 end print_devices;