1 /****^  ***********************************************************
  2         *                                                         *
  3         * Copyright, (C) Honeywell Bull Inc., 1987                *
  4         *                                                         *
  5         * Copyright, (C) Honeywell Information Systems Inc., 1982 *
  6         *                                                         *
  7         *********************************************************** */
  8 
  9 /* format: style2 */
 10 
 11 init_partitions:
 12      proc ();
 13 
 14 /* format: off */
 15 
 16 /* *      This procedure reads all the PART cards in the config deck, checks them against
 17    *      pack labels,
 18    *      This used to be in init_pvt.
 19    *
 20    *      11/28/80, W. Olin Sibert
 21    *      7/82 BIM remove fixed bin (9), merge with stocks etc.
 22    *         and flush wired_hardcore_data stuff.
 23    *      '82 for english error codes
 24    */
 25 
 26 /****^  HISTORY COMMENTS:
 27   1) change(86-01-15,Fawcett), approve(86-04-11,MCR7383),
 28      audit(86-07-07,GDixon), install(86-07-17,MR12.0-1097):
 29      Change the format of part card for subvolumes.
 30   2) change(86-06-05,GJohnson), approve(86-06-05,MCR7387),
 31      audit(86-06-10,Martinson), install(86-07-17,MR12.0-1091):
 32      Correct error message documentation.
 33   3) change(88-03-05,Beattie), approve(88-05-31,MCR7864),
 34      audit(88-05-13,Brunelle), install(88-05-31,MR12.2-1046):
 35      Initialize pointer to pvte earlier so error messages will work.
 36                                                    END HISTORY COMMENTS */
 37 
 38 /* format: on */
 39 
 40           dcl     P99                    picture "99" based;
 41           dcl     pvtx                   fixed bin;
 42           dcl     part_id                char (4) aligned;  /* System-defined name of partition */
 43           dcl     part_name              char (4) aligned;  /* Name of partition to use on this pack */
 44           dcl     part_idx               fixed bin;
 45           dcl     code                   fixed bin (35);
 46           dcl     problem                char (64);
 47           dcl     drive_no               fixed bin;
 48           dcl     sv_no                  fixed bin;
 49           dcl     sv_idx                 fixed bin;
 50           dcl     label_buffer           (512) fixed bin (71) automatic;
 51                                                             /* Buffer for label reading */
 52 
 53           dcl     config_$find           entry (char (4) aligned, pointer);
 54           dcl     read_disk_label        entry (fixed bin, ptr, char (*), fixed bin (35));
 55           dcl     syserr                 entry options (variable);
 56           dcl     syserr$error_code      entry options (variable);
 57 
 58           dcl     VALID_NUMBERS          char (10) int static options (constant) init ("0123456789");
 59           dcl     WHOAMI                 char (32) internal static options (constant) init ("init_partitions:");
 60 
 61           dcl     (addr, bin, convert, index, null, rtrim, substr, verify)
 62                                          builtin;
 63 ^L
 64 
 65           labelp = addr (label_buffer);
 66           pvtp = addr (pvt$);
 67           pvt_arrayp = addr (pvt.array);
 68 
 69           part_cardp = null ();
 70 GET_NEXT_PART_CARD:
 71           call config_$find (PART_CARD_WORD, part_cardp);
 72           if part_cardp = null ()
 73           then goto FOUND_ALL_PART_CARDS;                   /* All done */
 74 
 75           part_id = part_card.name;                         /* Find out which partition this is defining */
 76 
 77           if part_card.n_fields = 4
 78           then part_name = part_card.real_name;             /* Possibly the partition being defined actually */
 79                                                             /* has a different name, so check first */
 80           else part_name = part_id;                         /* But if none specified, then it's the same as the ID */
 81 
 82           if part_card.n_fields > 4
 83           then call syserr (BEEP, "^a Ignoring ""^a ^d."" on ^a part card.", WHOAMI, cold_part_card.highlow,
 84                     cold_part_card.nrec, part_id);          /* Complain if this is a leftover cold boot card */
 85 
 86           sv_idx = verify (rtrim (part_card.drive), VALID_NUMBERS);
 87                                                             /* check for non-numeric character */
 88           if sv_idx = 0
 89           then do;                                          /* non-subvolume device */
 90                     drive_no = bin (part_card.drive, 17);
 91                     sv_no = -1;
 92                end;
 93           else if sv_idx > 1
 94           then do;                                          /* possible subvolume device */
 95                     drive_no = bin (substr (part_card.drive, 1, sv_idx - 1), 17);
 96                     sv_no = index (valid_sv_string, substr (rtrim (part_card.drive), sv_idx)) - 1;
 97                     if sv_no = -1                           /* bad subvolume indicator */
 98                     then goto invalid_drive;
 99                end;
