1 
  2 
  3 
  4 
  5 
  6 
  7 
  8 
  9 
 10 
 11 
 12 
 13 
 14 backup_util: proc (dname, ename);
 15 
 16 
 17 
 18 
 19 
 20 
 21 
 22 
 23 
 24 
 25 
 26 
 27 dcl (dname character (168),                                 
 28      ename character (32)) aligned;                         
 29 
 30 
 31 dcl (i, j, k, l) fixed bin,                                 
 32      a_code fixed bin,                                      
 33      code fixed bin,                                        
 34      access_class bit (72) aligned,                         
 35      esw fixed bin,                                         
 36      area_ptr ptr,                                          
 37      ix pointer;                                            
 38 
 39 dcl (error_table_$moderr, error_table_$user_not_found, error_table_$nonamerr,
 40      error_table_$logical_volume_not_connected, error_table_$vtoce_connection_fail,
 41      error_table_$logical_volume_not_defined,
 42      error_table_$noentry, error_table_$bad_ring_brackets, error_table_$incorrect_access, error_table_$no_info,
 43      error_table_$fulldir, error_table_$segnamedup, error_table_$namedup, error_table_$safety_sw_on,
 44      error_table_$copy_sw_on) fixed bin ext;
 45 
 46 dcl  init static bit (1) initial ("1"b),                    
 47      group_id static character (32) aligned;                
 48 
 49 dcl 1 name (1) based (np) aligned,
 50     2 size bit (17),
 51     2 string character (32);
 52 
 53 dcl 1 stat_area,                                            
 54     2 (pad1 bit (18),
 55      nrp bit (18),
 56      pad2 bit (108)) unaligned;
 57 
 58 dcl  names (1) char (32) based;                             
 59 
 60 dcl (oldp, newp) ptr,                                       
 61     (oldn based (oldp), newn based (newp)) char (168),
 62      newl fixed bin;                                        
 63 
 64 dcl (dir, work) char (168), ent char (32);                  
 65 
 66 dcl  backup_map_$fs_error_line entry (fixed bin, char (*) aligned, char (168) aligned, char (32) aligned),
 67      backup_map_$name_line entry (pointer, fixed binary),
 68      backup_load_dir_list$build_tree entry (char (*) aligned, char (*) aligned, fixed bin,
 69      fixed bin (24), fixed bin (2), char (*) aligned, bit (72) aligned, fixed bin),
 70     (backup_util$delete_name, backup_util$give_access) entry (char (168) aligned, char (32) aligned, fixed bin);
 71 
 72 dcl  get_group_id_ entry returns (character (32)),
 73      get_system_free_area_ entry returns (ptr),
 74      hcs_$add_acl_entries entry (char (*) aligned, char (*) aligned, ptr, fixed bin, fixed bin),
 75      hcs_$add_dir_acl_entries entry (char (*) aligned, char (*) aligned, ptr, fixed bin, fixed bin),
 76      hcs_$status_minf entry (char (*) aligned, char (*) aligned, fixed bin (1), fixed bin (2), fixed bin (24), fixed bin),
 77      hcs_$chname_file entry (char (*) aligned, char (*) aligned, char (*) aligned, char (*) aligned, fixed binary),
 78     (hcs_$del_dir_tree, hcs_$delentry_file) entry (char (*) aligned, char (*) aligned, fixed binary),
 79      hcs_$status_ entry (char (*), char (*), fixed bin (1), ptr, ptr, fixed bin),
 80      hcs_$get_access_class entry (char (*) aligned, char (*) aligned, bit (72) aligned, fixed bin),
 81      hcs_$set_copysw entry (char (*) aligned, char (*) aligned, bit (1), fixed bin),
 82      hcs_$set_safety_sw entry (char (*) aligned, char (*) aligned, bit (1), fixed bin);
 83 
 84 
 85 dcl (addr, empty, fixed, index, length, min, pointer, substr, rtrim) builtin;
 86 
 87 %include bk_ss_;
 88 %include acl_structures;
 89  ^L
 90 add_names: entry (dname, ename, np, nnames, list_names);    
 91 
 92 dcl  np ptr,                                                
 93      nnames fixed bin,                                      
 94      list_names bit (1);                                    
 95           do i = 1 to nnames;
 96                ix = addr (np -> name (i));                  
 97                if (ename ^= ix -> name(1).string) then do;  
 98                     if bk_ss_$no_reload then go to print_name;   
 99 add:                call hcs_$chname_file (dname, ename, "", ix -> name (1).string, code); 
