1
2
3
4
5
6
7
8
9
10
11
12
13
14 truncate$trfile: proc (a_dirname, a_ename, a_addrs, a_code);
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 %page;
36
37
38
39 dcl a_addrs fixed bin (17) parameter;
40 dcl a_code fixed bin (35) parameter;
41 dcl a_dirname char (*) parameter;
42 dcl a_ename char (*) parameter;
43 dcl a_ep ptr parameter;
44 dcl a_segptr ptr parameter;
45
46
47
48 dcl addrs fixed bin (17);
49 dcl by_name bit (1) aligned init ("0"b);
50 dcl code fixed bin (35);
51 dcl ename char (32);
52 dcl esw fixed bin (17);
53 dcl fpage fixed bin (17);
54 dcl overlay_size fixed bin;
55 dcl parent char (168);
56 dcl segptr ptr;
57 dcl write_lock bit (36) aligned init ((36)"1"b);
58
59
60
61 dcl overlay bit (overlay_size) based aligned;
62
63
64
65 dcl error_table_$argerr fixed bin (35) external;
66 dcl error_table_$boundviol fixed bin (35) external;
67 dcl error_table_$dirseg fixed bin (35) external;
68 dcl error_table_$rqover fixed bin (35) external;
69 dcl pds$processid bit (36) aligned ext;
70
71
72
73 dcl get_kstep entry (fixed bin (18), ptr, fixed bin (35));
74 dcl initiate entry (char (*), char (*), char (*), fixed bin (1), fixed bin (2), ptr, fixed bin (35));
75 dcl lock$dir_unlock entry (ptr);
76 dcl mountedp entry (bit (36) aligned) returns (fixed bin (35));
77 dcl sum$dirmod entry (ptr);
78 dcl terminate_$noname entry (ptr, fixed bin (35));
79 dcl truncate_vtoce entry (ptr, fixed bin, fixed bin (35));
80
81
82
83 dcl (addrel, baseno, divide, fixed, null, ptr) builtin;
84
85 dcl out_of_bounds condition;
86 %page;
87 esw = 0;
88 code = 0;
89 addrs = a_addrs;
90 parent = a_dirname;
91 ename = a_ename;
92 call dc_find$obj_truncate (parent, ename, ep, code);
93 dp = ptr (ep, 0);
94 if code ^= 0 then go to finale;
95 by_name = "1"b;
96 go to join;
97
98 trseg: entry (a_segptr, a_addrs, a_code);
99
100 esw = 1;
101 code = 0;
102 addrs = a_addrs;
103 segptr = ptr (a_segptr, 0);
104
105 call get_kstep (fixed (baseno (segptr)), kstep, code);
106 if code ^= 0 then go to finale;
107
108 if kste.priv_init then call dc_find$obj_truncate_raw_ptr (segptr, ep, code);
109 else call dc_find$obj_truncate_ptr (segptr, ep, code);
110 if code ^= 0 then go to finale;
111 dp = ptr (ep, 0);
112
113 join: if ep -> entry.dirsw then do;
114 code = error_table_$dirseg;
115 go to unlock;
116 end;
117
118 if addrs < 0 then do;
119 code = error_table_$argerr;
120 go to unlock;
121 end;
122
123
124 fpage = divide (addrs + 1023, 1024, 17, 0);
125
126 go to join1;
127
128 trentry: entry (a_ep);
129
130 esw = 2;
131 fpage = 0;
132 ep = a_ep;
133 code = 0;
134 dp = ptr (ep, 0);
135 join1:
136
137 code = mountedp (dir.sons_lvid);
138 if code = 0
139 then do;
140 dir.modify = pds$processid;
141
142 call truncate_vtoce (ep, fpage, code);
143
144 if code ^= 0 then if code = error_table_$rqover then code = 0;
145 end;
146 if esw = 2 then return;
147
148
149 dir.modify = "0"b;
150 call sum$dirmod (dp);
151 if by_name
152 then call dc_find$finished (dp, "1"b);
153 else call lock$dir_unlock (dp);
154
155
156
157
158
159
160 if code ^= 0 then go to finale;
161
162 on condition (out_of_bounds) go to boundviol;
163
164 overlay_size = (fpage * 1024 - addrs) * 36;
165 if overlay_size ^= 0 then do;
166 if esw = 0 then do;
167 call initiate (parent, ename, "", 0, 1, segptr, code);
168 if segptr = null then goto finale;
169 code = 0;
170 end;
171 addrel (segptr, addrs) -> overlay = ""b;
172 if esw = 0 then call terminate_$noname (segptr, code);
173 end;
174
175 finale: a_code = code;
176 return;
177
178 unlock: if dir.modify then dir.modify = "0"b;
179 if by_name
180 then call dc_find$finished (dp, "1"b);
181 else call lock$dir_unlock (dp);
182 go to finale;
183
184 boundviol:
185 a_code = error_table_$boundviol;
186 return;
187 %page;
188 %page; %include dc_find_dcls;
189 %page; %include dir_entry;
190 %page; %include dir_header;
191 %page; %include kst;
192 end;