100           else do;                                          /* no valid drive number */
101 invalid_drive:
102                     call syserr (CRASH, "^a: Invalid device, ^a_^a, on ^a part card.", WHOAMI, part_card.subsystem,
103                          part_card.drive, part_id);
104                     goto GET_NEXT_PART_CARD;                /* In case someone types GO */
105                end;
106 
107           do pvtx = 1 to pvt.n_entries
108                while (pvt_array (pvtx).devname ^= part_card.subsystem | pvt_array (pvtx).logical_area_number ^= drive_no
109                | pvt_array (pvtx).sv_num ^= sv_no);         /* Now, try to find the right volume */
110           end;
111 
112           if pvtx > pvt.n_entries
113           then do;                                          /* Sorry, not there */
114                     call syserr (CRASH, "^a Unable to locate ^a_^a for ^a partition.", WHOAMI, part_card.subsystem,
115                          part_card.drive, part_id);
116                     goto GET_NEXT_PART_CARD;                /* In case someone types GO */
117                end;
118 
119 READ_LABEL:
120           call read_disk_label (pvtx, labelp, problem, code);
121           if code ^= 0
122           then do;
123                     call syserr$error_code (CRASH, code, "Error reading ^a_^a label. ^a", WHOAMI, part_card.subsystem,
124                          part_card.drive, problem);
125                     goto READ_LABEL;                        /* retry label read if GO typed */
126                end;
127 
128           pvtep = addr (pvt_array (pvtx));
129 
130           if label.nparts = 0
131           then do;
132                     call syserr (CRASH, "^a There are no partitions in the label for ^a_^a^[^a^;^s^] (pvtx ^d).", WHOAMI,
133                          pvte.devname, convert (P99, pvte.logical_area_number), pvte.is_sv, pvte.sv_name, pvtx);
134                     goto GET_NEXT_PART_CARD;                /* In case someone types GO */
135                end;
136 
137           do part_idx = 1 to label.nparts while (part_name ^= label.parts (part_idx).part);
138                                                             /* Search the label for the one we want */
139           end;
140 
141           if part_idx > label.nparts
142           then do;
143                     call syserr (CRASH, "^a part ^a^[ for part ^a^;^s^] not in label of ^a_^a^[^a^;^s^] (pvtx ^d)",
144                          WHOAMI, part_name, (part_name ^= part_id), part_id, pvte.devname,
145                          convert (P99, pvte.logical_area_number), pvte.is_sv, pvte.sv_name, pvtx);
146                     goto GET_NEXT_PART_CARD;                /* In case someone types GO */
147                end;
148 
149           pvte.permanent = "1"b;                            /* Protect it against demounting */
150 
151           goto GET_NEXT_PART_CARD;
152 ^L
153 
154 /* We come here when all is done. By rights, we ought to complain about missing
155    required partitions here, but that logic isn't designed yet.
156    */
157 
158 FOUND_ALL_PART_CARDS:
159           return;                                           /* All done */
160 %page;
161 %include pvt;
162 %page;
163 %include pvte;
164 %page;
165 %include fs_dev_types;
166 %page;
167 %include fs_vol_label;
168 %page;
169 %include config_part_card;
170 %page;
171 %include syserr_constants;
172 
173 /* BEGIN MESSAGE DOCUMENTATION
174 
175 Message:
176 init_partitions: Ignoring COLD_SPEC on PART_NAME part card.
177 
178 S:     $beep
179 
180 T:     $init
181 
182 M:     Cold boot partition specifications were found for partition
183 PART_NAME, and will be ignored.
184 
185 Message:
186 init_partitions: Invalid device, DISK_DRIVE, on PART_NAME part card.
187 
188 S:     $crash
189 
190 T:     $init
191 
192 M:     An invalid drive definition has been found for the PART_NAME
193 part card.
194 
195 A:     Fix PART card.
196 
197 Message:
198 init_partitions: Unable to locate DISK_DRIVE for PART_NAME partition.
199 
200 S:     $crash
201 
202 T:     $init
203 
204 M:     Partition PART_NAME is specified in the config deck for a non
205 existent DISK_DRIVE.
206 
207 A:     Fix PART and/or PRPH DSK cards.
208 
209 Message:
210 init_partitions: Error reading DISK_DRIVE label. PROBLEM ERROR_MESSAGE
211 
212 S:     $crash
213 
214 T:     $init
215 
216 M:     An error has been detected attempting to read the label
217 of DISK_DRIVE.
218 
219 A:     Correct problem and type "go" to retry the read.
220 
221 Message:
222 init_partition: There are no partitions in the label for DISK_DRIVE (pvtx PVTX).
223 
224 S:    $crash
225 
226 T:    $init
227 
228 M:    DISK_DRIVE has been specified on a part card, but has no partitions
229 defined in its label.
230 
231 A:    Fix the config deck.
232 
233 Message:
234 init_partition: part PART_NAME not in label of DISK_DRIVE (pvtx PVTX).
235 
236 S:    $crash
237 
238 T:    $init
239 
240 M:    A PART card specified DISK_DRIVE as the location of partition PART_NAME,
241 but the label of DISK_DRIVE does not define it.
242 
243 A:    Fix the config deck.
244 
245 Message:
246 init_partition: part PART_NAME for part PART_ID not in label of DISK_DRIVE (pvtx PVTX).
247 
248 S:    $crash
249 
250 T:    $init
251 
252 M:    A PART card specified DISK_DRIVE as the location of partition PART_NAME,
253 but the label of DISK_DRIVE does not define it.
254 
255 A:    Fix the config deck.
256 
257 END MESSAGE DOCUMENTATION */
258 
259      end init_partitions;