1 /****^  ***********************************************************
  2         *                                                         *
  3         * Copyright, (C) Honeywell Bull Inc., 1988                *
  4         *                                                         *
  5         * Copyright, (C) Honeywell Information Systems Inc., 1982 *
  6         *                                                         *
  7         * Copyright (c) 1972 by Massachusetts Institute of        *
  8         * Technology and Honeywell Information Systems, Inc.      *
  9         *                                                         *
 10         *********************************************************** */
 11 
 12 print_devices: proc;
 13 
 14 /* This command prints a list of devices for each request type
 15    handled by the IO daemon as determined by inspecting the
 16    iod_working_tables segment.  If more than one device class
 17    is defined for a request type, then the device classes
 18    are treated separately.  For each request type, the
 19    associated driver access name and authorization is
 20    printed.  An asterisk is placed immediately before a device
 21    name if the corresponding request type (device class) is
 22    the default for the device.
 23 */
 24 
 25 /* Written by J. Stern, 5/9/75 */
 26 /* Modified by J. C. Whitmore, 4/78, for new iod_tables format */
 27 /* Modified by J. C. Whitmore, 10/78, to use version 3 iod_tables */
 28 /* Modified by E. N. Kittlitz, 6/81, to use version 4 iod_tables */
 29 
 30 
 31 /****^  HISTORY COMMENTS:
 32   1) change(88-06-03,Brunelle), approve(88-06-03,MCR7911),
 33      audit(88-10-18,Wallman), install(88-10-28,MR12.2-1199):
 34      Upgraded to handle version 5 I/O daemon tables.  Also displays comments
 35      store in the major and minor device entries.  Display columns are based
 36      on length of longest entry for each column.
 37                                                    END HISTORY COMMENTS */
 38 
 39 
 40           dcl     argp                   ptr;               /* ptr to arg */
 41           dcl     arglen                 fixed bin;         /* length of arg */
 42           dcl     arg                    char (arglen) based (argp); /* command argument */
 43 
 44           dcl     bfsw                   bit (1) aligned;   /* ON for brief option */
 45           dcl     rqt_found              bit (1) aligned;   /* ON if desired request type found */
 46           dcl     an_found               bit (1) aligned;   /* ON if desired access name found */
 47           dcl     select                 bit (1) aligned;   /* ON if selecting subset of request types */
 48           dcl     match                  bit (1) aligned;   /* ON if request type or access name matched */
 49           dcl     accname                char (32) aligned; /* access name */
 50           dcl     req_type               char (32) aligned; /* request type name */
 51           dcl     rqt_name               char (32) aligned; /* request type name */
 52           dcl     dev_name               char (32) aligned; /* device name */
 53           dcl     sysdir                 char (168) aligned;/* directory containing iod_working_tables */
 54           dcl     ent_name               char (32) aligned;
 55 
 56           dcl     (i, j, k)              fixed bin;
 57           dcl     did_len                fixed bin;         /* driver id length */
 58           dcl     code                   fixed bin (35);    /* error code */
 59           dcl     star                   char (1) aligned;  /* to indicate default request type for device */
 60           dcl     count                  fixed bin;         /* count of queue groups printed */
 61           dcl     nargs                  fixed bin;
 62 
 63           dcl     system_high            bit (72) aligned;  /* system high access authorization */
 64           dcl     auth_string            char (170);        /* authorization string */
 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 /* initialize control argument defaults */
 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 /* look for arguments */
 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); /* take apart and put it back together */
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 /* get a pointer to the iod_working_tables */
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 /* print the table */
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, ".*")); /* compiler ensures it ends with ".*" */
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_ ("");                         /* throw in an extra blank line */
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;