100                     if code = error_table_$namedup then do; 
101                          call backup_util$delete_name (dname, ix -> name (1).string, code);    
102                          if code = 0 then go to add;        
103                     end;                                    
104                     else if code = error_table_$segnamedup then; 
105                     else if code ^= 0 then                  
106                          call backup_map_$fs_error_line (code, "chname_file in add_names", dname, ix -> name (1).string);
107                     else if bk_ss_$mapsw & list_names then  
108 print_name:              call backup_map_$name_line (addr (ix -> name (1).string), fixed (ix -> name (1).size, 17));
109                end;
110           end;
111           return;                                           
112 
113 
114 
115 delete_name: entry (dname, ename, a_code);                  
116           call hcs_$chname_file (dname, ename, ename, "", code); 
117           if code = error_table_$nonamerr then do;          
118 delete:        call hcs_$delentry_file (dname, ename, code); 
119                if code = error_table_$moderr | code = error_table_$incorrect_access then do; 
120 get_access:         call backup_util$give_access (dname, ename, code); 
121                     if code = 0 then go to delete;          
122                end;
123                else if code = error_table_$safety_sw_on then do; 
124                     call hcs_$set_safety_sw (dname, ename, "0"b, code);
125                     if code = 0 then go to delete;          
126                     call backup_map_$fs_error_line (code, "backup_util$delete_name", dname, ename);
127                end;
128                else if code = error_table_$copy_sw_on then do; 
129                     call hcs_$set_copysw (dname, ename, "0"b, code);
130                     if code = 0 then go to delete;
131                     call backup_map_$fs_error_line (code, "backup_util$delete_name", dname, ename);
132                end;
133                else if code = error_table_$user_not_found then go to get_access; 
134                else if code = error_table_$fulldir then do; 
135                     call hcs_$del_dir_tree (dname, ename, code); 
136                     if code = 0 then go to delete;
137                     call backup_map_$fs_error_line (code, "backup_util$delete_name", dname, ename);
138                end;
139                else if code ^= 0 then                       
140                     call backup_map_$fs_error_line (code, "backup_util$delete_name", dname, ename);
141           end;
142           else if code ^= 0 then                            
143                call backup_map_$fs_error_line (code, "backup_util$delete_name", dname, ename);
144           a_code = code;                                    
145           return;                                           
146 
147 
148 
149 
150 
151 give_access: entry (dname, ename, a_code);                  
152 
153 dcl  seg_aclp ptr int static,
154      dir_aclp ptr int static;
155 
156 dcl 1 seg_acl (1) aligned like segment_acl_entry int static;
157 dcl 1 dir_acl (1) aligned like directory_acl_entry int static;
158 
159 dcl  type fixed bin (2),
160      bitcnt fixed bin (24);
161 
162           if init then do;                                  
163                group_id = get_group_id_ ();                 
164                seg_acl.access_name (1),
165                     dir_acl.access_name (1) = group_id;
166                seg_acl.mode = "111"b;
167                seg_acl.extended_mode = ""b;
168                dir_acl.mode = "111"b;
169                seg_aclp = addr (seg_acl);
170                dir_aclp = addr (dir_acl);
171                init = ""b;                                  
172           end;
173           call hcs_$status_minf (dname, ename, 1, type, bitcnt, code);
174           if code ^= 0 then
175                if code = error_table_$logical_volume_not_defined then code = 0;
176                else if code = error_table_$logical_volume_not_connected then code = 0;
177                else if code = error_table_$vtoce_connection_fail then code = 0;
178                else go to ret;
179           if type = 0 then go to ret;
180           if type = 1 then call hcs_$add_acl_entries (dname, ename, seg_aclp, 1, code); 
181           else call hcs_$add_dir_acl_entries (dname, ename, dir_aclp, 1, code);
182 
183           if code = error_table_$no_info | code = error_table_$incorrect_access then do;
184                call hcs_$get_access_class (dname, "", access_class, code);
185                if code ^= 0 then access_class = "0"b;       
186                call backup_load_dir_list$build_tree (dname, "", 3, 0, 0, "", access_class, code);
187           end;                                              
188 ret:      a_code = code;                                    
189           return;                                           
190 
191 
192 
193 
194 
195 
196 get_real_name: entry (oldp, newp, newl, a_code);            
197           l = 0;                                            
198           work = "";                                        
199           i = index (oldn, " ");                            
200           if i = 0 then i = 169;                            
201           j = 1;                                            
202           do while (j < i - 1);                             
203                k = index (substr (oldn, j), ">");           
204                if k = 0 then go to done;                    
205                dir = substr (oldn, 1, j + k - 2);           
206                j = j + k;                                   
207                if j = 2 then dir = ">";                     
208                k = index (substr (oldn, j), ">");           
209                if k = 0 then ent = substr (oldn, j, i - j); 
210                else ent = substr (oldn, j, k - 1);          
211                area_ptr = get_system_free_area_ ();
212                call hcs_$status_ (dir, ent, 1, addr (stat_area), area_ptr, code); 
213                if code ^= 0 then
214                     if code = error_table_$logical_volume_not_connected then code = 0;
215                     else if code = error_table_$logical_volume_not_defined then code = 0;
216                     else if code = error_table_$vtoce_connection_fail then code = 0;
217                     else do;                                
218                          if code ^= error_table_$noentry then go to grn_ret; 
219                          work = substr (work, 1, l) || ">" || substr (oldn, j, i - j); 
220                          l = l + i - j + 1;                 
221                          go to done;                        
222                     end;
223                work = substr (work, 1, l) || ">" || pointer (area_ptr, stat_area.nrp) -> names (1);
224                l = index (work, " ") - 1;                   
225           end;
226 done:     code = 0;                                         
227           newl = l;                                         
228           if oldn = work then go to grn_ret;                
229           if l = 0 then go to grn_ret;                      
230           newn = work;                                      
231           code = 1;                                         
232 grn_ret:  a_code = code;                                    
233           return;
234 
235 
236 
237 
238 
239 idline:   entry (rfile, rdate, linep, n);                   
240 
241 dcl (rfile, rdate) char (*),                                
242      linep ptr,
243      line char (300) based (linep),                         
244      n fixed bin;                                           
245           call append (rtrim (bk_ss_$myname));              
246           call append ((rdate));                            
247           if rfile ^= "" then call append (rtrim (rfile));  
248           call append ("map");                              
249           if bk_ss_$quotasw then call append ("quota");     
250           else call append ("noquota");
251           if bk_ss_$onlysw then call append ("first");      
252           else call append ("last");
253           if bk_ss_$trimsw then call append ("trim");       
254           else call append ("notrim");
255           if bk_ss_$debugsw then call append ("debug");     debug
256           if bk_ss_$dir_trim then call append ("dir_trim"); 
257           if bk_ss_$err_onlinesw then call append ("error_on");
258           if bk_ss_$ignore_dates then call append ("ignore_dates");  
259           if bk_ss_$no_primary then call append ("noprimary");  
260           if bk_ss_$no_reload then call append ("noreload");  
261           if bk_ss_$no_setlvid then call append ("nosetlvid");  
262           if bk_ss_$qchecksw then call append ("qcheck");   
263           else call append ("noqcheck");                    
264           return;
265 
266 
267 append:   procedure (string);                               
268 
269 dcl  string character (*) aligned;                          
270                if n < length (line) then do;                
271                     n = n + 1;                              
272                     substr (line, n, 1) = " ";              
273                     i = min (length (line) - n, length (string)); 
274                     substr (line, n + 1, i) = string;       
275                     n = n + i;                              
276                end;
277           end append;
278 
279      end backup_util;