DABC (Data Acquisition Backbone Core)  2.9.9
rawCliProcn.c
Go to the documentation of this file.
1 /**********************************************************************
2  * Copyright:
3  * GSI, Gesellschaft fuer Schwerionenforschung mbH
4  * Planckstr. 1
5  * D-64291 Darmstadt
6  * Germany
7  * created 28. 8.1996 by Horst Goeringer
8  **********************************************************************
9  * rawCliProcn.c:
10  * utility programs for gStore package: clients only
11  **********************************************************************
12  * rawCheckFileList: remove objects already archived from file list
13  * rawCheckObjList: remove existing files from object and file list,
14  * reorder according to restore parameter
15  * rawGetFilelistEntries: get filelist entries from input file
16  * rawGetWSInfo: get workspace and pool info from master
17  * rawGetFullFile: get full file name from generic input & ll name
18  * rawQueryPrint: print query results for one object to stdout
19  * due to performance separate from rawQueryString
20  * rawQueryString: print query results for one object to string
21  * rawScanObjbuf: check if obj already available in obj buffer chain
22  * rawSortValues: sort indexed list of numbers
23  * ielpst: AIX only: elapsed (wall-clock) time measurement
24  **********************************************************************
25  * 26. 3.1996, H.G.: rawCheckObjList: work on ptr-linked object buffers
26  * 21.11.1997, H.G.: rawDelFile: only warning (rc=1) if obj not found
27  * 27. 7.1999, H.G.: rawGetFullFile: don't check matches, rely on ADSM
28  * 19.12.2000, H.G.: rawCheckObjList: remove unused code, better doc
29  * 18. 5.2001, H.G.: merge into new file rawcliproc.c:
30  * rawDelFile.c
31  * rawDelList (rawDelFilelist from rawproc.c)
32  * rawTapeFile.c
33  * ielpst.c
34  * 20. 7.2001, H.G.: rawCheckObjList: mover node in srawRetrList
35  * 24. 8.2001, H.G.: rawCheckObjList: stage status in srawRetrList
36  * 24. 1.2002, H.G.: created from rawcliproc.c, ACTION DELETE -> REMOVE
37  * 13. 2.2002, H.G.: rawDelFile: handle also stage file
38  * 25. 4.2002, H.G.: move rawTapeFile to new file rawProcTape.c
39  * 13. 1.2003, H.G.: rawCheckFileList: reset cFilell before calling
40  * rawGetLLName
41  * 31. 1.2003, H.G.: use rawdefn.h
42  * 4. 2.2003, H.G.: rawDelList, obj list: srawArchList -> srawRetrList
43  * rawCheckFileList, obj list: change type from
44  * srawArchList -> srawRetrList
45  * 14. 2.2003, H.G.: rawDelList: handles list of data movers
46  * rawCheckFileList: new arg pcNodeMaster
47  * 17. 2.2003, H.G.: rawCheckFileList, rawCheckObjList from rawprocn.c
48  * 17. 2.2003, H.G.: rawCheckFileList: return in filelist ptr
49  * 22. 5.2003, H.G.: renamed to rawCliProcn.c, new rawGetFilelistEntries
50  * 27. 6.2003, H.G.: new function rawGetWSInfo
51  * 18. 7.2003, H.G.: handle action QUERY_RETRIEVE_API
52  * 23. 2.2004, H.G.: rawCheckObjList: StageFS, ArchiveFS in srawRetrList
53  * 5. 3.2004, H.G.: rawCheckObjList: add cArchiveDate, cOwner to
54  * srawRetrList
55  * 6. 8.2004, H.G.: ported to Lynx
56  * 26. 1.2005, H.G.: rawapitd-gsi.h -> rawapitd-gsin.h
57  * 22. 4.2005, H.G.: rawScanObjbuf: handle filelist of any length
58  * 3. 4.2006, H.G.: ported to sarge
59  * 9. 5.2006, H.G.: rename QUERY_RETRIEVE_API -> QUERY_RETRIEVE_RECORD
60  * 7.12.2006, H.G.: rawDelList: add argument iSocketMaster
61  * 26.10.2007, H.G.: rawGetWSInfo: readable pool space information
62  * 19. 3.2008, H.G.: rawCheckObjList: use extended stage/cache parameters
63  * 14. 4.2008, H.G.: rawGetFilelistEntries: allow fully qualified filelist
64  * 21. 4.2008, H.G.: rawGetWSInfo: show only free HW, not free pool space
65  * 8. 5.2008, H.G.: rawGetFullFile: moved from rawProcn.c
66  * rawQueryFile: moved -> rawProcn.c
67  * rawQueryList: moved -> rawProcn.c
68  * 9. 5.2008, H.G.: replace srawArchList (in rawclin.h, removed)
69  * by srawFileList (added to rawcommn.h)
70  * 11. 6.2008, H.G.: rawGetFilelistEntries: correct handling of case
71  * only invalid entries in filelist
72  * 16. 6.2008, H.G.: rawCheckObjList: take all 5 restore fields into
73  * account for reordering
74  * 17. 6.2008, H.G.: rawGetFilelistEntries: use cDataFSHigh
75  * 16. 9.2008, H.G.: rawGetFilelistEntries: cDataFSHigh->cDataFSHigh1,2
76  * 6.11.2008, H.G.: rawGetWSInfo: improved handling rc=0 from recv()
77  * 11.11.2008, H.G.: add harmless suggestions of Hakan
78  * 3.12.2008, H.G.: add suggestions of Hakan, part II
79  * 9. 6.2009, H.G.: replace perror by strerror
80  * 10. 6.2009, H.G.: rawCheckObjList: new sort criteria:
81  * file in RC or WC: first and second in sort order
82  * all 5 restore order parameters (3rd - 7th)
83  * scan for all sort criteria over all query buffers
84  * 15. 6.2009, H.G.: rawSortValues: sort indexed list of numbers
85  * 14. 7.2009, H.G.: rawCheckObjList: when copying tape file entries:
86  * check for new input buffer also if file in RC/WC
87  * 27.11.2009, H.G.: rawCheckObjList: handle enhanced srawRetrList
88  * 30.11.2009, H.G.: rawCheckFileList: new arg pcArchive
89  * 10.12.2009, H.G.: rawDelFile: handle enhanced structure srawObjAttr
90  * old version info also available in new structure
91  * 29. 1.2010, H.G.: replace MAX_FILE -> MAX_FULL_FILE in:
92  * static string cPath
93  * rawGetFilelistEntries:
94  * cPath, cEntry, cTemp, cFileName
95  * rawGetWSInfo: pcGenFile
96  * rawGetFullFile: cname1, cPath
97  * 3. 2.2010, H.G.: make 'archive -over' working again
98  * rawDelFile: provide correct objId in command buffer
99  * rawDelList: fix bug setting local ptr to ll name
100  * 4. 2.2010, H.G.: rawDelList: provide all infos for rawDelFile
101  * rawDelFile: no more query for obj needed
102  * 5. 2.2010, H.G.: move rawQueryPrint,rawQueryString from rawProcn.c
103  * 10. 2.2010, H.G.: rawQueryPrint, rawQueryString: remove
104  * filetype, buffersize from output
105  * 26. 2.2010, H.G.: rawQueryString: add parameter (len output string)
106  * handle too short output string
107  * 19. 3.2010, H.G.: rawGetFilelistEntries: add parameter (dir in list)
108  * 12. 5.2010, H.G.: rawScanObjbuf: additional arg pathname,
109  * for recursive file handling
110  * 19. 5.2010, H.G.: rawCheckObjList: streamline filelist handling
111  * 18. 8.2010, H.G.: rawGetFilelistEntries: stricter limit check,
112  * remove trailing '/' in global path, if specified
113  * 6. 9.2010, H.G.: replace print formats for 'int': %lu -> %u
114  * 24. 9.2010, H.G.: rawQueryPrint, rawQueryString: 64 bit filesizes
115  * 26.11.2010, H.G.: use string cTooBig for filesizes>=4GB
116  * 11. 2.2011, H.G.: rename rawCheckObjlist -> rawCheckObjList,
117  * rawCheckObjList: new argument iObjAll, optionally:
118  * handle only objlists, no filelist (par. staging)
119  * rename rawCheckFilelist -> rawCheckFileList
120  * 17. 2.2011, H.G.: rawQueryPrint,rawQueryString:remove check iFileType
121  * 28. 7.2011, H.G.: rawCheckFileList: enhanced for recursive actions
122  * new args: iRecursive, pcTopDir, pcTophl
123  * 26. 8.2011, H.G.: rawCheckFileList: handle empty filelist positions
124  * (from duplicates from diff filelist entries)
125  * 15. 9.2011, H.G.: rawCheckFileList, non-recursive file loop:
126  * suppress multiple messages
127  * 20. 9.2011, H.G.: rawCheckFileList: add parameter iuTopDir
128  * 1. 2.2012, H.G.: rawDelList: in RetrList:
129  * iPoolId -> iPoolIdRC, use also iPoolIdWC
130  * 9. 2.2012, H.G.: rawQueryString: use STATUS_LEN_LONG,
131  * in cMsg1: 1024 -> STATUS_LEN
132  * 18. 4.2012, H.G.: rawQueryPrint: status GSI_CACHE_COPY: no 'CACHE*'
133  * in query output, is reserved for 'in creation'
134  * 28. 6.2012, H.G.: rawGetWSInfo: improve messages
135  * 13. 8.2012, H.G.: rawGetWSInfo: printing pool sizes: MB -> GB
136  * rawCheckObjList: handle >MAX_FILE_NO objs
137  * 14. 8.2012, H.G.: rawGetWSInfo: rewrite pool size parameter handling
138  * elimate rounding errors
139  * 15. 8.2012, H.G.: rawGetWSInfo: add GlobalPool
140  * 17. 8.2012, H.G.: rawCheckObjList: consistent names
141  * 23. 8.2012, H.G.: rawCheckFileList: correct compare if var path
142  * 6.12.2012, H.G.: rawCheckFileList/fnmatch: not for Lynx
143  * 7.10.2013, H.G.: rawGetWSInfo: handle up to 5 pools, more debug info
144  * 4.12.2013, H.G.: modify last arg of rawRecvStatus to 'srawStatus *'
145  * 24. 2.2014, H.G.: rawGetWSInfo: enable printing of file sizes <99 PB
146  * 12. 9.2014, H.G.: rawDelFile, rawDelList: moved back to rawProcn.c,
147  * as also needed on DMs for ARCHIVE_OVER from lustre
148  * 10.10.2014, H.G.: rawGetWSInfo: correct size units (GB)
149  * 10.11.2014, H.G.: rawGetWSInfo: amount of pool info command dependent
150  **********************************************************************
151  */
152 
153 #include <stdio.h>
154 #include <string.h>
155 #include <stdlib.h>
156 #include <errno.h>
157 
158 #ifdef Lynx
159 #include <socket.h>
160 #include <time.h>
161 #else
162 #include <fnmatch.h>
163 #include <sys/socket.h>
164 #include <sys/time.h>
165 #endif
166 
167 #ifdef Linux
168 #include <netinet/in.h>
169 #endif
170 
171 #include "rawapitd.h"
172 #include "rawapitd-gsin.h"
173 #include "rawcommn.h"
174 #include "rawdefn.h"
175 #include "rawclin.h"
176 #include "rawentn.h"
177 #include "rawapplcli.h"
178 
179 extern FILE *fLogFile;
180 extern int *piEntryList; /* for rawGetFilelistEntries */
181 
182 static unsigned int iint = sizeof(int);
183 static unsigned int iRetrList = sizeof(srawRetrList);
184 static unsigned int iFileList = sizeof(srawFileList);
185 
186 static char cPath[MAX_FULL_FILE] = "";
187  /* returned in rawGetFullFile, must not be locally */
188 
189 #ifndef Lynx
190 /*********************************************************************
191  * rawCheckFileList: remove objects already archived from file list
192  * returns number of removed objects
193  *
194  * created 15. 3.96, Horst Goeringer
195  * 25. 3.1996, H.G.: work on ptr-linked object buffers
196  *********************************************************************
197  */
198 
199 int rawCheckFileList(char **pcFileList, char **pcObjList,
200  char *pcArchive, char *pcNodeMaster,
201  int iRecursive, unsigned int iuTopDir,
202  char *pcTopDir, char *pcTophl)
203 {
204  char cModule[32] = "rawCheckFileList";
205  int iDebug = 0;
206 
207  char cDelimiter[2] = "";
208  char *pcfl, *pcol;
209  int *pifl, *piol;
210  int ifile0, ifile;
211  int iobj0, iobj;
212  char *pcc, *pcc1;
213  int inoMatch = 0;
214  int iDirWC = 0; /* =1: wildcarded local directory */
215  int iDirStar = 0; /* =1: top dir with trailing '*' */
216 
217  srawFileList *psFile, *psFile0; /* files to be archived */
218  srawRetrList *psObj, *psObj0; /* objects already archived */
219 
220  char cTopFile[MAX_FULL_FILE] = "";
221  /* (wildcarded) filename from top dir */
222  char cCurFile[MAX_FULL_FILE] = ""; /* filename string for mods */
223  char cFilell[MAX_FULL_FILE] = "", *pcFilell;
224  /* obj ll name from filename */
225  char cLastll[MAX_FULL_FILE] = ""; /* ll name from prev loop step */
226  char cCurObj[MAX_FULL_FILE] = ""; /* obj name relative to top hl */
227  unsigned int iuTophl = 0;
228 
229  bool_t bLastBuf;
230  int iobjBuf;
231  int **piptr; /* points to pointer to next buffer */
232  int *pinext; /* points to next buffer */
233 
234  int ifcur, iocur;
235  int ii, jj, iif;
236  int iRC, idel, iign;
237 
238  pcfl = *pcFileList;
239  pifl = (int *) pcfl;
240  ifile0 = pifl[0]; /* initial number of files */
241  ifile = ifile0;
242  psFile = (srawFileList *) ++pifl; /* points now to first file */
243  psFile0 = psFile;
244  pifl--; /* points again to number of files */
245 
246  pcol = *pcObjList;
247  piol = (int *) pcol;
248  iobj0 = piol[0]; /* number of archived objects */
249  iobj = iobj0;
250  psObj = (srawRetrList *) ++piol; /* points now to first object */
251  psObj0 = psObj;
252  piol--; /* points again to number of objects */
253 
254  pcFilell = cFilell;
255  if (iDebug)
256  {
257  fprintf(fLogFile,
258  "\n-D- begin %s: initial %d files, %d objects (1st buffer)\n",
259  cModule, ifile0, iobj0);
260  fprintf(fLogFile, " first file %s,\n first obj %s%s%s\n",
261  psFile->cFile, pcArchive, psObj->cNamehl, psObj->cNamell);
262  if (iRecursive)
263  {
264  if (iRecursive == 9) fprintf(fLogFile,
265  " local path with wildcards\n");
266  else
267  {
268  fprintf(fLogFile, " recursive file handling");
269  if (iRecursive == 12)
270  fprintf(fLogFile, ", local path with wildcards\n");
271  else /* (iRecursive == 2) */
272  fprintf(fLogFile, "\n");
273  }
274  }
275  }
276 
277  if (iRecursive)
278  {
279  if ( (strchr(pcTopDir , *pcStar) != NULL) ||
280  (strchr(pcTopDir, *pcQM) != NULL) ||
281  (strchr(pcTopDir, *pcPerc) != NULL) )
282  {
283  if ( (iRecursive == 9) || (iRecursive == 12) )
284  iDirWC = 1;
285  else
286  {
287  fprintf(fLogFile,
288  "-E- %s: inconsistency: wildcarded local path %s, but iRecursive=%d\n",
289  cModule, pcTophl, iRecursive);
290 
291  return -1;
292  }
293 
294  if (strchr(pcTopDir , *pcStar) != NULL)
295  {
296  pcc = pcTopDir;
297  pcc += strlen(pcTopDir) - 1; /* last char */
298  if (strncmp(pcc, pcStar, 1) == 0)
299  {
300  iDirStar = 1;
301  if (iDebug) fprintf(fLogFile,
302  " top dir with trailing '*'\n");
303  }
304  }
305  }
306 
307  iuTophl = strlen(pcTophl);
308  if (iuTophl < 2)
309  {
310  fprintf(fLogFile,
311  "-E- %s: invalid top gStore directory %s\n",
312  cModule, pcTophl);
313  return -1;
314  }
315 
316  if (iDebug)
317  {
318  if (iDirWC) fprintf(fLogFile,
319  " top directories %s\n top gStore directory %s\n",
320  pcTopDir, pcTophl);
321  else fprintf(fLogFile,
322  " top directory %s\n top gStore directory %s\n",
323  pcTopDir, pcTophl);
324  }
325  }
326 
327  iRC = strncmp(psObj->cNamell, pcObjDelim, 1);
328  if (iRC)
329  {
330  iRC = strncmp(psObj->cNamell, pcObjDelimAlt, 1);
331  if (iRC)
332  {
333  fprintf(fLogFile,
334  "-E- %s: invalid object delimiter %1s found\n",
335  cModule, psObj->cNamell);
336  return -1;
337  }
338  else
339  strcpy(cDelimiter, pcObjDelimAlt);
340  }
341  else
342  strcpy(cDelimiter, pcObjDelim);
343 
344  iign = 0;
345  for (ifcur=1; ifcur<=ifile0; ifcur++) /* file loop */
346  {
347  psObj = psObj0; /* first object again */
348  iobj = iobj0; /* first object number again */
349 
350  if (strncmp(psFile->cFile, "\n", 1) == 0)
351  {
352  iign++;
353  if (iDebug) fprintf(fLogFile,
354  " filelist position %d empty, to be ignored\n", ifcur);
355 
356  goto gNextFile;
357  }
358 
359  if (iRecursive == 0)
360  {
361  strcpy(cFilell, "");
362  iRC = rawGetLLName(psFile->cFile, cDelimiter, cFilell);
363 
364  if (iDebug) fprintf(fLogFile,
365  " %d: '%s'\n", ifcur, psFile->cFile);
366  }
367  else
368  {
369  strcpy(cTopFile, pcTopDir);
370 
371  /* get current dir */
372  strcpy(cCurFile, psFile->cFile);
373  pcc = strrchr(cCurFile, '/');
374  strcpy(pcc, "\0");
375  pcc++; /* rel file name */
376 
377  if (iRecursive == 9)
378  {
379  /* wildcarded subdir, but gStore objects not recursive */
380 
381  strcat(cTopFile, "/");
382  strcat(cTopFile, pcc);
383  if (iDebug == 1) fprintf(fLogFile,
384  "%d: strictly compare '%s' - '%s'\n", ifcur, cTopFile, psFile->cFile);
385 
386  /* compare path names, wildcards do not match '/' */
387  iRC = fnmatch(cTopFile, psFile->cFile, FNM_PATHNAME);
388  if (iRC != 0)
389  {
390  inoMatch = 1;
391  if (iDebug == 1) fprintf(fLogFile,
392  " '%s' not matching\n", psFile->cFile);
393  }
394  else
395  inoMatch = 0;
396 
397  } /* (iRecursive == 9) */
398  else if (iRecursive == 12)
399  {
400  /* recursive operation with wildcarded local subdir */
401 
402  if ( (strlen(cCurFile) > strlen(pcTopDir)) &&
403  (iDirStar == 0) )
404  strcat(cTopFile, "/*");
405 
406  strcat(cTopFile, "/");
407  strcat(cTopFile, pcc);
408 
409  if (iDebug == 1) fprintf(fLogFile,
410  "%d: compare '%s' - '%s'\n",
411  ifcur, cTopFile, psFile->cFile);
412 
413  iRC = fnmatch(cTopFile, psFile->cFile, 0);
414 
415  if (iRC != 0)
416  {
417  inoMatch = 1;
418  if (iDebug == 1) fprintf(fLogFile,
419  " '%s' not matching\n", psFile->cFile);
420  }
421  else
422  inoMatch = 0;
423 
424  } /* (iRecursive == 12) */
425  else
426  inoMatch = 0;
427 
428  /* remove not matching file from list */
429  if (inoMatch)
430  {
431  strncpy(psFile->cFile, "\n", 1);
432  ifile--;
433  if (ifile == 0)
434  {
435  if (iDebug) fprintf(fLogFile,
436  " last file, comparison finished\n");
437  goto gEndCompare;
438  }
439 
440  goto gNextFile;
441  }
442 
443  /* get rel filename for gStore object ll */
444  pcc = strrchr(psFile->cFile, '/');;
445  strcpy(pcFilell, pcc);
446 
447  if (iDebug)
448  fprintf(fLogFile, " okay, compare with objs\n");
449 
450  } /* (iRecursive) */
451 
452  bLastBuf = bFalse;
453  iobjBuf = 1;
454  if (iDebug == 1)
455  fprintf(fLogFile, "\n*** buffer %d: %d objs\n", iobjBuf, iobj);
456 
457  while (!bLastBuf)
458  {
459  for (iocur=1; iocur<=iobj; iocur++) /* object loop */
460  {
461  /* compare current file with gStore objs in list */
462  if (iRecursive == 0)
463  {
464  /* comparison of filename sufficient */
465  iRC = strcmp(cFilell, psObj->cNamell);
466  }
467  else
468  {
469  if (iRecursive == 9)
470  {
471  pcc = strrchr(cFilell, '/');
472  if (pcc == NULL)
473  {
474  fprintf(fLogFile,
475  "-E- %s: missing path in file name %s\n",
476  cModule, cFilell);
477 
478  goto gNextFile;
479  }
480  }
481 
482  /* compare filename and subdirs below top dir/hl */
483  strcpy(cCurObj, psObj->cNamehl);
484  strcat(cCurObj, psObj->cNamell);
485  pcc = cCurObj;
486  pcc += iuTophl; /* gStore obj relative to top hl */
487 
488  strcpy(cCurFile, psFile->cFile);
489  pcc1 = cCurFile;
490  pcc1 += iuTopDir;
491  /* filename relative to top dir (above wildcards),
492  so iuTopDir may differ from strlen(cTopDir) */
493 
494  if (iDebug == 1) fprintf(fLogFile,
495  " compare '%s' - '%s'\n", pcc1, pcc);
496 
497  iRC = strcmp(pcc1, pcc);
498  }
499 
500  if (iRC == 0) /* file archived */
501  {
502  fprintf(fLogFile,
503  "-W- %s%s%s already archived in gStore\n",
504  pcArchive, psObj->cNamehl, psObj->cNamell);
505 
506  /* remove file from list */
507  strncpy(psFile->cFile, "\n", 1);
508  ifile--;
509  if (ifile == 0)
510  {
511  if (iDebug) fprintf(fLogFile,
512  " last file, comparison finished\n");
513  goto gEndCompare;
514  }
515 
516  strcpy(cLastll, psObj->cNamell);
517  goto gNextFile;
518 
519  } /* iRC == 0: file already archived */
520 
521 gNextObj:
522  psObj++;
523  } /* object loop */
524 
525  piptr = (int **) psObj;
526  if (*piptr == NULL)
527  {
528  bLastBuf = bTrue;
529  if (iDebug > 1)
530  fprintf(fLogFile, " %d: last obj buffer\n", iobjBuf);
531  if (iDebug)
532  fprintf(fLogFile, "*** %d: %s (%s) to be archived\n",
533  ifcur, psFile->cFile, cFilell);
534  }
535  else
536  {
537  iobjBuf++;
538  pinext = *piptr;
539  iobj = *pinext++;
540  psObj = (srawRetrList *) pinext;
541  if (iDebug > 1) fprintf(fLogFile,
542  "\n*** new buffer %d: %d objs, first obj '%s'\n",
543  iobjBuf, iobj, psObj->cNamell);
544  }
545  } /* while (!bLastBuf) */
546 
547 gNextFile:
548  psFile++;
549 
550  } /* file loop */
551 
552 gEndCompare:
553  idel = ifile0-ifile;
554  if (iDebug) fprintf(fLogFile,
555  " %d of %d files removed: %d files remaining\n",
556  idel, ifile0, ifile);
557 
558  if (iign)
559  {
560  ifile -= iign;
561  if (iDebug) fprintf(fLogFile,
562  " %d files ignored: %d files remaining\n",
563  iign, ifile);
564  }
565 
566  pifl[0] = ifile;
567  *pcFileList = (char *) pifl;
568 
569  if ( (ifile > 0) && (idel+iign > 0) ) /* compress filelist */
570  {
571  iif = 1;
572  psFile = psFile0;
573  for (ifcur=1; ifcur<=ifile0; ifcur++) /* file loop */
574  {
575  if (iDebug == 2)
576  fprintf(fLogFile, "%d: %s\n", ifcur, psFile->cFile);
577 
578  iRC = strncmp(psFile->cFile, "\n", 1);
579  if (iRC != 0) /* file found */
580  {
581  if (iif >= ifile0)
582  break;
583 
584  psFile0++;
585  psFile++;
586  iif++;
587  }
588  else
589  { /* compress action */
590  for (iocur=ifcur+1; iocur<=ifile0; iocur++)
591  {
592  psFile++;
593  iif++;
594  iRC = strncmp(psFile->cFile, "\n", 1);
595  if (iRC == 0)
596  {
597  if (iif >= ifile0)
598  break;
599  }
600  else
601  {
602  strcpy(psFile0->cFile, psFile->cFile);
603  if (iDebug > 1) fprintf(fLogFile,
604  "*** %d: %s\n", iif, psFile0->cFile);
605  if (iif >= ifile0)
606  break;
607 
608  psFile0++;
609  }
610  } /* for (iocur...) */
611 
612  } /* compress action */
613  } /* for (ifcur...) */
614 
615  if (iDebug)
616  fprintf(fLogFile, " file list compressed\n");
617 
618  } /* ifile > 0 && idel+iign > 0 */
619 
620  if (iDebug)
621  {
622  fprintf(fLogFile, "-D- end %s\n\n", cModule);
623  fflush(fLogFile);
624  }
625 
626  return idel + iign;
627 
628 } /* rawCheckFileList */
629 #endif
630 
631 /********************************************************************
632  * rawCheckObjList:
633  * iObjComp: no. of valid objs/files
634  * on input:
635  * pcObjList: chain of ptr-linked buffers with obj lists
636  * pcFileList: corresponding file list (one buffer)
637  * in both invalid elements (retrieve: already existing) with
638  * file names eliminated to "\0"
639  * on output (one buffer):
640  * pcObjComp: compressed and sorted obj list
641  * pcFileList: compressed and sorted file list
642  * internal (one buffer):
643  * pcObjSort: compressed intermediate results
644  * pcFileSort: compressed intermediate results
645  * pcFileComp: compressed and sorted file list, to be copied to
646  * pcFileList
647  *
648  * compress pcObjList -> pcObjComp
649  * (retrieve, stage, and unstage)
650  *
651  * remove files/objs with 0 length ll names from obj + file lists
652  * (retrieve only)
653  *
654  * reorder remaining files/objs according to
655  * (1) read cache
656  * (2) write cache
657  * (3) 5 restore parameters
658  * (retrieve and stage only)
659  *
660  * created 18. 3.96, Horst Goeringer
661  *********************************************************************
662  */
663 
665  int iObjAll,/*overall no. of objs incl those to be eliminated */
666  int iObjComp, /* no. of compressed objects */
667  int iSort, /* =0: only compress of obj list (unstage) */
668  char **pcObjList, /* chained buffer list with obj names */
669  char **pcFileList, /* buffer with file names */
670  char **pcObjComp) /* compressed output buffer with obj names */
671 {
672  char cModule[32]="rawCheckObjList";
673  int iDebug = 0;
674 
675  int iRC;
676  int iDiff = 0;
677  char cMsg[STATUS_LEN] = "";
678 
679  int iaValue[iObjAll+1][6];
680  /* for sorting relevant values of all objs
681  * 1st index: file/object no.
682  * 2nd index 0: = 0: ignore (file
683  * = 1: file in read cache
684  * = 2: file in write cache
685  * = 3: sort according to up to 5 TSM restore params
686  * 2nd index 1 - 5: value of corresponing TSM restore parameters
687  */
688  int iaCompValue[iObjComp+1][6];
689  /* compressed list of for sorting relevant values */
690  int iaIndex[iObjComp];
691  /* sort index for each obj used after compression */
692 
693  int iaIndNew[iObjAll+1];
694  int iaValTop[iObjAll+1];
695  int iaValHiHi[iObjAll+1];
696  int iaValHiLo[iObjAll+1];
697  int iaValLoHi[iObjAll+1];
698  int iaValLoLo[iObjAll+1];
699 
700  int iif = 0, ii1 = 0, ii2 = 0;
701  int iisort1 = 0, /* no. of 1st object to be sorted */
702  iisort2 = 0; /* no. of last object to be sorted */
703  int iitop1 = 0, /* no. of 1st topId to be sorted */
704  iitop2 = 0, /* no. of last topId to be sorted */
705  iTopValcur = 0, /* no. of current top value */
706  iObjTopValcur = 0;/* cur no. of object with current top value */
707  int iihihi1 = 0, iihihi2 = 0, iHiHiValcur = 0, iihihicur = 0;
708  int iihilo1 = 0, iihilo2 = 0, iHiLoValcur = 0, iihilocur = 0;
709  int iilohi1 = 0, iilohi2 = 0, iLoHiValcur = 0, iilohicur = 0;
710  int iiTSM = 0; /* no of TSM objects */
711 
712  int iFileSort = 0, /* no. of TSM files: to be sorted */
713  iReadCache = 0, /* no. of files in read cache */
714  iWriteCache = 0, /* no. of files in write cache */
715  iIgnore = 0; /* no. of files to be ignored */
716 
717  /* no. of files using restore field */
718  int iRestoTop = 0,
719  iRestoHiHi = 0,
720  iRestoHiLo = 0,
721  iRestoLoHi = 0,
722  iRestoLoLo = 0;
723 
724  /* no. of different restore fields */
725  unsigned int iRestoTopValues = 0,
726  iRestoHiHiValues = 0,
727  iRestoHiLoValues = 0,
728  iRestoLoHiValues = 0,
729  iRestoLoLoValues = 0;
730 
731  unsigned int iRestoTopMin = 0,
732  iRestoHiHiMin = 0,
733  iRestoHiLoMin = 0,
734  iRestoLoHiMin = 0,
735  iRestoLoLoMin = 0;
736 
737  bool_t bRestoSort = bFalse;
738  /* if true: subset of restore fields sorted */
739  bool_t bRestoTop = bFalse, /* if true: top restore field used */
740  bRestoHiHi = bFalse, /* if true: HighHigh resto field used */
741  bRestoHiLo = bFalse,/* if true: HighLow restore field used */
742  bRestoLoHi = bFalse,/* if true: LowHigh restore field used */
743  bRestoLoLo = bFalse; /* if true: LowLow restore field used */
744 
745  char *pcfl, *pcol;
746  int *pifl, *piol;
747  int iFileAll = 0; /* overall number of files (buffer pcFileList) */
748  int iobj0 = 0, /* number of objects in current buffer pcObjList */
749  iobj = 0;
750 
751  int iFileBufComp, /* size of buffer with compressed filelist */
752  iObjBufComp; /* size of buffer with compressed objlist */
753  /* pcObjComp in arg list */
754  char *pcFileComp; /* local file buffer: filled in sorting */
755  char *pcflcomp, *pcolcomp;
756  int *piflcomp, *piolcomp;
757 
758  char *pcFileSort, /* local file buffer: filled in sorting */
759  *pcObjSort; /* local object buffer: filled in sorting */
760  char *pcflsort, *pcolsort;
761  int *piflsort, *piolsort;
762 
763  int iiObj = 0; /* no. of file/object found in current buffer */
764  int iiBuf = 0; /* no. of current object buffer */
765  int iiFile = 0; /* no. of file/object used in current buffer */
766 
767  int **piptr; /* points to pointer to next object buffer */
768  int *pinext; /* points to next object buffer */
769 
770  srawFileList *psFile, *psFile0; /* files in file list */
771  srawFileList *psFileSort, /* files in local file list */
772  *psFileSort0, /* 1st file in local file list */
773  *psFileComp, /* files in local file list */
774  *psFileComp0; /* 1st file in local file list */
775 
776  srawRetrList *psObj; /* current object in current buffer */
777  srawRetrList *psObj0; /* 1st object (in 1st buffer) */
778  srawRetrList *psObjSort, /* objects in local object list */
779  *psObjSort0, /* 1st object in local object list */
780  *psObjComp, /* objects in output object list */
781  *psObjComp0; /* 1st object in output object list */
782 
783  int ii, jj, jjMin = 0;
784  int icount = 0;
785 
786  bool_t bInit;
787 
788  /* linked object list (input) */
789  pcol = *pcObjList;
790  piol = (int *) pcol;
791  iobj0 = piol[0]; /* number of archived objects in buffer */
792  iobj = iobj0;
793  psObj = (srawRetrList *) ++piol; /* points now to first object */
794  psObj0 = psObj;
795  piol--; /* points again to number of objects */
796 
797  /* object list (output) */
798  pcolcomp = *pcObjComp;
799  piolcomp = (int *) pcolcomp;
800  psObjComp = (srawRetrList *) ++piolcomp; /* first object */
801  psObjComp0 = psObjComp;
802  piolcomp--;
803 
804  /* file list (input and output) */
805  pcfl = *pcFileList;
806  pifl = (int *) pcfl;
807  iFileAll = pifl[0]; /* number of all files */
808  if (iFileAll > 0)
809  {
810  psFile = (srawFileList *) ++pifl; /* points now to first file */
811  psFile0 = psFile;
812  pifl--; /* points again to number of files */
813  }
814 
815  if (iDebug)
816  {
817  fprintf(fLogFile,
818  "\n-D- begin %s: overall %d objs, in 1st buffer %d objs, compressed: %d objs\n",
819  cModule, iObjAll, iobj0, iObjComp);
820  if (iFileAll == 0)
821  fprintf(fLogFile, " no filelist handling\n");
822  if (iDebug > 1)
823  {
824  if (iSort == 1)
825  {
826  fprintf(fLogFile, " sort entries, first obj %s%s",
827  psObj->cNamehl, psObj->cNamell);
828  if (iFileAll > 0)
829  fprintf(fLogFile, ", first file %s\n", psFile->cFile);
830  else
831  fprintf(fLogFile, "\n");
832  }
833  else fprintf(fLogFile,
834  " first obj %s%s\n", psObj->cNamehl, psObj->cNamell);
835  }
836  fflush(fLogFile);
837  }
838 
839  if (iDebug == 2)
840  {
841  for (jj=1; jj<=iFileAll; jj++)
842  {
843  fprintf(fLogFile, "DDDD %d: file %s (%p)\n", jj, psFile->cFile, psFile);
844  psFile++;
845  }
846  psFile = psFile0; /* reset */
847  }
848 
849  /************ unstage: only compress object buffer ****************/
850 
851  if (iSort == 0)
852  {
853  iiBuf = 1; /* running buffer no. */
854  ii = 0;
855 
856  /* loop over all objects */
857  for (jj=1; jj<=iObjAll; jj++)
858  {
859  iiObj++;
860  if (strlen(psObj->cNamell) < 2)
861  {
862  if (iDebug == 2) fprintf(fLogFile,
863  " object %d(%d): ignored\n", iiObj, jj);
864 
865  goto gNextObjUnstage;
866  }
867 
868  ii++;
869  memcpy((char *) psObjComp, (char *) psObj, iRetrList);
870  if (iDebug) fprintf(fLogFile,
871  "%d(%d): obj %s%s copied (Comp)\n", iiObj, jj,
872  psObjComp->cNamehl, psObjComp->cNamell);
873 
874  psObjComp++;
875 
876 gNextObjUnstage:
877  psObj++;
878  if (iiObj == iobj)
879  {
880  if (iDebug) fprintf(fLogFile,
881  " buffer %d: last obj (no. %d) handled\n",
882  iiBuf, iiObj);
883 
884  piptr = (int **) psObj;
885  if (*piptr == NULL)
886  {
887  if (iDebug) fprintf(fLogFile,
888  " buffer %d: last obj buffer\n", iiBuf);
889  }
890  else
891  {
892  iiObj = 0;
893  iiBuf++;
894  pinext = *piptr;
895  iobj = *pinext++;
896  psObj = (srawRetrList *) pinext;
897  if (iDebug) fprintf(fLogFile,
898  " new buffer %d, %d objs, first: %s%s|\n",
899  iiBuf, iobj, psObj->cNamehl, psObj->cNamell);
900  }
901  } /* iiObj == iobj */
902  } /* loop over all objects */
903 
904  *piolcomp = ii;
905  goto gEndCheckObjlist;
906 
907  } /* (iSort == 0) */
908 
909  /************* allocate local file/object buffers *****************/
910 
911  if (iFileAll > 0)
912  {
913  iFileBufComp = sizeof(int) + iObjComp*sizeof(srawFileList);
914  if ((pcFileComp = (char *) calloc(
915  (unsigned) iFileBufComp, sizeof(char) ) ) == NULL)
916  {
917  fprintf(fLogFile,
918  "-E- %s: allocating filelist buffer (Comp, %d byte)\n",
919  cModule, iFileBufComp);
920  if (errno)
921  fprintf(fLogFile, " %s\n", strerror(errno));
922  perror("-E- allocating filelist buffer (Comp)");
923 
924  return -2;
925  }
926  if (iDebug) fprintf(fLogFile,
927  " filelist buffer (Comp) allocated (size %d)\n",
928  iFileBufComp);
929 
930  piflcomp = (int *) pcFileComp;
931  piflcomp[0] = iObjComp; /* compressed number of files */
932  psFileComp = (srawFileList *) ++piflcomp; /* first file */
933  psFileComp0 = psFileComp;
934 
935  if ( (pcFileSort = (char *) calloc(
936  (unsigned) iFileBufComp, sizeof(char)) ) == NULL)
937  {
938  fprintf(fLogFile,
939  "-E- %s: allocating filelist buffer (Sort, %d byte)\n",
940  cModule, iFileBufComp);
941  if (errno)
942  fprintf(fLogFile, " %s\n", strerror(errno));
943  perror("-E- allocating filelist buffer (Sort)");
944 
945  return(-2);
946  }
947 
948  if (iDebug) fprintf(fLogFile,
949  " filelist buffer (Sort) allocated for %d files (size %d)\n",
950  iObjComp, iFileBufComp);
951 
952  piflsort = (int *) pcFileSort;
953  piflsort[0] = iObjComp; /* compressed number of files */
954  psFileSort = (srawFileList *) ++piflsort; /* first file */
955  psFileSort0 = psFileSort;
956  }
957 
958  iObjBufComp = sizeof(int) + iObjComp*sizeof(srawRetrList);
959  if ( (pcObjSort = (char *) calloc(
960  (unsigned) iObjBufComp, sizeof(char)) ) == NULL )
961  {
962  fprintf(fLogFile,
963  "-E- %s: allocating objectlist buffer (%d byte)\n",
964  cModule, iObjBufComp);
965  if (errno)
966  fprintf(fLogFile, " %s\n", strerror(errno));
967  perror("-E- allocating objlist buffer");
968 
969  return(-3);
970  }
971  if (iDebug) fprintf(fLogFile,
972  " objlist buffer (Sort) allocated for %d objs (size %d)\n",
973  iObjComp, iObjBufComp);
974 
975  pcolsort = pcObjSort;
976  piolsort = (int *) pcolsort;
977  piolsort[0] = iObjComp; /* compressed number of objects */
978  psObjSort = (srawRetrList *) ++piolsort; /* first object */
979  psObjSort0 = psObjSort;
980 
981  /************** scan ALL objects to get sort criteria *************/
982 
983  for (jj=1; jj<=iObjComp; jj++)
984  {
985  iaIndex[jj] = -1; /* init */
986  }
987  for (jj=1; jj<=iObjAll; jj++)
988  {
989  for (ii=0; ii<=5; ii++)
990  {
991  if (ii == 0)
992  iaValue[jj][ii] = -1; /* init */
993  else
994  iaValue[jj][ii] = 0; /* init */
995  }
996  }
997 
998  psObj = psObj0; /* 1st object in 1st buffer */
999  iobj = iobj0; /* no. of objects in 1st buffer */
1000  iiObj = 0; /* running object no. in buffer */
1001  iiBuf = 1; /* running buffer no. */
1002 
1003  if (iDebug)
1004  {
1005  fprintf(fLogFile, "scan objects for sort criteria:\n");
1006  fflush(fLogFile);
1007  }
1008 
1009  /* loop over ALL objects to get sort criteria */
1010  for (jj=1; jj<=iObjAll; jj++)
1011  {
1012  iiObj++; /* counter objects in cur buffer */
1013 
1014  if (iDebug == 2)
1015  {
1016  fprintf(fLogFile, "DDD %d (all %d): obj %s (%p)", iiObj, jj, psObj->cNamell, psObj);
1017  if (iFileAll > 0) fprintf(fLogFile, ", file %s (%p)\n", psFile->cFile, psFile);
1018  else fprintf(fLogFile, "\n");
1019  }
1020 
1021  if (strlen(psObj->cNamell) < 2)
1022  {
1023  iaValue[jj][0] = 0; /* ignore */
1024  if (iDebug == 2) fprintf(fLogFile,
1025  " object %d(%d): ignored\n", iiObj, jj);
1026 
1027  iIgnore++;
1028  goto gNextValue;
1029  }
1030 
1031  if (psObj->iStageFS)
1032  {
1033  if (iDebug == 2) fprintf(fLogFile,
1034  " object %d(%d) %s%s: in read cache\n",
1035  iiObj, jj, psObj->cNamehl, psObj->cNamell);
1036 
1037  iReadCache++;
1038  iaValue[jj][0] = 1;
1039 
1040  /* copy to final destination */
1041  memcpy((char *) psObjComp, (char *) psObj, iRetrList);
1042 
1043  if (iFileAll > 0)
1044  memcpy(psFileComp->cFile, psFile->cFile, iFileList);
1045 
1046  if (iDebug)
1047  {
1048  fprintf(fLogFile,
1049  "%d: read cache obj %s%s (objId %u-%u) copied (Comp)\n",
1050  iReadCache, psObjComp->cNamehl, psObjComp->cNamell,
1051  psObjComp->iObjHigh, psObjComp->iObjLow);
1052 
1053  if (iFileAll > 0)
1054  {
1055  fprintf(fLogFile, " orig file name %s (%p)\n", psFile->cFile, psFile);
1056  fprintf(fLogFile, " file name %s copied (Comp: %p)\n", psFileComp->cFile, psFileComp);
1057  }
1058 
1059  if (jj == iObjAll) fprintf(fLogFile,
1060  " in last buffer %d: last obj (no. %d) handled\n",
1061  iiBuf, iiObj);
1062  fflush(fLogFile);
1063  }
1064 
1065  /* mark as already handled
1066  strncpy(psObj->cNamell, "\0", 1); */
1067 
1068  psObjComp++;
1069  if (iFileAll > 0)
1070  psFileComp++;
1071 
1072  goto gNextValue;
1073  }
1074 
1075  if (psObj->iCacheFS)
1076  {
1077  if (iDebug == 2) fprintf(fLogFile,
1078  " object %d(%d) %s%s: in write cache\n",
1079  iiObj, jj, psObj->cNamehl, psObj->cNamell);
1080 
1081  iWriteCache++;
1082  iaValue[jj][0] = 2;
1083 
1084  /* copy to temp. destination */
1085  memcpy((char *) psObjSort, (char *) psObj, iRetrList);
1086  if (iFileAll > 0)
1087  memcpy(psFileSort->cFile, psFile->cFile, iFileList);
1088 
1089  if (iDebug)
1090  {
1091  fprintf(fLogFile,
1092  "%d: write cache obj %s%s (%u-%u) copied (Sort)\n",
1093  iWriteCache, psObjSort->cNamehl, psObjSort->cNamell,
1094  psObjSort->iObjHigh, psObjSort->iObjLow);
1095 
1096  if (jj == iObjAll) fprintf(fLogFile,
1097  " in last buffer %d: last obj (no. %d) handled\n",
1098  iiBuf, iiObj);
1099  }
1100 
1101  psObjSort++;
1102  if (iFileAll > 0)
1103  psFileSort++;
1104 
1105  goto gNextValue;
1106  }
1107 
1108  iaValue[jj][0] = 3;
1109  if (psObj->iRestoHigh)
1110  {
1111  iaValue[jj][1] = psObj->iRestoHigh;
1112  iRestoTop++;
1113  if (iDebug == 2) fprintf(fLogFile,
1114  " object %d(%d) %s%s: top restore field %d\n",
1115  iiObj, jj, psObj->cNamehl, psObj->cNamell, iaValue[jj][1]);
1116  }
1117  if (psObj->iRestoHighHigh)
1118  {
1119  iaValue[jj][2] = psObj->iRestoHighHigh;
1120  iRestoHiHi++;
1121  fprintf(fLogFile,
1122  "-W- object %d(%d) %s%s: hihi restore field %d\n",
1123  iiObj, jj, psObj->cNamehl, psObj->cNamell, iaValue[jj][2]);
1124  }
1125  if (psObj->iRestoHighLow)
1126  {
1127  iaValue[jj][3] = psObj->iRestoHighLow;
1128  iRestoHiLo++;
1129  if (iDebug == 2) fprintf(fLogFile,
1130  " object %d(%d) %s%s: hilo restore field %d\n",
1131  iiObj, jj, psObj->cNamehl, psObj->cNamell, iaValue[jj][3]);
1132  }
1133  if (psObj->iRestoLowHigh)
1134  {
1135  iaValue[jj][4] = psObj->iRestoLowHigh;
1136  iRestoLoHi++;
1137  fprintf(fLogFile,
1138  "-W- object %d(%d) %s%s: lohi restore field %d\n",
1139  iiObj, jj, psObj->cNamehl, psObj->cNamell, iaValue[jj][4]);
1140  }
1141  if (psObj->iRestoLow)
1142  {
1143  iaValue[jj][5] = psObj->iRestoLow;
1144  iRestoLoLo++;
1145  if (iDebug == 2) fprintf(fLogFile,
1146  " object %d(%d) %s%s: lolo restore field %d\n",
1147  iiObj, jj, psObj->cNamehl, psObj->cNamell, iaValue[jj][5]);
1148  }
1149 
1150 gNextValue:
1151  psObj++;
1152  if (iFileAll > 0)
1153  psFile++;
1154 
1155  if (iiObj == iobj)
1156  {
1157  if (iDebug) fprintf(fLogFile,
1158  " buffer %d: last obj (no. %d) handled\n",
1159  iiBuf, iiObj);
1160 
1161  piptr = (int **) psObj;
1162  if (*piptr == NULL)
1163  {
1164  if (iDebug) fprintf(fLogFile,
1165  " buffer %d: last obj buffer\n", iiBuf);
1166  }
1167  else
1168  {
1169  iiObj = 0;
1170  iiBuf++;
1171  pinext = *piptr;
1172  iobj = *pinext++;
1173  psObj = (srawRetrList *) pinext;
1174  if (iDebug) fprintf(fLogFile,
1175  " new buffer %d, %d objs, first: %s%s|\n",
1176  iiBuf, iobj, psObj->cNamehl, psObj->cNamell);
1177  }
1178  } /* iiObj == iobj */
1179  } /* loop over all objects */
1180 
1181  if (iDebug) fprintf(fLogFile,
1182  " usage of restore fields: %u-%u-%u-%u-%u\n",
1183  iRestoTop, iRestoHiHi, iRestoHiLo, iRestoLoHi, iRestoLoLo);
1184 
1185  /**** copy WC entries to final destination (behind RC entries) ****/
1186 
1187  if (iWriteCache)
1188  {
1189  psObjSort = psObjSort0; /* first object */
1190  if (iFileAll > 0)
1191  psFileSort = psFileSort0; /* first file */
1192 
1193  for (ii=1; ii<=iWriteCache; ii++)
1194  {
1195  memcpy((char *) psObjComp, (char *) psObjSort, iRetrList);
1196  psObjSort++;
1197  psObjComp++;
1198 
1199  if (iFileAll > 0)
1200  {
1201  memcpy(psFileComp->cFile, psFileSort->cFile, iFileList);
1202  psFileSort++;
1203  psFileComp++;
1204  }
1205  } /* loop write cache entries */
1206  } /* (iWriteCache) */
1207 
1208  if ( ((iReadCache) || (iWriteCache)) && (iDebug == 2) )
1209  {
1210  psObjComp = psObjComp0; /* first object */
1211  if (iFileAll > 0)
1212  psFileComp = psFileComp0; /* first file */
1213 
1214  if (iReadCache)
1215  {
1216  fprintf(fLogFile,
1217  "%d read cache entries (Comp)\n", iReadCache);
1218  for (ii=1; ii<=iReadCache; ii++)
1219  {
1220  fprintf(fLogFile, " %d: obj %s%s",
1221  ii, psObjComp->cNamehl, psObjComp->cNamell);
1222  psObjComp++;
1223 
1224  if (iFileAll > 0)
1225  {
1226  fprintf(fLogFile, ", file %s\n",
1227  psFileComp->cFile);
1228  psFileComp++;
1229  }
1230  else
1231  fprintf(fLogFile, "\n");
1232  }
1233  }
1234 
1235  if (iWriteCache)
1236  {
1237  fprintf(fLogFile,
1238  "%d write cache entries (Comp)\n", iWriteCache);
1239  for (ii=1; ii<=iWriteCache; ii++)
1240  {
1241  jj = iReadCache + ii;
1242  fprintf(fLogFile, " %d: obj %s%s",
1243  jj, psObjComp->cNamehl, psObjComp->cNamell);
1244  psObjComp++;
1245 
1246  if (iFileAll > 0)
1247  {
1248  fprintf(fLogFile, ", file %s\n",
1249  psFileComp->cFile);
1250  psFileComp++;
1251  }
1252  else
1253  fprintf(fLogFile, "\n");
1254  }
1255  }
1256  } /* (iReadCache || iWriteCache) && (iDebug == 2) */
1257 
1258  /* no more TSM files left */
1259  if (iReadCache + iWriteCache + iIgnore == iObjAll)
1260  {
1261  if (iDebug)
1262  fprintf(fLogFile, "no TSM objects\n");
1263 
1264  goto gEndCheckObjlist;
1265  }
1266 
1267  /*********** create compressed arrays and obj/file buffers ********/
1268 
1269  iFileSort = iObjAll - iReadCache - iWriteCache - iIgnore;
1270  /* should be no. of TSM objs */
1271  psObjSort = (srawRetrList *) piolsort; /* first object */
1272  psObj = psObj0; /* 1st object in 1st buffer */
1273 
1274  if (iFileAll > 0)
1275  {
1276  psFileSort = (srawFileList *) piflsort; /* first file */
1277  psFile = psFile0;
1278  }
1279 
1280  iobj = iobj0; /* no. of objects in 1st buffer */
1281  iiObj = 0; /* running object no. in buffer */
1282  iiBuf = 1; /* running buffer no. */
1283  iiTSM = 0; /* no. of objs with restore order fields */
1284 
1285  if (iDebug) fprintf(fLogFile,
1286  " TSM restore values before sorting:\n");
1287 
1288  /* loop over all objects to select the TSM objects */
1289  for (jj=1; jj<=iObjAll; jj++)
1290  {
1291  iiObj++;
1292  if (iaValue[jj][0] < 3)
1293  {
1294  if (iDebug)
1295  {
1296  fprintf(fLogFile,
1297  " %d: (%d) ignored", jj, iaValue[jj][0]);
1298  if (psObj->iStageFS)
1299  fprintf(fLogFile, " (RC)\n");
1300  else if (psObj->iCacheFS)
1301  fprintf(fLogFile, " (WC)\n");
1302  else
1303  fprintf(fLogFile, "\n");
1304  }
1305  }
1306  else
1307  {
1308  iiTSM++;
1309  iaCompValue[iiTSM][0] = iaValue[jj][0];
1310  iaCompValue[iiTSM][1] = iaValue[jj][1];
1311  iaCompValue[iiTSM][2] = iaValue[jj][2];
1312  iaCompValue[iiTSM][3] = iaValue[jj][3];
1313  iaCompValue[iiTSM][4] = iaValue[jj][4];
1314  iaCompValue[iiTSM][5] = iaValue[jj][5];
1315 
1316  if (iDebug) fprintf(fLogFile,
1317  " %d(%d): %d %d-%d-%d-%d-%d\n", jj, iiTSM,
1318  iaValue[jj][0], iaValue[jj][1], iaValue[jj][2],
1319  iaValue[jj][3], iaValue[jj][4], iaValue[jj][5]);
1320 
1321  memcpy((char *) psObjSort, (char *) psObj, iRetrList);
1322  psObjSort++;
1323 
1324  if (iFileAll > 0)
1325  {
1326  memcpy(psFileSort->cFile, psFile->cFile, iFileList);
1327  psFileSort++;
1328  }
1329  }
1330 
1331  psObj++;
1332  if (iFileAll > 0)
1333  psFile++;
1334 
1335  if (iiObj == iobj)
1336  {
1337  if (iDebug == 2) fprintf(fLogFile,
1338  " buffer %d: last obj (no. %d) handled\n",
1339  iiBuf, iiObj);
1340 
1341  piptr = (int **) psObj;
1342  if (*piptr == NULL)
1343  {
1344  if (iDebug == 2) fprintf(fLogFile,
1345  " buffer %d: last obj buffer\n", iiBuf);
1346  }
1347  else
1348  {
1349  iiObj = 0;
1350  iiBuf++;
1351  pinext = *piptr;
1352  iobj = *pinext++;
1353  psObj = (srawRetrList *) pinext;
1354  if (iDebug == 2) fprintf(fLogFile,
1355  " new buffer %d, %d objs, first: %s%s\n",
1356  iiBuf, iobj, psObj->cNamehl, psObj->cNamell);
1357  }
1358  } /* iiObj == iobj */
1359  } /* loop over all objects to select the TSM objects */
1360 
1361  if (iiTSM != iFileSort)
1362  {
1363  fprintf(fLogFile,
1364  "-E- %s: inconsistent no. of TSM files: %d - %d\n",
1365  cModule, iFileSort, iiTSM);
1366  return -2;
1367  }
1368 
1369  psObjSort = (srawRetrList *) piolsort; /* first object */
1370  if (iFileAll > 0)
1371  psFileSort = (srawFileList *) piflsort; /* first file */
1372 
1373  /*************** sort top restore values in array *****************/
1374 
1375  if (iDebug == 2) fprintf(fLogFile,
1376  "DDD list of %d compressed TSM objs/files (ps...Sort):\n",
1377  iFileSort);
1378 
1379  for (jj=1; jj<=iFileSort; jj++)
1380  {
1381  if (iRestoTop)
1382  iaValTop[jj] = iaCompValue[jj][1];
1383  else
1384  iaValTop[jj] = 0;
1385 
1386  if (iRestoHiHi)
1387  iaValHiHi[jj] = iaCompValue[jj][2];
1388  else
1389  iaValHiHi[jj] = 0;
1390 
1391  if (iRestoHiLo)
1392  iaValHiLo[jj] = iaCompValue[jj][3];
1393  else
1394  iaValHiLo[jj] = 0;
1395 
1396  if (iRestoLoHi)
1397  iaValLoHi[jj] = iaCompValue[jj][4];
1398  else
1399  iaValLoHi[jj] = 0;
1400 
1401  if (iRestoLoLo)
1402  iaValLoLo[jj] = iaCompValue[jj][5];
1403  else
1404  iaValLoLo[jj] = 0;
1405 
1406  iaIndex[jj] = jj;
1407 
1408  if (iDebug == 2)
1409  {
1410  fprintf(fLogFile, " %d: obj %s%s",
1411  jj, psObjSort->cNamehl, psObjSort->cNamell);
1412  psObjSort++;
1413 
1414  if (iFileAll > 0)
1415  {
1416  fprintf(fLogFile, ", file %s\n", psFileSort->cFile);
1417  psFileSort++;
1418  }
1419  else
1420  fprintf(fLogFile, "\n");
1421  }
1422  }
1423 
1424  iisort1 = 1;
1425  iisort2 = iFileSort;
1426 
1427  if (iRestoTop)
1428  {
1429  iRC = rawSortValues(iaValTop, iFileSort, iisort1, iisort2,
1430  iaIndex, iaIndNew);
1431 
1432  /* rearrange other restore fields */
1433  iDiff = 0;
1434  for (jj=iisort1; jj<=iisort2; jj++)
1435  {
1436  if (iaIndNew[jj] != iaIndex[jj])
1437  {
1438  ii1 = iaIndNew[jj];
1439  if (iRestoHiHi)
1440  iaValHiHi[jj] = iaCompValue[ii1][2];
1441  if (iRestoHiLo)
1442  iaValHiLo[jj] = iaCompValue[ii1][3];
1443  if (iRestoLoHi)
1444  iaValLoHi[jj] = iaCompValue[ii1][4];
1445  if (iRestoLoLo)
1446  iaValLoLo[jj] = iaCompValue[ii1][5];
1447  iDiff++;
1448  }
1449  }
1450 
1451  /* update index field */
1452  memcpy(&iaIndex[iisort1], &iaIndNew[iisort1],
1453  (unsigned) iFileSort*iint);
1454 
1455  if (iDebug == 2)
1456  {
1457  fprintf(fLogFile,
1458  "DDD restore order after top sorting (%d changes):\n",
1459  iDiff);
1460  for (jj=iisort1; jj<=iisort2; jj++)
1461  {
1462  fprintf(fLogFile,
1463  " %d: index %d, values: %u-%u-%u-%u-%u\n",
1464  jj, iaIndNew[jj], iaValTop[jj],
1465  iaValHiHi[jj], iaValHiLo[jj],
1466  iaValLoHi[jj], iaValLoLo[jj]);
1467  }
1468  }
1469 
1470  iRestoTopValues = 1;
1471  iRestoTopMin = iaValTop[iisort1];
1472  for (jj=iisort1+1; jj<=iisort2; jj++)
1473  {
1474  if (iaValTop[jj] > iRestoTopMin)
1475  {
1476  iRestoTopMin = iaValTop[jj];
1477  iRestoTopValues++;
1478  }
1479  }
1480 
1481  if (iDebug) fprintf(fLogFile,
1482  "%d different top restore values\n", iRestoTopValues);
1483 
1484  iitop1 = iisort1;
1485  /* index of 1st obj with cur top restore field */
1486 
1487  /* loop over different top restore fields */
1488  for (iTopValcur=1; iTopValcur<=iRestoTopValues; iTopValcur++)
1489  {
1490  if (iTopValcur == iRestoTopValues)
1491  iitop2 = iFileSort;
1492  else
1493  {
1494  iRestoTopMin = iaValTop[iitop1];
1495  for (jj=iitop1+1; jj<=iFileSort; jj++)
1496  {
1497  if (iaValTop[jj] > iRestoTopMin)
1498  {
1499  iitop2 = jj-1;
1500  break;
1501  }
1502 
1503  if (jj == iFileSort)
1504  iitop2 = jj;
1505  }
1506  }
1507 
1508  if (iitop1 == iitop2)
1509  {
1510  if (iDebug) fprintf(fLogFile,
1511  " %d. top restore value %d: only one object (%d)\n",
1512  iTopValcur, iaValTop[iitop1], iitop1);
1513 
1514  if (iTopValcur == iRestoTopValues)
1515  break;
1516  else
1517  {
1518  iitop1 = iitop2 + 1;
1519  continue;
1520  }
1521  }
1522  else if (iDebug) fprintf(fLogFile,
1523  " %d. top restore value %d: objs %d - %d\n",
1524  iTopValcur, iaValTop[iitop1], iitop1, iitop2);
1525 
1526  /* sort entries according to hihi: DDD not yet used */
1527  if (iRestoHiHi)
1528  {
1529  ;
1530  } /* (iRestoHiHi) */
1531 
1532  /* sort entries according to hilo */
1533  if (iRestoHiLo)
1534  {
1535  if (iitop2 - iitop1)
1536  {
1537  iRC = rawSortValues(iaValHiLo, iFileSort, iitop1, iitop2,
1538  iaIndex, iaIndNew);
1539 
1540  /* rearrange other restore fields */
1541  iDiff = 0;
1542  for (jj=iitop1; jj<=iitop2; jj++)
1543  {
1544  if (iaIndNew[jj] != iaIndex[jj])
1545  {
1546  ii1 = iaIndNew[jj];
1547  if (iRestoTop)
1548  iaValTop[jj] = iaCompValue[ii1][1];
1549  if (iRestoHiHi)
1550  iaValHiHi[jj] = iaCompValue[ii1][2];
1551  if (iRestoLoHi)
1552  iaValLoHi[jj] = iaCompValue[ii1][4];
1553  if (iRestoLoLo)
1554  iaValLoLo[jj] = iaCompValue[ii1][5];
1555  iDiff++;
1556  }
1557  }
1558 
1559  /* update index field */
1560  ii1 = iitop2 - iitop1 + 1;
1561  memcpy(&iaIndex[iitop1], &iaIndNew[iitop1],
1562  (unsigned) ii1*iint);
1563 
1564  if (iDebug == 2)
1565  {
1566  fprintf(fLogFile,
1567  " restore order after hilo sorting (%d - %d: %d changes):\n",
1568  iitop1, iitop2, iDiff);
1569  for (jj=iitop1; jj<=iitop2; jj++)
1570  {
1571  fprintf(fLogFile,
1572  " %d: index %d, values: %u-%u-%u-%u-%u\n",
1573  jj, iaIndNew[jj], iaValTop[jj],
1574  iaValHiHi[jj], iaValHiLo[jj],
1575  iaValLoHi[jj], iaValLoLo[jj]);
1576  }
1577  }
1578 
1579  iRestoHiLoValues = 1;
1580  iRestoHiLoMin = iaValHiLo[iitop1];
1581 
1582  for (jj=iitop1+1; jj<=iitop2; jj++)
1583  {
1584  if (iaValHiLo[jj] > iRestoHiLoMin)
1585  {
1586  iRestoHiLoMin = iaValHiLo[jj];
1587  iRestoHiLoValues++;
1588  }
1589  }
1590 
1591  if (iDebug) fprintf(fLogFile,
1592  " %d different hilo restore values\n", iRestoHiLoValues);
1593 
1594  } /* (iitop2 - iitop1) */
1595  else
1596  iRestoHiLoValues = 1;
1597 
1598  iihilo1 = iitop1;
1599  /* index of 1st obj with cur hilo restore field */
1600 
1601  /* loop over different hilo fields for fixed top field */
1602  for (iHiLoValcur=1; iHiLoValcur<=iRestoHiLoValues; iHiLoValcur++)
1603  {
1604  if (iHiLoValcur == iRestoHiLoValues)
1605  iihilo2 = iitop2;
1606  else
1607  {
1608  iRestoHiLoMin = iaValHiLo[iihilo1];
1609  for (jj=iitop1+1; jj<=iitop2; jj++)
1610  {
1611  if (iaValHiLo[jj] > iRestoHiLoMin)
1612  {
1613  iihilo2 = jj-1;
1614  break;
1615  }
1616 
1617  if (jj == iitop2)
1618  iihilo2 = jj;
1619  }
1620  }
1621 
1622  if (iihilo1 == iihilo2)
1623  {
1624  if (iDebug) fprintf(fLogFile,
1625  " %d. hilo restore value %d: only one object (%d)\n",
1626  iHiLoValcur, iaValHiLo[iihilo1], iihilo1);
1627 
1628  if (iHiLoValcur == iRestoHiLoValues)
1629  break;
1630  else
1631  {
1632  iihilo1 = iihilo2 + 1;
1633  continue;
1634  }
1635  }
1636  else if (iDebug) fprintf(fLogFile,
1637  " %d. hilo restore value %d: objs %d - %d\n",
1638  iHiLoValcur, iaValHiLo[iihilo1], iihilo1, iihilo2);
1639 
1640  /* sort entries according to lohi: DDD not yet used */
1641  if (iRestoLoHi)
1642  {
1643  ;
1644  } /* (iRestoLoHi) */
1645 
1646  if (iRestoLoLo)
1647  {
1648  if (iihilo2 - iihilo1)
1649  {
1650  iRC = rawSortValues(iaValLoLo, iFileSort,
1651  iihilo1, iihilo2, iaIndex, iaIndNew);
1652 
1653  /* rearrange other restore fields */
1654  iDiff = 0;
1655  for (jj=iihilo1; jj<=iihilo2; jj++)
1656  {
1657  if (iaIndNew[jj] != iaIndex[jj])
1658  {
1659  ii1 = iaIndNew[jj];
1660  if (iRestoTop)
1661  iaValTop[jj] = iaCompValue[ii1][1];
1662  if (iRestoHiHi)
1663  iaValHiHi[jj] = iaCompValue[ii1][2];
1664  if (iRestoHiLo)
1665  iaValHiLo[jj] = iaCompValue[ii1][3];
1666  if (iRestoLoHi)
1667  iaValLoHi[jj] = iaCompValue[ii1][4];
1668  iDiff++;
1669  }
1670  }
1671 
1672  /* update index field */
1673  ii1 = iihilo2 - iihilo1 + 1;
1674  memcpy(&iaIndex[iihilo1], &iaIndNew[iihilo1],
1675  (unsigned) ii1*iint);
1676 
1677  if (iDebug == 2)
1678  {
1679  fprintf(fLogFile,
1680  " restore order after lolo sorting (%d - %d: %d changes):\n",
1681  iihilo1, iihilo2, iDiff);
1682  for (jj=iihilo1; jj<=iihilo2; jj++)
1683  {
1684  fprintf(fLogFile,
1685  " %d: index %d, values: %u-%u-%u-%u-%u\n",
1686  jj, iaIndNew[jj], iaValTop[jj],
1687  iaValHiHi[jj], iaValHiLo[jj],
1688  iaValLoHi[jj], iaValLoLo[jj]);
1689  }
1690  }
1691  } /* (iihilo2 - iihilo1) */
1692  else
1693  iRestoLoLoValues = 1;
1694 
1695  } /* (iRestoLoLo) */
1696  else
1697  iRestoLoLoValues = 0;
1698 
1699  iihilo1 = iihilo2 + 1;
1700 
1701  } /* iHiLoValcur: loop over different hilo restore fields */
1702 
1703  } /* (iRestoHiLo */
1704  else
1705  iRestoHiLoValues = 0;
1706 
1707  iitop1 = iitop2 + 1;
1708 
1709  } /* iTopValcur: loop over different top restore fields */
1710  } /* (iRestoTop) */
1711  else
1712  iRestoTopValues = 0;
1713 
1714  psObjSort = (srawRetrList *) piolsort; /* first object */
1715  if (iFileAll > 0)
1716  psFileSort = (srawFileList *) piflsort; /* first file */
1717 
1718  if (iDebug == 2)
1719  {
1720  fprintf(fLogFile,
1721  "DDD final restore order after sorting (%d-%d):\n",
1722  iisort1, iisort2);
1723  for (jj=iisort1; jj<=iisort2; jj++)
1724  {
1725  ii = iaIndex[jj];
1726  fprintf(fLogFile,
1727  " %d: index %d, values: %u-%u-%u-%u-%u\n",
1728  jj, iaIndex[jj], iaCompValue[ii][1], iaCompValue[ii][2],
1729  iaCompValue[ii][3], iaCompValue[ii][4], iaCompValue[ii][5]);
1730  }
1731  }
1732 
1733  /******** copy + compress TSM entries to temp destination *********/
1734 
1735  psObjSort = (srawRetrList *) piolsort; /* first object */
1736  psObj = psObj0; /* 1st object in 1st buffer */
1737 
1738  if (iFileAll > 0)
1739  {
1740  psFileSort = (srawFileList *) piflsort; /* first file */
1741  psFile = psFile0;
1742  }
1743 
1744  iobj = iobj0; /* no. of objects in 1st buffer */
1745  iiObj = 0; /* running object no. in buffer */
1746  iiBuf = 1; /* running buffer no. */
1747  icount = 0;
1748 
1749  if (iDebug == 2) fprintf(fLogFile,
1750  "DDD copy TSM objects to temp destination for compression\n");
1751 
1752  for (jj = 1; jj <= iObjAll; jj++)
1753  {
1754  /* skip empty, RC, WC entries */
1755  if (iaValue[jj][0] < 3)
1756  {
1757  if (iDebug == 2)
1758  {
1759  fprintf(fLogFile, " (%d): ignored", jj);
1760  if (psObj->iStageFS)
1761  fprintf(fLogFile, " (RC)\n");
1762  else if (psObj->iCacheFS)
1763  fprintf(fLogFile, " (WC)\n");
1764  else
1765  fprintf(fLogFile, "\n");
1766  }
1767 
1768  iiObj++;
1769  psObj++;
1770  if (iFileAll > 0)
1771  psFile++;
1772 
1773  goto gNextCopy2Temp;
1774  }
1775 
1776  iiObj++;
1777  icount++;
1778 
1779  memcpy((char *) psObjSort, (char *) psObj, iRetrList);
1780  if (iFileAll > 0)
1781  memcpy(psFileSort->cFile, psFile->cFile, iFileList);
1782 
1783  if (iDebug == 2)
1784  {
1785  fprintf(fLogFile,
1786  " %d(%d): obj %s%s (objId %u-%u) copied (Comp), retrId %u-%u-%u-%u-%u\n",
1787  iiObj, jj, psObjSort->cNamehl, psObjSort->cNamell,
1788  psObjSort->iObjHigh, psObjSort->iObjLow,
1789  psObjSort->iRestoHigh, psObjSort->iRestoHighHigh,
1790  psObjSort->iRestoHighLow, psObjSort->iRestoLowHigh,
1791  psObjSort->iRestoLow);
1792  }
1793 
1794  psObj++;
1795  psObjSort++;
1796 
1797  if (iFileAll > 0)
1798  {
1799  psFile++;
1800  psFileSort++;
1801  }
1802 
1803  /* last object scanned */
1804 gNextCopy2Temp:
1805  if (iiObj == iobj)
1806  {
1807  if (iDebug > 1) fprintf(fLogFile,
1808  " buffer %d: last obj (no. %d) handled\n",
1809  iiBuf, iiObj);
1810  piptr = (int **) psObj;
1811  if (*piptr == NULL)
1812  {
1813  if (iDebug > 1) fprintf(fLogFile,
1814  " %d: last obj buffer\n", iiBuf);
1815  }
1816  else
1817  {
1818  iiObj = 0;
1819  iiBuf++;
1820  pinext = *piptr;
1821  iobj = *pinext++;
1822  psObj = (srawRetrList *) pinext;
1823  if (iDebug > 1) fprintf(fLogFile,
1824  " %d: new buffer, %d objs, first: |%s%s|\n",
1825  iiBuf, iobj, psObj->cNamehl, psObj->cNamell);
1826  }
1827  } /* iiObj == iobj */
1828  } /* loop copy TSM objects to temp destination for compression */
1829 
1830  if (iDebug == 2)
1831  {
1832  psObjSort = (srawRetrList *) piolsort; /* first object */
1833  if (iFileAll > 0)
1834  psFileSort = (srawFileList *) piflsort; /* first file */
1835 
1836  fprintf(fLogFile,
1837  "DDD compressed list of TSM objects (not yet sorted):\n");
1838 
1839  for (jj=1; jj<=iFileSort; jj++)
1840  {
1841  fprintf(fLogFile, " %d: obj %s%s",
1842  jj, psObjSort->cNamehl, psObjSort->cNamell);
1843  psObjSort++;
1844 
1845  if (iFileAll > 0)
1846  {
1847  fprintf(fLogFile, ", file %s\n",
1848  psFileSort->cFile);
1849  psFileSort++;
1850  }
1851  else
1852  fprintf(fLogFile, "\n");
1853  }
1854  }
1855 
1856  if (icount != iFileSort)
1857  {
1858  fprintf(fLogFile,
1859  "-E- %s: unexpected no. of objects found: %d, expected %d\n",
1860  cModule, icount, iFileSort);
1861  return -5;
1862  }
1863 
1864  /********** copy sorted TSM entries to final destination **********
1865  **************** behind WC entries, using index ******************/
1866 
1867  psObjSort = (srawRetrList *) piolsort; /* first object */
1868  if (iFileAll > 0)
1869  psFileSort = (srawFileList *) piflsort; /* first file */
1870 
1871  if (iDebug == 2) fprintf(fLogFile,
1872  "DDD copy TSM objects in correct order to final destination\n");
1873 
1874  ii1 = 1; /* init position on 1st obj */
1875  for (jj = 1; jj <= iFileSort; jj++)
1876  {
1877  ii2 = iaIndex[jj];
1878  iDiff = ii2 - ii1;
1879 
1880  psObjSort += iDiff;
1881  if (iFileAll > 0)
1882  psFileSort += iDiff;
1883 
1884  icount++;
1885 
1886  memcpy((char *) psObjComp, (char *) psObjSort, iRetrList);
1887  if (iFileAll > 0)
1888  memcpy(psFileComp->cFile, psFileSort->cFile, iFileList);
1889 
1890  if (iDebug == 2)
1891  {
1892  fprintf(fLogFile,
1893  " %d: TSM obj %s%s (index %d, objId %u-%u) copied (Comp), retrId %u-%u-%u-%u-%u\n",
1894  jj, psObjSort->cNamehl, psObjSort->cNamell, ii2,
1895  psObjSort->iObjHigh, psObjSort->iObjLow,
1896  psObjSort->iRestoHigh, psObjSort->iRestoHighHigh,
1897  psObjSort->iRestoHighLow, psObjSort->iRestoLowHigh, psObjSort->iRestoLow);
1898  }
1899 
1900  psObjComp++;
1901  if (iFileAll > 0)
1902  psFileComp++;
1903  ii1 = ii2;
1904 
1905  } /* for (jj...) */
1906 
1907  iObjAll = iReadCache + iWriteCache + iFileSort;
1908  if (iDebug)
1909  {
1910  psObjComp = psObjComp0; /* first object */
1911  if (iFileAll > 0)
1912  psFileComp = psFileComp0; /* first file */
1913  fprintf(fLogFile,
1914  "final list of all objects (compressed and sorted):\n");
1915 
1916  for (jj=1; jj<=iObjAll; jj++)
1917  {
1918  fprintf(fLogFile,
1919  " %d: obj %s%s, objId %u-%u, retrId %u-%u-%u-%u-%u",
1920  jj, psObjComp->cNamehl, psObjComp->cNamell,
1921  psObjComp->iObjHigh, psObjComp->iObjLow,
1922  psObjComp->iRestoHigh, psObjComp->iRestoHighHigh,
1923  psObjComp->iRestoHighLow, psObjComp->iRestoLowHigh,
1924  psObjComp->iRestoLow);
1925  if (psObjComp->iStageFS)
1926  fprintf(fLogFile, " (RC)");
1927  else if (psObjComp->iCacheFS)
1928  fprintf(fLogFile, " (WC)");
1929 
1930  psObjComp++;
1931 
1932  if (iFileAll > 0)
1933  {
1934  fprintf(fLogFile, ", file %s\n", psFileComp->cFile);
1935 
1936  psFileComp++;
1937  }
1938  else
1939  fprintf(fLogFile, "\n");
1940  }
1941  }
1942 
1943 gEndCheckObjlist:
1944 
1945  if ( (iSort) && (iFileAll > 0) )
1946  {
1947  memset(pcfl, 0x00, (unsigned) iFileBufComp);
1948  memcpy(pcfl, pcFileComp, (unsigned) iFileBufComp);
1949  }
1950 
1951  if (iDebug) fprintf(fLogFile,
1952  "-D- end %s\n\n", cModule);
1953 
1954  return 0;
1955 
1956 } /* rawCheckObjList */
1957 
1958 /**********************************************************************
1959  * rawGetFilelistEntries:
1960  * get filelist entries from input file
1961  * if global path specified, add to file name
1962  * uses external buffer ptr piEntryList provided by caller
1963  * replaces '%' (historical) by '?' (supported by TSM)
1964  * removes tape file specifications
1965  * removes duplicate entries
1966  * orders: generic file names first
1967  *
1968  * created 22. 5.2003 by Horst Goeringer
1969  **********************************************************************
1970  */
1971 
1972 int rawGetFilelistEntries( char *pcFileName,
1973  int *piDataFS,
1974  char *pcDataFS,
1975  int *piEntries,
1976  int *piGlobalDir)
1977 {
1978  char cModule[32] = "rawGetFilelistEntries";
1979  int iDebug = 0;
1980 
1981  char cMsg[STATUS_LEN] = "";
1982  int ii, jj;
1983  int iDelCount = 0;
1984  int iFilesIgnored = 0; /* =1: no. of files with specific subdir */
1985  int iGlobalDir = 0; /* =1: global dir in 1st line specified */
1986  int iDataFS = 0; /* =1: path in central data FS */
1987  int imax = MAX_FULL_FILE - 1;
1988  char cPath[MAX_FULL_FILE] = "";
1989  char cEntry[MAX_FULL_FILE] = "";
1990  char cTemp[MAX_FULL_FILE] = "";
1991  char cFileName[MAX_FULL_FILE] = "";
1992  char cQualifier[16] = ".filelist";
1993  const char *pcLeading = "@";
1994  char *pcc;
1995  char *ploc;
1996  char *pccT = NULL;
1997  char *pccE;
1998 
1999  int iRemove = 0;
2000  int iGeneric = 0; /* = 1: generic file name found */
2001  int iSingle = 0; /* = 1: file name without wildcard chars found */
2002  int iRC;
2003  int iError;
2004 
2005  int iGenericEntries = 0;
2006  int iSingleEntries = 0;
2007  int iEntries = -1;
2008  FILE *fiFile = NULL;
2009 
2010  int iMaxEntries;
2011  int iSizeBuffer;
2012  int *piFilelist, *piFilelisto;
2013  srawFileList *pFilelist, /* first filelist entry */
2014  *pFilelistc, /* current filelist entry */
2015  *pFilelistco, /* current filelist entry old buffer */
2016  *pFilelistc0; /* current filelist entry for remove */
2017 
2018  if (iDebug)
2019  printf("\n-D- begin %s\n", cModule);
2020 
2021  iDataFS = *piDataFS;
2022  piFilelist = piEntryList; /* copy of external pointer */
2023  iPathPrefix = strlen(cPathPrefix); /* from rawclin.h */
2024 
2025  if ((int) strlen(pcFileName) >= imax)
2026  {
2027  fprintf(fLogFile,
2028  "-E- %s: file name too long (max %d)\n",
2029  cModule, --imax);
2030  iError = -1;
2031  goto gErrorFilelist;
2032  }
2033  strcpy(cFileName, pcFileName); /* local copy */
2034 
2035  pccT = (char *) strrchr(pcFileName, *pcLeading);
2036  if (pccT)
2037  {
2038  pccE = (char *) strrchr(pccT, *pcObjDelim);
2039  if (pccE) /* '@' only in path name */
2040  pccT = NULL;
2041  }
2042 
2043  if (pccT == NULL)
2044  {
2045  if (iDebug) fprintf(fLogFile,
2046  " no leading '%s' in file name %s\n", pcLeading, pcFileName);
2047  goto gEndFilelist;
2048  }
2049 
2050  pcc = cQualifier;
2051  ploc = strrchr(cFileName, pcc[0]);
2052  if (ploc != NULL)
2053  {
2054  ploc++;
2055  pcc++;
2056  if (strcmp(ploc, pcc) != 0)
2057  {
2058  if (iDebug) fprintf(fLogFile,
2059  " no trailing %s\n", cQualifier);
2060  goto gEndFilelist;
2061  }
2062  }
2063  else
2064  {
2065  if (iDebug) fprintf(fLogFile,
2066  " no trailing %s in file name %s\n", cQualifier, pcFileName);
2067  goto gEndFilelist;
2068  }
2069 
2070  if (iDebug) fprintf(fLogFile,
2071  " %s is a filelist\n", cFileName);
2072 
2073  fiFile = fopen(pcFileName, "r");
2074  if (fiFile == NULL)
2075  {
2076  fprintf(fLogFile, "-E- %s: opening filelist %s\n",
2077  cModule, pcFileName);
2078  if (errno)
2079  fprintf(fLogFile, " %s\n", strerror(errno));
2080  perror("-E- opening filelist");
2081 
2082  iError = -1;
2083  goto gErrorFilelist;
2084  }
2085  if (iDebug) fprintf(fLogFile,
2086  " filelist %s opened\n", pcFileName);
2087 
2088  piFilelisto = piFilelist;
2089  iMaxEntries = *piFilelist;
2090  if (iDebug) fprintf(fLogFile,
2091  " max no. of entries in filelist buffer: %d\n", iMaxEntries);
2092  if (iDebug == 2) fprintf(fLogFile,
2093  "DDD piFilelist %p, *piFilelist %d\n",
2094  piFilelist, *piFilelist);
2095 
2096  pFilelist = (srawFileList *) &(piFilelist[1]);
2097  /* skip max no. of entries */
2098  pFilelistc = pFilelist; /* current entry */
2099  pccE = cEntry;
2100  iEntries = 0;
2101  for(;;)
2102  {
2103  pccE = fgets(cEntry, imax, fiFile);
2104 
2105  if ( (pccE != NULL) && (strlen(pccE) > 1) )
2106  {
2107  /* remove blanks, line feeds, and so on */
2108  ii = strlen(pccE);
2109  memset(cTemp, '\0', strlen(cTemp));
2110  pccT = cTemp;
2111  iDelCount = 0;
2112  while (ii-- > 0)
2113  {
2114  if ( (*pccE != '\0') && (*pccE != '\n') && (*pccE != '\r') &&
2115  (*pccE != ' ') )
2116  {
2117  strncpy(pccT, pccE, 1);
2118  pccT++;
2119  }
2120  else
2121  iDelCount++;
2122 
2123  pccE++;
2124 
2125  }
2126  strncpy(pccT, "\0", 1); /* terminates copied name */
2127 
2128  if (iDebug == 2) fprintf(fLogFile,
2129  "'%s' -> '%s': %d chars removed\n", cEntry, cTemp, iDelCount);
2130 
2131  /* check for path prefix */
2132  if (iEntries == 0)
2133  {
2134  if (strncmp(cTemp, cPathPrefix, (unsigned) iPathPrefix) == 0)
2135  {
2136  iGlobalDir = 1;
2137 
2138  if (iDebug) fprintf(fLogFile,
2139  " path prefix '%s' in first filelist entry found\n",
2140  cPathPrefix);
2141 
2142  pccT = cTemp;
2143  for (ii=1; ii<=iPathPrefix; ii++)
2144  { pccT++; }
2145 
2146  if (strlen(pccT) == 0)
2147  {
2148  fprintf(fLogFile,
2149  "-W- no path name found after path prefix: %s\n",
2150  cEntry);
2151  continue;
2152  }
2153 
2154  ii = strlen(pccT) - 1;
2155  pcc = pccT;
2156  pcc += ii;
2157  if (strncmp(pcc, "/", 1) == 0) /* trailing '/' */
2158  strncpy(cPath, pccT, (unsigned) ii);
2159  else
2160  strcpy(cPath, pccT);
2161 
2162  if (iDebug) fprintf(fLogFile,
2163  " path '%s' for files in filelist\n", cPath);
2164 
2165  if ( (strncmp(cPath, cDataFSHigh1,
2166  strlen(cDataFSHigh1)) == 0) ||
2167  (strncmp(cPath, cDataFSHigh2,
2168  strlen(cDataFSHigh2)) == 0) )
2169  {
2170  iDataFS = 1;
2171  strcpy(pcDataFS, cPath);
2172 
2173  if (iDebug) fprintf(fLogFile,
2174  " central data FS path %s\n", cPath);
2175  }
2176 
2177  continue;
2178 
2179  } /* path prefix found */
2180  } /* (iEntries == 0) */
2181 
2182  if (strncmp(cTemp, cPathPrefix, (unsigned) iPathPrefix) == 0)
2183  {
2184  fprintf(fLogFile,
2185  "-E- only one path specification in file list allowed, %s and following files ignored\n",
2186  cTemp);
2187  break;
2188  }
2189 
2190  /* replace '%' (historical) by '?' (supported by TSM) */
2191  while ( (ploc = strchr(cTemp, *pcPerc)) != NULL)
2192  {
2193  if (iDebug)
2194  fprintf(fLogFile, "-W- replace %s", cTemp);
2195  *ploc = *pcQM;
2196  if (iDebug)
2197  fprintf(fLogFile, " by %s\n", cTemp);
2198  }
2199 
2200  if ( (iEntries == iMaxEntries) && /* reallocate */
2201  (iEntries > 0) )
2202  {
2203  iMaxEntries *= 2;
2204  if (iDebug) fprintf(fLogFile,
2205  " entry buffer full, reallocate: max %d entries\n",
2206  iMaxEntries);
2207 
2208  iSizeBuffer = iMaxEntries*MAX_FULL_FILE + sizeof(int);
2209  piFilelisto = piFilelist;
2210  piFilelist = (int *) calloc(
2211  (unsigned) iSizeBuffer, sizeof(char) );
2212  if (piFilelist == NULL)
2213  {
2214  fprintf(fLogFile,
2215  "-E- %s: reallocating filelist buffer (size %d)\n",
2216  cModule, iSizeBuffer);
2217  if (errno)
2218  fprintf(fLogFile, " %s\n", strerror(errno));
2219  perror("-E- reallocating filelist buffer");
2220 
2221  iError = -1;
2222  goto gErrorFilelist;
2223  }
2224 
2225  if (iDebug) fprintf(fLogFile,
2226  " filelist entry buffer reallocated (size %d)\n",
2227  iSizeBuffer);
2228 
2229  *piFilelist = iMaxEntries;
2230  if (iDebug == 2) fprintf(fLogFile,
2231  "DDD piFilelist %p, *piFilelist %d\n",
2232  piFilelist, *piFilelist);
2233 
2234  pFilelistc = (srawFileList *) &(piFilelist[1]); /* new */
2235  pFilelistco = pFilelist; /* old buffer */
2236  pFilelist = pFilelistc; /* first new buffer */
2237 
2238  for (ii=1; ii<=iEntries; ii++)
2239  {
2240  if (iDebug == 2) fprintf(fLogFile,
2241  "DDD pFilelistc %p\n", pFilelistc);
2242  strcpy(pFilelistc->cFile, pFilelistco->cFile);
2243  pFilelistc++;
2244  pFilelistco++;
2245  }
2246 
2247  if (iDebug) fprintf(fLogFile,
2248  " %d old entries copied to new buffer, next:\n",
2249  iEntries);
2250 
2251  if (iDebug == 2) fprintf(fLogFile,
2252  "DDD free piFilelisto %p\n", piFilelisto);
2253  free(piFilelisto);
2254  piFilelisto = piFilelist;
2255 
2256  } /* (iEntries == iMaxEntries) */
2257 
2258  if (iDebug == 2) fprintf(fLogFile,
2259  "DDD pFilelistc %p\n", pFilelistc);
2260 
2261  if ( (ploc = strchr(cTemp, *pcObjDelim)) != NULL)
2262  {
2263  iFilesIgnored++;
2264  if (iFilesIgnored == 1) fprintf(fLogFile,
2265  "-W- file-specific path not yet implemented in filelist\n");
2266  fprintf(fLogFile, "-W- %s ignored\n", cTemp);
2267  continue;
2268  }
2269 
2270  if (iGlobalDir)
2271  {
2272  strcpy(pFilelistc->cFile, cPath);
2273  strncat(pFilelistc->cFile, "/", 1);
2274  }
2275  strcat(pFilelistc->cFile, cTemp);
2276  iEntries++;
2277 
2278  if (iDebug) fprintf(fLogFile,
2279  " %3d: %s \n", iEntries, pFilelistc->cFile);
2280 
2281  pFilelistc++;
2282  }
2283  else
2284  break;
2285 
2286  } /* read loop */
2287 
2288  *piGlobalDir = iGlobalDir; /* for caller */
2289 
2290  pFilelistc = pFilelist;
2291  if (iDebug)
2292  {
2293  fprintf(fLogFile, " after allocation:\n");
2294  for (ii=1; ii<=iEntries; ii++)
2295  {
2296  fprintf(fLogFile,
2297  " %3da: %s \n", ii, pFilelistc->cFile);
2298  pFilelistc++;
2299  }
2300  }
2301 
2302  /* check if duplicate entries */
2303  if (iEntries)
2304  {
2305  pFilelistc = pFilelist;
2306  iRemove = 0;
2307  for (ii=1; ii<iEntries; ii++)
2308  {
2309  if (strlen(pFilelistc->cFile) == 0) /* already removed */
2310  {
2311  pFilelistc++;
2312  continue;
2313  }
2314 
2315  pFilelistco = pFilelistc;
2316  pFilelistco++;
2317  for (jj=ii+1; jj<=iEntries; jj++)
2318  {
2319  if (strcmp(pFilelistc->cFile, pFilelistco->cFile) == 0)
2320  {
2321  if (iDebug)
2322  fprintf(fLogFile, "-W- duplicate entry %s removed\n",
2323  pFilelistco->cFile);
2324  strcpy(pFilelistco->cFile, "");
2325  iRemove++;
2326  }
2327  pFilelistco++;
2328  }
2329 
2330  pFilelistc++;
2331  }
2332 
2333  if (iDebug)
2334  {
2335  if (iRemove) fprintf(fLogFile,
2336  " %d duplicate entries found in list\n", iRemove);
2337  else fprintf(fLogFile,
2338  " no duplicate entries found in list\n");
2339  }
2340  } /* (iEntries) */
2341  else
2342  {
2343  if (iDebug)
2344  fprintf(fLogFile, " no valid entries found in list\n");
2345  goto gEndFilelist;
2346  }
2347 
2348  pFilelistc = pFilelist;
2349  if (iDebug)
2350  {
2351  fprintf(fLogFile, " after removal of duplicates:\n");
2352  for (ii=1; ii<=iEntries; ii++)
2353  {
2354  fprintf(fLogFile,
2355  " %3db: %s \n", ii, pFilelistc->cFile);
2356  pFilelistc++;
2357  }
2358  }
2359 
2360  /* reorder remaining entries */
2361  if (iRemove)
2362  {
2363  pFilelistc = pFilelist;
2364  for (ii=1; ii<iEntries; ii++)
2365  {
2366  if (strlen(pFilelistc->cFile) == 0) /* removed */
2367  {
2368  pFilelistco = pFilelistc;
2369  pFilelistco++;
2370  pFilelistc0 = pFilelistc;
2371  for (jj=ii+1; jj<=iEntries; jj++)
2372  {
2373  strcpy(pFilelistc0->cFile, pFilelistco->cFile);
2374  pFilelistc0++;
2375  pFilelistco++;
2376  }
2377  continue;
2378  /* no ptr incr, as same location to be checked again */
2379  }
2380  pFilelistc++;
2381  }
2382  iEntries -= iRemove;
2383  }
2384 
2385  *piFilelist = iEntries; /* store result */
2386 
2387  /* check if sorting necessary */
2388  pFilelistc = pFilelist;
2389  for (ii=1; ii<=iEntries; ii++)
2390  {
2391  ploc = strchr(pFilelistc->cFile, *pcStar);
2392  if (ploc != NULL)
2393  iGeneric = 1;
2394  else
2395  {
2396  ploc = strchr(pFilelistc->cFile, *pcQM);
2397  if (ploc != NULL)
2398  iGeneric = 1;
2399  else
2400  {
2401  ploc = strchr(pFilelistc->cFile, *pcPerc);
2402  if (ploc != NULL)
2403  iGeneric = 1;
2404  else
2405  iSingle = 1;
2406  }
2407  }
2408  if ( (iGeneric) && (iSingle) )
2409  break;
2410 
2411  pFilelistc++;
2412  }
2413 
2414  /* reorder: generic names first */
2415  if ( (iGeneric) && (iSingle) )
2416  {
2417  piFilelisto = piFilelist;
2418 
2419  /* create buffer for sorted entries */
2420  iSizeBuffer = iEntries*MAX_FULL_FILE + sizeof(int);
2421  piFilelist = (int *) calloc((unsigned) iSizeBuffer, sizeof(char));
2422  if (piFilelist == NULL)
2423  {
2424  fprintf(fLogFile,
2425  "-E- %s: allocating ordered filelist buffer (size %d)\n",
2426  cModule, iSizeBuffer);
2427  if (errno)
2428  fprintf(fLogFile, " %s\n", strerror(errno));
2429  perror("-E- allocating ordered filelist buffer");
2430 
2431  iError = -1;
2432  goto gErrorFilelist;
2433  }
2434 
2435  if (iDebug) fprintf(fLogFile,
2436  " ordered filelist buffer allocated (size %d)\n",
2437  iSizeBuffer);
2438 
2439  if (iDebug == 2) fprintf(fLogFile,
2440  "DDD piFilelist %p, *piFilelist %d\n",
2441  piFilelist, *piFilelist);
2442 
2443  pFilelistc = (srawFileList *) &(piFilelist[1]);
2444  pFilelist = pFilelistc;
2445  pFilelistco = (srawFileList *) &(piFilelisto[1]);
2446  iGenericEntries = 0;
2447 
2448  /* copy generic entries */
2449  for (ii=1; ii<=iEntries; ii++)
2450  {
2451  iGeneric = 0;
2452  iSingle = 0;
2453  ploc = strchr(pFilelistco->cFile, *pcStar);
2454  if (ploc != NULL)
2455  iGeneric = 1;
2456  else
2457  {
2458  ploc = strchr(pFilelistco->cFile, *pcQM);
2459  if (ploc != NULL)
2460  iGeneric = 1;
2461  else
2462  {
2463  ploc = strchr(pFilelistco->cFile, *pcPerc);
2464  if (ploc != NULL)
2465  iGeneric = 1;
2466  else
2467  iSingle = 1;
2468  }
2469  }
2470 
2471  if (iGeneric)
2472  {
2473  strcpy(pFilelistc->cFile, pFilelistco->cFile);
2474  strcpy(pFilelistco->cFile, "");
2475  pFilelistc++;
2476  iGenericEntries++;
2477  }
2478  pFilelistco++;
2479 
2480  } /* loop pFilelistco */
2481 
2482  pFilelistco = (srawFileList *) &(piFilelisto[1]);
2483  iSingleEntries = 0;
2484 
2485  /* copy non-generic entries */
2486  for (ii=1; ii<=iEntries; ii++)
2487  {
2488  if (strlen(pFilelistco->cFile) != 0)
2489  {
2490  strcpy(pFilelistc->cFile, pFilelistco->cFile);
2491  pFilelistc++;
2492  iSingleEntries++;
2493  }
2494  pFilelistco++;
2495  }
2496 
2497  if (iDebug) fprintf(fLogFile,
2498  " %d generic file names, followed by %d non-generic file names\n",
2499  iGenericEntries, iSingleEntries);
2500 
2501  } /* (iGeneric) && (iSingle) */
2502 
2503  pFilelistc = pFilelist;
2504  if (iDebug)
2505  {
2506  fprintf(fLogFile, " after reordering:\n");
2507  for (ii=1; ii<=iEntries; ii++)
2508  {
2509  fprintf(fLogFile,
2510  " %3dc: %s \n", ii, pFilelistc->cFile);
2511  pFilelistc++;
2512  }
2513  }
2514 
2515 gEndFilelist:
2516  *piEntries = iEntries;
2517  iError = 0;
2518 
2519  if ( (iDebug == 2) && (pccT) ) fprintf(fLogFile,
2520  "DDD piFilelist %p, *piFilelist %d\n",
2521  piFilelist, *piFilelist);
2522 
2523 gErrorFilelist:
2524  if (fiFile)
2525  {
2526  iRC = fclose(fiFile);
2527  if (iRC)
2528  {
2529  fprintf(fLogFile, "-E- %s: closing filelist %s\n",
2530  cModule, pcFileName);
2531  if (errno)
2532  fprintf(fLogFile, " %s\n", strerror(errno));
2533  perror("-E- closing filelist");
2534  }
2535  }
2536 
2537  *piDataFS = iDataFS;
2538  piEntryList = piFilelist; /* pass to external pointer */
2539 
2540  if (iDebug)
2541  printf("-D- end %s\n\n", cModule);
2542 
2543  return iError;
2544 
2545 } /* rawGetFilelistEntries */
2546 
2547 /********************************************************************
2548  * rawGetWSInfo: get workspace and pool info from master server
2549  *
2550  * created 30. 6.2003 by Horst Goeringer
2551  ********************************************************************
2552  */
2553 
2554 int rawGetWSInfo( srawCliActionComm *pCliActionComm,
2555  srawPoolStatus *pPoolInfo,
2556  srawWorkSpace **ppWorkSpace,
2557  char *pcReportReadCache, char *pcReportGlobalReadCache)
2558 {
2559  char cModule[32] = "rawGetWSInfo";
2560  int iDebug = 0;
2561 
2562  int iRC = 0;
2563  int iSocket = 0;
2564  int iPoolInfo = 1; /* =1: provide info on stage pool(s) */
2565  int iPrintPoolInfo = 0; /* =1: print info on stage pool(s) */
2566  int iWorkSpaceInfo = 0; /* =1: provide info on workspace */
2567  char cMsg[STATUS_LEN] = "";
2568 
2569  int iAction = 0;
2570  int iBuf;
2571  int ii, ii1, ii2;
2572  int iIdent = 0;
2573  int iStatus = 0;
2574  int iAttrLen = 0;
2575 
2576  int iPoolId = 0; /* identifier of requested pool, = 0: all */
2577  int iSleepClean = 0; /* sleep if clean job needs started */
2578 
2579  int iPoolmax = 0;
2580  int iPoolcur = 0;
2581  int iBufPool = 0;
2582 
2583  char cPoolNameRetr[32] = "RetrievePool";
2584  char cPoolNameStage[32] = "StagePool";
2585  int iHardwareMax = 0; /* max space in hardware (GByte) */
2586  int iHardwareFree = 0; /* free space in hardware (GByte) */
2587  int iPoolRetrMax = 0; /* overall size of RetrievePool (GByte) */
2588  int iPoolRetrFree = 0; /* free space of RetrievePool (GByte) */
2589  int iPoolRetrFiles = 0; /* no. of files stored in RetrievePool */
2590  int iPoolStageMax = 0; /* overall size of StagePool (GByte) */
2591  int iPoolStageFree = 0; /* free space of StagePool (GByte) */
2592  int iPoolStageFiles = 0; /* no. of files stored in StagePool */
2593 
2594  int iPoolStageAvail = 0; /* guaranteed availability (days) */
2595  int iRandomExcess = 0;
2596  /* unused space of other pools used in RetrievePool (GByte) */
2597  int iPoolStageMaxWS = 0; /* max WS size in StagePool (GByte) */
2598  int iPoolStageCheck = 0;
2599  /* min work space check size for StagePool (GByte) */
2600  int iStageSizeUnavail = 0;
2601  /* StagePool space currently allocated by other pools */
2602 
2603  int iWorkSizeNew = 0;
2604  /* still to be staged for requested work space (MByte) */
2605  int iWorkSizeAll = 0; /* size of requested work space (MByte) */
2606  int iWorkFilesAll = 0; /* total no. of files in work space */
2607  int iWorkSizeSta = 0; /* part of requ. work space already staged */
2608  int iWorkFilesSta = 0;
2609  /* no. of files in work space already staged */
2610  int iWorkSizeStaStage = 0;
2611  /* part of staged work space in StagePool */
2612  int iWorkFilesStaStage = 0; /* no. of staged files in StagePool */
2613  int iWorkSizeStaRetr = 0;
2614  /* part of staged work space in RetrievePool */
2615  int iWorkFilesStaRetr = 0; /* no. of staged files in RetrievePool */
2616  int iWorkSizeEst = 0; /* part of requ. work space size estimated */
2617  int iWorkFilesEst = 0;
2618  /* no. of files in work space with size estimated */
2619  int iWorkStatus = -1;
2620  /* status of work space sent by server:
2621  =0: requ. size available
2622  =3: requ. size larger than GlobalPool HW
2623  (max size in GlobalPool: limited by HW,
2624  as spec. in lxha05:/tsmapi/home/archivepooln.data)
2625  =1: not enough free space in GlobalPool
2626  =2: requ. size larger than max work size in StagePool
2627  (spec. in lxha05:/tsmapi/home/stagepooln.data) */
2628 
2629 
2630  int *piBuffer;
2631  char *pcc;
2632  char cMsgPref[8] = "";
2633  char cMisc[1024] = "";
2634  char pcGenFile[MAX_FULL_FILE] = ""; /* full (generic) file name */
2635 
2636  srawWorkSpace *pWorkSpace;
2637  srawPoolStatusData *pPoolInfoData, *pPoolInfoData0;
2638 
2639  if (iDebug)
2640  printf("\n-D- begin %s\n", cModule);
2641 
2642  piBuffer = pCliActionComm->piBuffer; /* area to receive data */
2643  iSocket = pCliActionComm->iSocket;
2644  iAction = pCliActionComm->iAction;
2645 
2646  iPoolInfo = 1;
2647  if (iAction == QUERY_POOL)
2648  {
2649  iPoolId = pCliActionComm->iStatus;
2650  if (iPoolId == 0) /* all pools */
2651  iPrintPoolInfo = 6;
2652  else
2653  {
2654  iPrintPoolInfo = iPoolId;
2655  if (iPrintPoolInfo == 5)
2656  iPrintPoolInfo = 3;
2657  }
2658 
2659  iWorkSpaceInfo = 0;
2660  }
2661  else if (iAction == STAGE)
2662  {
2663  iPoolId = pCliActionComm->iStatus;
2664  iPrintPoolInfo = iPoolId;
2665  if (iPrintPoolInfo == 5)
2666  iPrintPoolInfo = 3;
2667  iWorkSpaceInfo = 1;
2668  }
2669  else if (iAction == QUERY_WORKSPACE)
2670  {
2671  strcpy(pcGenFile, pCliActionComm->pcFile);
2672  iPoolId = 0; /* show info about StagePool and RetrievePool */
2673  iPrintPoolInfo = 6;
2674  iWorkSpaceInfo = 1;
2675  }
2676 
2677  if (iDebug)
2678  {
2679  printf(" action %d", iAction);
2680  if (iPrintPoolInfo)
2681  {
2682  printf(", print pool info");
2683 
2684  if (iAction == QUERY_POOL)
2685  {
2686  if (iPoolId)
2687  printf(", for poolId %d\n", iPoolId);
2688  else
2689  printf(", for all pools\n");
2690  }
2691  else if (iAction == STAGE)
2692  {
2693  printf(", poolId %d\n", iPoolId);
2694  }
2695  else
2696  printf("\n");
2697  }
2698  else
2699  printf("\n");
2700  }
2701 
2702  if (iPoolInfo)
2703  {
2704  pcc = (char *) piBuffer; /* header for pool info */
2705  pPoolInfo = (srawPoolStatus *) piBuffer; /* for caller */
2706  iRC = rawRecvHead(iSocket, pcc);
2707  if (iRC <= 0)
2708  {
2709  printf("-E- receiving header pool status from master server\n");
2710  return -1;
2711  }
2712 
2713  iIdent = ntohl(pPoolInfo->iIdent);
2714  iStatus = ntohl(pPoolInfo->iPoolNo);
2715  iAttrLen = ntohl(pPoolInfo->iStatusLen);
2716 
2717  if (iDebug) printf(
2718  " header pool status received (%d bytes): ident %d, status %d, attrlen %d\n",
2719  iRC, iIdent, iStatus, iAttrLen);
2720 
2721  /* expect IDENT_POOL */
2722  if (iIdent != IDENT_POOL)
2723  {
2724  if (iIdent == IDENT_STATUS)
2725  {
2726  if ( (iStatus == STA_ERROR) || (iStatus == STA_ERROR_EOF) )
2727  {
2728  printf("-E- received error status from server");
2729  if (iDebug)
2730  printf(" instead of pool info:\n");
2731  else printf(":\n");
2732 
2733  if (iAttrLen > 0)
2734  {
2735  pcc = cMsg;
2736  iRC = rawRecvError(iSocket, iAttrLen, pcc);
2737  if (iRC < 0) printf(
2738  "-E- receiving error msg from server, rc = %d\n",
2739  iRC);
2740  else printf(" %s\n", pcc);
2741  }
2742  else printf(" no error message available\n");
2743 
2744  } /* (iStatus == STA_ERROR) || (iStatus == STA_ERROR_EOF) */
2745  else
2746  {
2747  printf(
2748  "-E- unexpected status (type %d) received from server\n",
2749  iStatus);
2750  }
2751  } /* iIdent == IDENT_STATUS */
2752  else
2753  {
2754  printf(
2755  "-E- unexpected header (%d) received from server\n",
2756  iIdent);
2757  }
2758 
2759  return -1;
2760 
2761  } /* (iIdent != IDENT_POOL) ) */
2762 
2763  iPoolmax = iStatus;
2764  iBufPool = iAttrLen; /* size pool buffer without header */
2765 
2766  pcc += HEAD_LEN;
2767  pPoolInfoData = (srawPoolStatusData *) pcc;
2768  pPoolInfoData0 = pPoolInfoData; /* first pool info */
2769 
2770  /* receive staging pool info */
2771  iBuf = iBufPool;
2772  while(iBuf > 0)
2773  {
2774  if ( (iRC = recv( iSocket, pcc, (unsigned) iBuf, 0 )) <= 0)
2775  {
2776  if (iRC < 0) printf(
2777  "-E- %s: receiving pool info\n", cModule);
2778  else
2779  {
2780  ii = iBufPool - iBuf;
2781  printf(
2782  "-E- %s: connection to entry server broken, %d byte of pool info (%d byte) received\n",
2783  cModule, ii, iBufPool);
2784  }
2785  if (errno)
2786  printf(" %s\n", strerror(errno));
2787  perror("-E- receiving pool info");
2788 
2789  return -1;
2790  }
2791 
2792  iBuf -= iRC;
2793  pcc += iRC;
2794 
2795  } /* while(iBuf > 0) */
2796 
2797  if (iDebug)
2798  {
2799  printf(" status of %d pools received (%d bytes)\n",
2800  iPoolmax, iBufPool);
2801  }
2802 
2803  /* get pool names first for info messages */
2804  if ( (iAction == QUERY_POOL) || (iAction == QUERY_WORKSPACE) ||
2805  (iAction == STAGE) )
2806  for (iPoolcur=1; iPoolcur<=iPoolmax; iPoolcur++)
2807  {
2808  if (iPoolcur == 1) /* RetrievePool */
2809  {
2810  /* convert to GByte */
2811  iPoolRetrMax = ntohl(pPoolInfoData->iMaxSize)/1000;
2812  iPoolRetrFree = ntohl(pPoolInfoData->iFreeSize)/1000;
2813 
2814  if (iPoolRetrFree < 0)
2815  {
2816  iRandomExcess = -iPoolRetrFree;
2817  iPoolRetrFree = 0;
2818  }
2819  iPoolRetrFiles = ntohl(pPoolInfoData->iFiles);
2820  if ( (iPoolRetrFree == iPoolRetrMax) && (iPoolRetrFiles > 0) )
2821  iPoolRetrFree--; /* eliminate rounding errors */
2822 
2823  if ( (iPrintPoolInfo == 1) || (iPrintPoolInfo == 6) ||
2824  (iDebug) )
2825  {
2826  sprintf(pcReportReadCache,
2827  " %s: used for 'gstore retrieve' to all file systems except lustre\n free space %8d GByte\n no min file lifetime of files\n",
2828  pPoolInfoData->cPoolName, iPoolRetrFree);
2829 
2830  if (iDebug)
2831  printf(" info1 created:\n%s", pcReportReadCache);
2832  }
2833  }
2834 
2835  if (iPoolcur == 2) /* StagePool */
2836  {
2837  /* corrected numbers, if deviating from 1st pool */
2838  iHardwareMax = ntohl(pPoolInfoData->iMaxSizeHW)/1000;
2839  iHardwareFree = ntohl(pPoolInfoData->iFreeSizeHW)/1000;
2840 
2841  iPoolStageMax = ntohl(pPoolInfoData->iMaxSize)/1000;
2842  iPoolStageFree = ntohl(pPoolInfoData->iFreeSize)/1000;
2843 
2844  if (iPoolStageFree < 0)
2845  iPoolStageFree = 0;
2846 
2847  iPoolStageFiles = ntohl(pPoolInfoData->iFiles);
2848  if ( (iPoolStageFree == iPoolStageMax) &&
2849  (iPoolStageFiles > 0) )
2850  iPoolStageFree--; /* eliminate rounding errors */
2851 
2852  iPoolStageAvail = ntohl(pPoolInfoData->iFileAvail);
2853 
2854  ii = iPoolStageFree + iPoolRetrFree;
2855  if (iHardwareFree != ii)
2856  iHardwareFree = ii; /* eliminate rounding errors */
2857 
2858  if ( (iPrintPoolInfo == 2) || (iPrintPoolInfo == 6) ||
2859  (iDebug) )
2860  {
2861  sprintf(cMisc,
2862  " %s: used for smaller staging transfers\n free space %8d GByte\n min file availability of %d days guaranteed\n",
2863  pPoolInfoData->cPoolName, iPoolStageFree,
2864  ntohl(pPoolInfoData->iFileAvail));
2865  strcat(pcReportReadCache, cMisc);
2866 
2867  if (iDebug)
2868  printf(" info21 created:\n%s", cMisc);
2869 
2870  if (iPrintPoolInfo != 2)
2871  {
2872  sprintf(cMisc,
2873  "-I- StagePool shares available disk space with RetrievePool\n free HW space %8d GByte, total HW space %8d GByte\n",
2874  iHardwareFree, iHardwareMax);
2875  strcat(pcReportReadCache, cMisc);
2876 
2877  if (iDebug)
2878  printf(" info22 created:\n%s", cMisc);
2879  }
2880  }
2881 
2882  if ( (iAction == STAGE) || (iAction == QUERY_WORKSPACE) )
2883  {
2884  /* in GB, for later use */
2885  iPoolStageMaxWS = ntohl(pPoolInfoData->iMaxWorkSize)/1000;
2886  iPoolStageCheck = ntohl(pPoolInfoData->iCheckSize)/1000;
2887  }
2888  } /* (iPoolcur == 2) */
2889 
2890  if ( (iPoolcur < iPoolmax) &&
2891  ((iPoolcur == 3) || (iPoolcur == 4)) )
2892  {
2893  if (iDebug) printf(
2894  " poolNo %d: (%s) ignored\n",
2895  iPoolcur, pPoolInfoData->cPoolName);
2896  }
2897 
2898  if (iPoolcur == iPoolmax) /* GlobalPool */
2899  {
2900  iPoolStageFiles = ntohl(pPoolInfoData->iFiles);
2901  iPoolStageMax = ntohl(pPoolInfoData->iMaxSize)/1000;
2902  iPoolStageFree = ntohl(pPoolInfoData->iFreeSize)/1000;
2903 
2904  if ( (iPoolStageFree == iPoolStageMax) &&
2905  (iPoolStageFiles > 0) )
2906  iPoolStageFree--; /* eliminate rounding errors */
2907  if (iPoolStageFree < 0)
2908  iPoolStageFree = 0;
2909 
2910  iHardwareMax = ntohl(pPoolInfoData->iMaxSizeHW)/1000;
2911  iHardwareFree = ntohl(pPoolInfoData->iFreeSizeHW)/1000;
2912 
2913  if ( (iPrintPoolInfo == 3) || (iPrintPoolInfo == 6) ||
2914  (iDebug) )
2915  {
2916  sprintf(pcReportGlobalReadCache,
2917  " %s: used for larger staging transfers and for archive from lustre\n free space %8d GByte, total HW space %8d GByte\n for staged files min file availability of %d days guaranteed\n",
2918  pPoolInfoData->cPoolName,
2919  iPoolStageFree, iPoolStageMax,
2920  iPoolStageAvail); /* known from prev. iteration */
2921 
2922  if (iDebug)
2923  printf(" info3 created:\n%s", pcReportGlobalReadCache);
2924  }
2925  } /* (iPoolcur == iPoolmax) */
2926 
2927  pPoolInfoData++;
2928 
2929  } /* loop pools */
2930 
2931  pPoolInfoData = pPoolInfoData0; /* 1st pool again */
2932 
2933  } /* (iPoolInfo) */
2934 
2935  /********************* get work space info ************************/
2936 
2937  if (iWorkSpaceInfo)
2938  {
2939  pWorkSpace = (srawWorkSpace *) pcc;
2940  *ppWorkSpace = pWorkSpace; /* for caller */
2941 
2942  iRC = rawRecvHead(iSocket, pcc);
2943  if (iRC <= 0)
2944  {
2945  printf("-E- receiving work space buffer header\n");
2946  return -1;
2947  }
2948  if (iDebug)
2949  printf("-D- header work space buffer received (%d bytes)\n",
2950  iRC);
2951 
2952  iIdent = ntohl(pWorkSpace->iIdent);
2953  iStatus = ntohl(pWorkSpace->iWorkId);
2954  iAttrLen = ntohl(pWorkSpace->iStatusLen);
2955 
2956  /* expect IDENT_WORKSPACE */
2957  if (iIdent != IDENT_WORKSPACE)
2958  {
2959  if (iIdent == IDENT_STATUS)
2960  {
2961  if ( (iStatus == STA_ERROR) || (iStatus == STA_ERROR_EOF) )
2962  {
2963  if (iDebug) printf("\n");
2964  printf("-E- received error status from server");
2965  if (iDebug)
2966  printf(" instead of work space info:\n");
2967  else printf(":\n");
2968 
2969  if (iAttrLen > 0)
2970  {
2971  pcc = (char *) piBuffer;
2972  iRC = rawRecvError(iSocket, iAttrLen, pcc);
2973  if (iRC < 0) printf(
2974  "-E- receiving error msg from server, rc = %d\n",
2975  iRC);
2976  else printf(" %s\n", pcc);
2977  }
2978  else printf(" no error message available\n");
2979 
2980  } /* (iStatus == STA_ERROR) || (iStatus == STA_ERROR_EOF) */
2981  else
2982  {
2983  printf(
2984  "-E- unexpected status (%d) received from server\n",
2985  iStatus);
2986  }
2987  } /* iIdent == IDENT_WORKSPACE */
2988  else
2989  {
2990  printf(
2991  "-E- unexpected header (%d) received from server\n",
2992  iIdent);
2993  }
2994 
2995  return -1;
2996 
2997  } /* (iIdent != IDENT_WORKSPACE) ) */
2998 
2999  /* receive work space info */
3000  iBuf = iAttrLen;
3001  pcc += HEAD_LEN;
3002  while(iBuf > 0)
3003  {
3004  if ( (iRC = recv( iSocket, pcc, (unsigned) iBuf, 0 )) <= 0)
3005  {
3006  if (iRC < 0) printf(
3007  "-E- %s: receiving work space info (%d byte)\n",
3008  cModule, iAttrLen);
3009  else
3010  {
3011  ii = iAttrLen - iBuf;
3012  printf("-E- %s: connection to sender broken, %d byte of work space info (%d byte) received\n",
3013  cModule, ii, iAttrLen);
3014  }
3015  if (errno)
3016  printf(" %s\n", strerror(errno));
3017  perror("-E- receiving work space info");
3018 
3019  return -1;
3020  }
3021 
3022  iBuf -= iRC;
3023  pcc += iRC;
3024 
3025  } /* while(iBuf > 0) */
3026 
3027  if (iDebug)
3028  printf(" remainder work space buffer received (%d byte)\n",
3029  iAttrLen);
3030 
3031  iWorkSizeAll = ntohl(pWorkSpace->iWorkSizeAll);
3032  iWorkFilesAll = ntohl(pWorkSpace->iWorkFilesAll);
3033  iWorkStatus = ntohl(pWorkSpace->iStatus);
3034  iWorkSizeSta = ntohl(pWorkSpace->iWorkSizeSta);
3035  iWorkFilesSta = ntohl(pWorkSpace->iWorkFilesSta);
3036  iWorkSizeStaStage = ntohl(pWorkSpace->iWorkSizeStaTemp);
3037  iWorkFilesStaStage = ntohl(pWorkSpace->iWorkFilesStaTemp);
3038  iWorkSizeEst = ntohl(pWorkSpace->iWorkSizeEst);
3039  iWorkFilesEst = ntohl(pWorkSpace->iWorkFilesEst);
3040 
3041  iWorkSizeStaRetr = iWorkSizeSta - iWorkSizeStaStage;
3042  iWorkFilesStaRetr = iWorkFilesSta - iWorkFilesStaStage;
3043 
3044  /* provide infos if stage of large workspace or if ws_query */
3045  if ( ((iPrintPoolInfo) &&
3046  (iWorkFilesAll > MIN_SEQUENTIAL_FILES)) ||
3047  (iAction == QUERY_WORKSPACE) || (iDebug) )
3048  {
3049  if (iAction != QUERY_WORKSPACE)
3050  {
3051  printf(" %d matching files, overall size %d MByte\n",
3052  iWorkFilesAll, iWorkSizeAll);
3053  if (iWorkFilesEst) printf(
3054  " size estimated for %d files: %d MByte\n",
3055  iWorkFilesEst, iWorkSizeEst);
3056 
3057  if (iWorkSizeSta == iWorkSizeAll)
3058  {
3059  if (iDebug) printf(
3060  " all files already available on staging disk\n");
3061  }
3062  else if (iWorkSizeSta)
3063  {
3064  if (iDebug)
3065  {
3066  printf(
3067  " %d files already available on staging disk (%d MByte)\n",
3068  iWorkFilesSta, iWorkSizeSta);
3069  if (iWorkFilesStaStage) printf(
3070  " %d files already in %s (%d MByte)\n",
3071  iWorkFilesStaStage, cPoolNameStage, iWorkSizeStaStage);
3072  }
3073 
3074  printf(" %d files still to be staged (%d MByte)\n",
3075  iWorkFilesAll-iWorkFilesSta,
3076  iWorkSizeAll - iWorkSizeSta);
3077  }
3078  else
3079  printf(" all files to be staged\n");
3080  }
3081 
3082  /* handle problems or limitations indicated by iWorkStatus:
3083  = 0: needed size ws available
3084  = 3: needed size ws > size GlobalPool
3085  = 1: overall size ws > free size GlobalPool
3086  = 2: overall size ws > allowed size of ws in StagePool
3087  */
3088 
3089  if (iWorkStatus != 0)
3090  {
3091  if ( (iAction == QUERY_WORKSPACE) &&
3092  ((iWorkStatus == 1) || (iWorkStatus == 3)) )
3093  {
3094  strcpy(cMsgPref, "-W-");
3095  printf("%s requested workspace cannot be staged completely\n",
3096  cMsgPref);
3097  }
3098 
3099  if (iWorkStatus < 0)
3100  printf("%s staging disk pool currently unavailable\n",
3101  cMsgPref);
3102  else if (iWorkStatus == 3)
3103  {
3104  printf( "%s overall size of %s is limited to %d GByte\n",
3105  cMsgPref, cPoolNameStage, iPoolStageMax);
3106  printf(
3107  "-I- Please reduce your work space requirements\n");
3108  }
3109  else if (iWorkStatus == 1)
3110  {
3111  printf(" currently free in cache: %d GByte\n",
3112  iPoolStageFree);
3113  printf(
3114  " still needed: %d MByte (%d files)\n",
3115  iWorkSizeAll-iWorkSizeSta,
3116  iWorkFilesAll-iWorkFilesSta);
3117  if (iAction == QUERY_WORKSPACE)
3118  printf( "-I- Check later again!\n");
3119  else printf(
3120  "-I- Query work space status before retrying later!\n");
3121  }
3122  else if (iWorkStatus != 2) printf(
3123  "-E- unexpected workspace status received from server (%d)\n",
3124  iWorkStatus);
3125 
3126  iWorkStatus = 0;
3127 
3128  } /* (iWorkStatus != 0) */
3129 
3130  if ( (iDebug) && (iWorkSizeSta != iWorkSizeAll) )
3131  {
3132  if (iAction == QUERY_WORKSPACE)
3133  {
3134  iWorkSizeNew = iWorkSizeAll - iWorkSizeSta;
3135  if (iRandomExcess)
3136  {
3137  if (iWorkSizeNew > iHardwareFree)
3138  {
3139  printf(" currently unused in %s: %d GByte\n",
3140  cPoolNameStage, iPoolStageFree);
3141  printf(
3142  " currently free in %s: %d GByte, remainder temporarily used by other pools\n",
3143  cPoolNameStage, iHardwareFree);
3144  }
3145  else printf(
3146  " currently free in cache: %d GByte\n",
3147  iHardwareFree);
3148  }
3149  else printf(
3150  " currently free in cache: %d GByte\n",
3151  iPoolStageFree);
3152 
3153  } /* (iAction == QUERY_WORKSPACE) */
3154  } /* (iWorkSizeSta != iWorkSizeAll) */
3155 
3156  /* server set clean request, implemented??? DDD */
3157  if (iWorkStatus >= 9)
3158  {
3159  if (iDebug)
3160  {
3161  /* if (ntohl(pPoolInfoData->iFreeSize) >= 0)
3162  does not work in Linux:
3163  negative values are not recognized! */
3164  ii = ntohl(pPoolInfoData0->iFreeSize);
3165 
3166  printf("-D- currently free (HW): %d GByte\n",
3167  iHardwareFree);
3168  printf(
3169  " currently %d MByte unused in %s are allocated by other pools\n",
3170  ii*(-1), cPoolNameStage);
3171  }
3172 
3173  if (iAction == QUERY_WORKSPACE)
3174  strcpy(cMisc, "must be initiated (gstore stage)");
3175  else
3176  strcpy(cMisc, "is initiated");
3177  printf(
3178  "-I- a clean job %s to provide the requested space\n",
3179  cMisc);
3180 
3181  if (iWorkStatus > 9)
3182  {
3183  /* iSleepClean = iWorkStatus*60; */ /* in sec */
3184  iSleepClean = iWorkStatus;
3185  /* if (iDebug)
3186  printf("-D- sleep for %ds\n", iSleepClean);
3187  sleep(iSleepClean);
3188  */
3189  }
3190 
3191  } /* (iWorkStatus >= 9) */
3192 
3193  } /* (iPoolInfo) || (iAction == QUERY_WORKSPACE) */
3194  } /* (iWorkSpaceInfo) */
3195 
3196  if (iDebug)
3197  printf("-D- end %s\n\n", cModule);
3198 
3199  return 0;
3200 
3201 } /* rawGetWSInfo */
3202 
3203 /********************************************************************
3204  * rawGetFullFile: get full file name from generic input and ll name
3205  * returns full file name
3206  *
3207  * created 18. 3.1996, Horst Goeringer
3208  ********************************************************************
3209  */
3210 
3211 char *rawGetFullFile(char *pcFile, char *pcNamell)
3212 {
3213 
3214  char cModule[32] = "rawGetFullFile";
3215  int iDebug = 0;
3216 
3217  char cname1[MAX_FULL_FILE] = ""; /* name structure assumed: */
3218  int ilen;
3219  int iRC;
3220 
3221  char *pdelim=NULL, *pdelim2=NULL;
3222  char *pc, *pcll;
3223 
3224  if (iDebug)
3225  fprintf(fLogFile, "\n-D- begin %s\n", cModule);
3226 
3227  strcpy(cPath, pcFile);
3228  pdelim = strrchr(cPath, *pcFileDelim);
3229  if (pdelim != NULL) /* path specified */
3230  {
3231  strncpy(pdelim, "\0", 1);
3232  strcpy(cname1, ++pdelim);
3233  }
3234  else
3235  {
3236 #ifdef VMS
3237  pdelim2 = strrchr(cPath, *pcFileDelim2);
3238  if (pdelim2 != NULL) /* logical device specified */
3239  {
3240  strncpy(pdelim2, "\0", 1);
3241  strcpy(cname1, ++pdelim2);
3242  }
3243  else
3244  {
3245 #endif
3246  strncpy(cPath, "\0", 1);
3247  strcpy(cname1, pcFile);
3248 #ifdef VMS
3249  }
3250 #endif
3251  } /* (pdelim == NULL) */
3252 
3253  ilen = strlen(cname1);
3254  if (iDebug)
3255  {
3256 #ifdef VMS
3257  if (pdelim != NULL)
3258  fprintf(fLogFile, "-D- %s: path %s], name1: %s (len %d)\n",
3259  cModule, cPath, cname1, ilen);
3260  /* !!! bracket in fprintf needed, as not yet in cPath */
3261  else
3262  {
3263  if (pdelim2 != NULL)
3264  fprintf(fLogFile, "-D- %s: device %s, name1: %s (len %d)\n",
3265  cModule, cPath, cname1, ilen);
3266  else
3267  fprintf(fLogFile, "-D- %s: no prefix, name1: %s (len %d)\n",
3268  cModule, cname1, ilen);
3269  }
3270 #else
3271  fprintf(fLogFile,
3272  " path: %s, name1: %s (len %d)\n", cPath, cname1, ilen);
3273 #endif
3274  }
3275 
3276  pc = &cname1[0];
3277  pcll = pcNamell;
3278  iRC = strncmp(pcll, pcObjDelim, 1);
3279  if (iRC == 0) pcll++; /* skip object delimiter */
3280  else
3281  {
3282  iRC = strncmp(pcll, pcObjDelimAlt, 1);
3283  if (iRC == 0) pcll++; /* skip object delimiter */
3284  }
3285 
3286  if (strlen(cPath) > 0)
3287  {
3288 #ifdef VMS
3289  if (pdelim2 != NULL)
3290  strcat(cPath, pcFileDelim2);
3291  else
3292 #endif
3293  strcat(cPath, pcFileDelim);
3294  }
3295  strcat(cPath, pcll);
3296  if (iDebug) fprintf(fLogFile,
3297  "-D- end %s: full file name found: %s\n\n", cModule, cPath);
3298 
3299  return( (char *) cPath);
3300 
3301 } /* rawGetFullFile */
3302 
3303 /*********************************************************************
3304  * rawQueryPrint: print query results for one object
3305  * created 19. 2.1996, Horst Goeringer
3306  *********************************************************************
3307  */
3308 
3310  srawObjAttr *pQAttr,
3311  int ipMode) /* = 0: default print mode,
3312  = 1: debug print mode,
3313  = 10: default print mode, stage status unknown
3314  = 11: debug print mode, stage status unknown
3315  */
3316 {
3317  char cModule[32]="rawQueryPrint";
3318  char ctype[8] = "";
3319  char cMClass[12] = "";
3320  char cPath[MAX_OBJ_HL];
3321  char cStatus[16] = "";
3322 
3323  int ii;
3324  int iStage = 0; /* StagePool (read cache) */
3325  int iCache = 0; /* ArchivePool (write cache) */
3326  int iATLServer = 0; /* =1: aixtsm1(AIX), =2: gsitsma(Windows) */
3327  int iFileType = -1;
3328  int iMediaClass = 0;
3329 
3330  unsigned long *plFileSizeC; /* 8 byte filesize */
3331  unsigned long lFileSize; /* 8 byte filesize */
3332  int iVersionObjAttr = 0;
3333  /* version no. of srawObjAttr:
3334  =3: 288 byte, 2 restore fields
3335  =4: 304 byte, 5 restore fields, ATL server no.
3336  =5: 384 byte, maior enhancement */
3337 
3338  iVersionObjAttr = ntohl(pQAttr->iVersion);
3339  if ( (ipMode == 1) || (ipMode == 11) ) fprintf(fLogFile,
3340  "\n-D- begin %s: objAttr V%d\n", cModule, iVersionObjAttr);
3341 
3342  if ( (iVersionObjAttr != VERSION_SRAWOBJATTR) &&
3343  (iVersionObjAttr != VERSION_SRAWOBJATTR-1) )
3344  {
3345  fprintf(fLogFile,
3346  "-E- %s: invalid cacheDB entry version %d\n",
3347  cModule, iVersionObjAttr);
3348 
3349  return;
3350  }
3351 
3352  iFileType = ntohl(pQAttr->iFileType);
3353  iMediaClass = ntohl(pQAttr->iMediaClass);
3354  iATLServer = ntohl(pQAttr->iATLServer);
3355 
3356  switch(iMediaClass)
3357  {
3358  case MEDIA_FIXED:
3359  strcpy(cMClass, "DISK ");
3360  break;
3361  case MEDIA_LIBRARY:
3362  strcpy(cMClass, "TAPE ");
3363  break;
3364  case MEDIA_NETWORK:
3365  strcpy(cMClass, "NETWORK");
3366  break;
3367  case MEDIA_SHELF:
3368  strcpy(cMClass, "SHELF");
3369  break;
3370  case MEDIA_OFFSITE:
3371  strcpy(cMClass, "OFFSITE");
3372  break;
3373  case MEDIA_UNAVAILABLE:
3374  strcpy(cMClass, "UNAVAILABLE");
3375  break;
3376  case GSI_MEDIA_STAGE:
3377  case GSI_MEDIA_LOCKED:
3378  strcpy(cMClass, "STAGE");
3379  strcpy(cStatus, "staged");
3380  iStage = 1;
3381  break;
3382  case GSI_MEDIA_INCOMPLETE:
3383  strcpy(cMClass, "STAGE*");
3384  strcpy(cStatus, "still staging");
3385  iStage = 1;
3386  break;
3387  case GSI_STAGE_INVALID:
3388  strcpy(cMClass, "STAGE*");
3389  strcpy(cStatus, "staging failed");
3390  iStage = 1;
3391  break;
3392  case GSI_MEDIA_CACHE: /* GSI write cache */
3393  case GSI_CACHE_LOCKED:
3394  strcpy(cMClass, "CACHE");
3395  strcpy(cStatus, "cached");
3396  iCache = 1;
3397  break;
3398  case GSI_CACHE_INCOMPLETE:
3399  strcpy(cMClass, "CACHE*");
3400  strcpy(cStatus, "still caching");
3401  iCache = 1;
3402  break;
3403  case GSI_CACHE_COPY:
3404  strcpy(cMClass, "CACHE");
3405  strcpy(cStatus, "still copying");
3406  iCache = 1;
3407  break;
3408  default:
3409  fprintf(fLogFile, "-E- Invalid media class %d found\n",
3410  iMediaClass);
3411  break;
3412  }
3413 
3414  if (iATLServer)
3415  {
3416  if (iATLServer < 0)
3418 
3419  ii = MAX_ATLSERVER;
3420  if (ii > 1)
3421  sprintf(cMClass, "%s%d", cMClass, iATLServer);
3422  else
3423  sprintf(cMClass, "%s", cMClass);
3424  }
3425 
3426  if ( (ipMode == 10) || (ipMode == 11) )
3427  strcat(cMClass, "??"); /* stage status not checked */
3428 
3429  if (strlen(pQAttr->cDateCreate) == 16) /* no trailing blank */
3430  strcat(pQAttr->cDateCreate, " ");
3431  strcpy(cPath, (char *) rawGetPathName(pQAttr->cNamehl));
3432  fprintf(fLogFile, "%s%s%s %s %s %s",
3433  pQAttr->cNamefs, cPath, pQAttr->cNamell,
3434  pQAttr->cOwner, pQAttr->cDateCreate, cMClass);
3435 
3436  pQAttr->iFileSize = ntohl(pQAttr->iFileSize);
3437  pQAttr->iFileSize2 = ntohl(pQAttr->iFileSize2);
3438  plFileSizeC = (unsigned long *) &(pQAttr->iFileSize);
3439  lFileSize = *plFileSizeC;
3440 
3441  if (lFileSize)
3442  {
3443  if ( (pQAttr->iFileSize2 == 0) ||
3444  (sizeof(long) == 8) )
3445  fprintf(fLogFile, " %12lu", lFileSize);
3446  else
3447  fprintf(fLogFile, " %s ", cTooBig);
3448  }
3449 
3450  /* reconvert to net format */
3451  pQAttr->iFileSize = htonl(pQAttr->iFileSize);
3452  pQAttr->iFileSize2 = htonl(pQAttr->iFileSize2);
3453 
3454  if (iStage)
3455  fprintf(fLogFile, " %s %s", pQAttr->cNode, pQAttr->cStageUser);
3456  if (iCache)
3457  fprintf(fLogFile, " %s", pQAttr->cNode);
3458  fprintf(fLogFile, "\n");
3459 
3460  if ( (ipMode == 1) || (ipMode == 11) )
3461  {
3462  if (ntohl(pQAttr->iFS))
3463  fprintf(fLogFile, " on data mover %s in pool FS %d (poolId %d)\n",
3464  pQAttr->cNode, ntohl(pQAttr->iFS),
3465  ntohl(pQAttr->iPoolId));
3466  fprintf(fLogFile,
3467  " obj-Id: %u-%u, restore order: %u-%u-%u-%u-%u\n",
3468  ntohl(pQAttr->iObjHigh),
3469  ntohl(pQAttr->iObjLow),
3470  ntohl(pQAttr->iRestoHigh),
3471  ntohl(pQAttr->iRestoHighHigh),
3472  ntohl(pQAttr->iRestoHighLow),
3473  ntohl(pQAttr->iRestoLowHigh),
3474  ntohl(pQAttr->iRestoLow) );
3475  fprintf(fLogFile,
3476  " owner: %s, OS: %.8s, mgmt-class: %s, file set %d\n",
3477  pQAttr->cOwner,
3478  pQAttr->cOS, pQAttr->cMgmtClass, ntohl(pQAttr->iFileSet));
3479  }
3480 
3481  if ( (ipMode == 1) || (ipMode == 11) )
3482  fprintf(fLogFile, "-D- end %s\n\n", cModule);
3483 
3484 } /* rawQueryPrint */
3485 
3486 /*********************************************************************/
3487 /* rawQueryString: print query results for one object to string */
3488 /* created 19. 2.96, Horst Goeringer */
3489 /*********************************************************************/
3490 
3492  srawObjAttr *pQAttr,
3493  int ipMode, /* = 0: default print mode,
3494  = 1: debug print mode,
3495  = 10: default print mode, stage status unknown
3496  = 11: debug print mode, stage status unknown */
3497  int iOut, /* length output string */
3498  char *pcOut)
3499 {
3500  char cModule[32] = "rawQueryString";
3501  int iDebug = 0;
3502 
3503  int iMsg = 0;
3504  char ctype[8] = "";
3505  char cMClass[12] = "";
3506  char cPath[MAX_OBJ_HL];
3507  char cMsg[STATUS_LEN_LONG] = "";
3508  char cMsg1[STATUS_LEN] = "";
3509 
3510  int ii;
3511  int iStage = 0; /* StagePool (read cache) */
3512  int iCache = 0; /* ArchivePool (write cache) */
3513  int iATLServer; /* =1: aixtsm1(AIX), =2: gsitsma(Windows) */
3514  int iFileType = -1;
3515  int iMediaClass = 0;
3516 
3517  unsigned long *plFileSizeC; /* 8 byte filesize */
3518  unsigned long lFileSize; /* 8 byte filesize */
3519  int iVersionObjAttr = 0;
3520  /* version no. of srawObjAttr:
3521  =3: 288 byte, 2 restore fields
3522  =4: 304 byte, 5 restore fields, ATL server no.
3523  =5: 384 byte, maior enhancement */
3524 
3525  iVersionObjAttr = ntohl(pQAttr->iVersion);
3526  if (iDebug) fprintf(fLogFile,
3527  "\n-D- begin %s: version ObjAttr %d\n", cModule, iVersionObjAttr);
3528 
3529  if ( (iVersionObjAttr != VERSION_SRAWOBJATTR) &&
3530  (iVersionObjAttr != VERSION_SRAWOBJATTR-1) )
3531  {
3532  fprintf(fLogFile,
3533  "-E- %s: invalid cacheDB entry version %d\n",
3534  cModule, iVersionObjAttr);
3535 
3536  return 0;
3537  }
3538 
3539  iFileType = ntohl(pQAttr->iFileType);
3540  iMediaClass = ntohl(pQAttr->iMediaClass);
3541  iATLServer = ntohl(pQAttr->iATLServer);
3542 
3543  switch(iMediaClass)
3544  {
3545  case MEDIA_FIXED:
3546  strcpy(cMClass, "DISK ");
3547  break;
3548  case MEDIA_LIBRARY:
3549  strcpy(cMClass, "TAPE ");
3550  break;
3551  case MEDIA_NETWORK:
3552  strcpy(cMClass, "NETWORK");
3553  break;
3554  case MEDIA_SHELF:
3555  strcpy(cMClass, "SHELF");
3556  break;
3557  case MEDIA_OFFSITE:
3558  strcpy(cMClass, "OFFSITE");
3559  break;
3560  case MEDIA_UNAVAILABLE:
3561  strcpy(cMClass, "UNAVAILABLE");
3562  break;
3563  case GSI_MEDIA_STAGE:
3564  case GSI_MEDIA_LOCKED:
3565  strcpy(cMClass, "STAGE");
3566  iStage = 1;
3567  break;
3568  case GSI_MEDIA_INCOMPLETE:
3569  case GSI_STAGE_INVALID:
3570  strcpy(cMClass, "STAGE*");
3571  break;
3572  case GSI_MEDIA_CACHE: /* GSI write cache */
3573  case GSI_CACHE_LOCKED:
3574  strcpy(cMClass, "CACHE");
3575  iCache = 1;
3576  break;
3577  case GSI_CACHE_INCOMPLETE:
3578  case GSI_CACHE_COPY:
3579  strcpy(cMClass, "CACHE*");
3580  iCache = 1;
3581  break;
3582  default:
3583  fprintf(fLogFile, "-E- Invalid media class %d found\n",
3584  iMediaClass);
3585  break;
3586  }
3587 
3588  if (iATLServer)
3589  {
3590  if (iATLServer < 0)
3592 
3593  ii = MAX_ATLSERVER;
3594  if (ii > 1)
3595  sprintf(cMClass, "%s%d", cMClass, iATLServer);
3596  else
3597  sprintf(cMClass, "%s", cMClass);
3598  }
3599  if ( (ipMode == 10) || (ipMode == 11) )
3600  strcat(cMClass, "??"); /* stage status not checked */
3601 
3602  if (strlen(pQAttr->cDateCreate) == 16) /* no trailing blank */
3603  strcat(pQAttr->cDateCreate, " ");
3604  strcpy(cPath, (char *) rawGetPathName(pQAttr->cNamehl));
3605 
3606  sprintf(cMsg, "%s%s%s %s %s %s",
3607  pQAttr->cNamefs, cPath, pQAttr->cNamell,
3608  pQAttr->cOwner, pQAttr->cDateCreate, cMClass);
3609 
3610  pQAttr->iFileSize = ntohl(pQAttr->iFileSize);
3611  pQAttr->iFileSize2 = ntohl(pQAttr->iFileSize2);
3612  plFileSizeC = (unsigned long *) &(pQAttr->iFileSize);
3613  lFileSize = *plFileSizeC;
3614 
3615  /* reconvert to net format */
3616  pQAttr->iFileSize = htonl(pQAttr->iFileSize);
3617  pQAttr->iFileSize2 = htonl(pQAttr->iFileSize2);
3618 
3619  if (lFileSize)
3620  {
3621  if ( (pQAttr->iFileSize2 == 0) ||
3622  (sizeof(long) == 8) )
3623  sprintf(cMsg1, " %12lu", lFileSize);
3624  else
3625  sprintf(cMsg1, " %s ", cTooBig);
3626  strcat(cMsg, cMsg1);
3627  }
3628  if (iStage)
3629  {
3630  sprintf(cMsg1, " %s %s", pQAttr->cNode, pQAttr->cStageUser);
3631  strcat(cMsg, cMsg1);
3632  }
3633  if (iCache)
3634  {
3635  sprintf(cMsg1, " %s", pQAttr->cNode);
3636  strcat(cMsg, cMsg1);
3637  }
3638  strcat(cMsg, "\n");
3639 
3640  if ( (ipMode == 1) || (ipMode == 11) )
3641  {
3642  if (ntohl(pQAttr->iFS))
3643  {
3644  sprintf(cMsg1,
3645  " on data mover %s, FS %d (poolId %d)\n",
3646  pQAttr->cNode, ntohl(pQAttr->iFS),
3647  ntohl(pQAttr->iPoolId));
3648  strcat(cMsg, cMsg1);
3649  }
3650 
3651  sprintf(cMsg1,
3652  " obj-Id: %u-%u, restore order: %u-%u-%u-%u-%u\n",
3653  ntohl(pQAttr->iObjHigh),
3654  ntohl(pQAttr->iObjLow),
3655  ntohl(pQAttr->iRestoHigh),
3656  ntohl(pQAttr->iRestoHighHigh),
3657  ntohl(pQAttr->iRestoHighLow),
3658  ntohl(pQAttr->iRestoLowHigh),
3659  ntohl(pQAttr->iRestoLow) );
3660  strcat(cMsg, cMsg1);
3661 
3662  sprintf(cMsg1,
3663  " version %d, owner: %s, OS: %s, mgmt-class: %s, file set %d\n",
3664  ntohl(pQAttr->iVersion), pQAttr->cOwner,
3665  pQAttr->cOS, pQAttr->cMgmtClass, ntohl(pQAttr->iFileSet));
3666  strcat(cMsg, cMsg1);
3667  }
3668 
3669  iMsg = strlen(cMsg);
3670 
3671  if (iOut < iMsg)
3672  {
3673  fprintf(fLogFile,
3674  "-W- %s: output string provided too short (%d byte), %d byte needed\n",
3675  cModule, iOut, iMsg);
3676  strncpy(pcOut, cMsg, (unsigned) iOut-1);
3677  strcat(pcOut, "\0");
3678 
3679  fprintf(fLogFile,
3680  "-W- %s: query information incomplete:\n%s\n", cModule, pcOut);
3681 
3682  iMsg = iOut;
3683  }
3684  else
3685  {
3686  if (iDebug) fprintf(fLogFile,
3687  " %s: length query info %d byte, length of string provided %d byte, msg:\n",
3688  cModule, iMsg, iOut);
3689  strcpy(pcOut, cMsg);
3690  }
3691 
3692  if (iDebug)
3693  fprintf(fLogFile, "-D- end %s\n\n", cModule);
3694 
3695  return iMsg;
3696 
3697 } /* rawQueryString */
3698 
3699 /**********************************************************************
3700  * rawScanObjbuf:
3701  * check if obj already available in obj buffer chain
3702  * created 10. 7.2003 by Horst Goeringer
3703  **********************************************************************
3704  */
3705 
3706 int rawScanObjbuf(char *pcPath, char *pcFile,
3707  int iObjnoAll, int *piObjBuf0)
3708 {
3709  char cModule[32] = "rawScanObjbuf";
3710  int iDebug = 0;
3711 
3712  int ii;
3713  int iFound = 0; /* =1: specified file already available in list */
3714  int iObjnoBuf; /* no. of objects in current buffer */
3715  int iObjnoCur = 0; /* current object no. (in all buffers) */
3716  int iBufno = 0; /* no. of object buffers */
3717  int *piObjBuf; /* ptr to current object buffer */
3718  int **ppiNextBuf;
3719 
3720  srawRetrList *psRetrList; /* points to object in buffer chain */
3721 
3722  if (iDebug)
3723  printf("\n-D- begin %s: check %d objs for %s%s\n",
3724  cModule, iObjnoAll, pcPath, pcFile);
3725 
3726  piObjBuf = piObjBuf0;
3727 
3728  /* loop over object buffers */
3729  for (;;)
3730  {
3731  iObjnoBuf = *piObjBuf;
3732  psRetrList = (srawRetrList *) &(piObjBuf[1]);
3733  iBufno++;
3734  if (iDebug == 2)
3735  {
3736  printf("DDD buffer %d: piObjBuf %p, value %d, psRetrList %p\n",
3737  iBufno, piObjBuf, *piObjBuf, psRetrList);
3738  fflush(stdout);
3739  }
3740 
3741  /* loop over objects in current buffer */
3742  for (ii=1; ii<=iObjnoBuf; ii++)
3743  {
3744  iObjnoCur++;
3745  if (iDebug == 2)
3746  {
3747  printf(" %d: %s%s, addr %p\n",
3748  iObjnoCur, psRetrList->cNamehl, psRetrList->cNamell,
3749  psRetrList);
3750  fflush(stdout);
3751  }
3752 
3753  if ( (strcmp(pcFile, psRetrList->cNamell) == 0) &&
3754  (strcmp(pcPath, psRetrList->cNamehl) == 0) )
3755  {
3756  if (iDebug) printf(
3757  " file %s%s already available in list\n",
3758  pcPath, pcFile);
3759  iFound = 1;
3760  goto gEndScan;
3761  }
3762 
3763  psRetrList++;
3764 
3765  } /* loop over objects in current buffer */
3766 
3767  if (iObjnoCur == iObjnoAll)
3768  {
3769  if (iDebug) printf(
3770  " all %d files scanned\n", iObjnoAll);
3771  break;
3772  }
3773 
3774  if (psRetrList)
3775  {
3776  ppiNextBuf = (int **) psRetrList;
3777  piObjBuf = *ppiNextBuf;
3778  psRetrList = (srawRetrList *) &(piObjBuf[1]);
3779  if (iDebug == 2)
3780  {
3781  printf("DDD next piObjBuf %p, value %d, psRetrList %p\n",
3782  piObjBuf, *piObjBuf, psRetrList);
3783  fflush(stdout);
3784  }
3785  }
3786  else /* last buffer */
3787  break;
3788 
3789  } /* loop over buffers */
3790 
3791 gEndScan:
3792  if (iDebug)
3793  printf("-D- end %s: %d buffers scanned\n\n", cModule, iBufno);
3794 
3795  if (iFound)
3796  return 1;
3797  else
3798  return 0;
3799 
3800 } /* end rawScanObjbuf */
3801 
3802 /**********************************************************************
3803  * rawSortValues:
3804  * sort indexed list of numbers
3805  * created 15. 6.2000 by Horst Goeringer
3806  **********************************************************************
3807  */
3808 
3810  int *iaValue,
3811  int iAll,
3812  int iFirst,
3813  int iLast,
3814  int *iaIndex,
3815  int *iaIndNew)
3816 {
3817  char cModule[32] = "rawSortValues";
3818  int iDebug = 0;
3819 
3820  int ii, ii1, iif, jj;
3821  int iLoop;
3822  int iInd;
3823  int iFound = 0;
3824  int iaValNew[iAll+1];
3825 
3826  iLoop = iLast - iFirst + 1;
3827 
3828  if (iDebug)
3829  printf("\n-D- begin %s\n", cModule);
3830 
3831  if (iDebug)
3832  {
3833  printf(" numbers on input:\n value index\n");
3834  for (ii=iFirst; ii<=iLast; ii++)
3835  {
3836  printf(" %6d: %10d %6d\n", ii, iaValue[ii], iaIndex[ii]);
3837  }
3838  }
3839 
3840  iFound = iFirst - 1; /* 1st possible index: iFirst */
3841  for (jj=iFirst; jj<=iLast; jj++)
3842  {
3843  if (iFound >= iFirst)
3844  {
3845  for (iif=iFirst; iif<=iFound; iif++)
3846  {
3847  if ( (iaValue[jj] < iaValNew[iif]) && (iaValNew[iif]) )
3848  {
3849  for (ii1=iFound; ii1>=iif; ii1--)
3850  {
3851  iaValNew[ii1+1] = iaValNew[ii1];
3852  iaIndNew[ii1+1] = iaIndNew[ii1];
3853  }
3854 
3855  iaValNew[iif] = iaValue[jj];
3856  iaIndNew[iif] = iaIndex[jj];
3857  iFound++;
3858  if (iDebug == 2) fprintf(fLogFile,
3859  " at pos %d inserted: val %d, ind %d\n",
3860  iif, iaValNew[iif], iaIndNew[iif]);
3861 
3862  break;
3863  }
3864  else
3865  {
3866  if (iif == iFound)
3867  {
3868  iFound++;
3869  iaValNew[iFound] = iaValue[jj];
3870  iaIndNew[iFound] = iaIndex[jj];
3871  if (iDebug == 2) fprintf(fLogFile,
3872  " at pos %d appended: val %d, ind %d\n",
3873  iFound, iaValNew[iFound], iaIndNew[iFound]);
3874 
3875  break; /* loop iif */
3876  }
3877 
3878  continue; /* loop iif */
3879  }
3880  } /* loop iif */
3881  } /* (iFound) */
3882  else
3883  {
3884  iaValNew[iFirst] = iaValue[jj];
3885  iaIndNew[iFirst] = iaIndex[jj];
3886  iFound = iFirst;
3887 
3888  if (iDebug == 2) fprintf(fLogFile,
3889  " start value: val %d, ind %d\n",
3890  iaValNew[iFound], iaIndNew[iFound]);
3891  }
3892  } /* loop objects */
3893 
3894  memcpy(&iaValue[iFirst], &iaValNew[iFirst], (unsigned) iLoop*iint);
3895 
3896  if (iDebug)
3897  {
3898  printf(" numbers on output:\n value index\n");
3899  for (ii=iFirst; ii<=iLast; ii++)
3900  {
3901  printf(" %6d: %10d %6d\n", ii, iaValue[ii], iaIndNew[ii]);
3902  }
3903  }
3904 
3905  if (iDebug)
3906  printf("-D- end %s\n\n", cModule);
3907 
3908  return 0;
3909 
3910 } /* end rawSortValues*/
3911 
3912 #ifdef _AIX
3913 /*********************************************************************
3914  * ielpst: Elapsed (wall-clock) time measurement
3915  *
3916  * Usage examples:
3917  *
3918  * ielpst( 1, iBuf[0..1] );
3919  * ... code ...
3920  * ElapsedTime(in microsecs) = ielpst( 1, iBuf[0..1] );
3921  *
3922  * ielpst( 1000, iBuf[0..1] );
3923  * ... code ...
3924  * ElapsedTime(in millisecs) = ielpst( 1000, iBuf[0..1] );
3925  *
3926  *********************************************************************
3927  * created 17.11.1992, Michael Kraemer
3928  *********************************************************************
3929  */
3930 
3931 unsigned long ielpst( unsigned long iScale,
3932  unsigned long *iBuf )
3933 {
3934  char cModule[32] = "ielpst";
3935  int iDebug = 0;
3936 
3937  struct timestruc_t stv;
3938  unsigned long iTemp[2];
3939 
3940  gettimer( TIMEOFDAY, &stv );
3941 
3942  if ( iScale <= 0 ) iScale = 1;
3943  iTemp[1] = stv.tv_sec - iBuf[1];
3944  if ( ( iTemp[0] = stv.tv_nsec - iBuf[0] ) & 0x80000000 ) {
3945  iTemp[0] += 1000000000L; iTemp[1] -= 1;
3946  }
3947  iBuf[1] = stv.tv_sec; iBuf[0] = stv.tv_nsec;
3948  return( iTemp[1] * ( 1000000L / iScale ) + ( iTemp[0] / 1000 ) / iScale );
3949 
3950 } /* ielpst */
3951 
3952 /* FORTRAN entry */
3953 unsigned long ielpst_( unsigned long *iScale,
3954  unsigned long *iBuf )
3955 {
3956  return( ielpst( *iScale, iBuf ) );
3957 } /* ielpst_ */
3958 #endif
static unsigned int iFileList
Definition: rawCliProcn.c:184
int rawCheckFileList(char **pcFileList, char **pcObjList, char *pcArchive, char *pcNodeMaster, int iRecursive, unsigned int iuTopDir, char *pcTopDir, char *pcTophl)
Definition: rawCliProcn.c:199
static char cPath[MAX_FULL_FILE]
Definition: rawCliProcn.c:186
int * piEntryList
Definition: rawapin.c:215
FILE * fLogFile
Definition: rawapin.c:217
int rawGetWSInfo(srawCliActionComm *pCliActionComm, srawPoolStatus *pPoolInfo, srawWorkSpace **ppWorkSpace, char *pcReportReadCache, char *pcReportGlobalReadCache)
Definition: rawCliProcn.c:2554
int rawQueryString(srawObjAttr *pQAttr, int ipMode, int iOut, char *pcOut)
Definition: rawCliProcn.c:3491
int rawCheckObjList(int iObjAll, int iObjComp, int iSort, char **pcObjList, char **pcFileList, char **pcObjComp)
Definition: rawCliProcn.c:664
int rawSortValues(int *iaValue, int iAll, int iFirst, int iLast, int *iaIndex, int *iaIndNew)
Definition: rawCliProcn.c:3809
int rawScanObjbuf(char *pcPath, char *pcFile, int iObjnoAll, int *piObjBuf0)
Definition: rawCliProcn.c:3706
void rawQueryPrint(srawObjAttr *pQAttr, int ipMode)
Definition: rawCliProcn.c:3309
static unsigned int iint
Definition: rawCliProcn.c:182
static unsigned int iRetrList
Definition: rawCliProcn.c:183
char * rawGetFullFile(char *pcFile, char *pcNamell)
Definition: rawCliProcn.c:3211
int rawGetFilelistEntries(char *pcFileName, int *piDataFS, char *pcDataFS, int *piEntries, int *piGlobalDir)
Definition: rawCliProcn.c:1972
static int iATLServer
Definition: rawapin.c:246
#define GSI_CACHE_COPY
Definition: rawapitd-gsin.h:31
#define GSI_CACHE_LOCKED
Definition: rawapitd-gsin.h:28
#define GSI_STAGE_INVALID
Definition: rawapitd-gsin.h:26
#define GSI_CACHE_INCOMPLETE
Definition: rawapitd-gsin.h:29
#define GSI_MEDIA_STAGE
Definition: rawapitd-gsin.h:23
#define GSI_MEDIA_INCOMPLETE
Definition: rawapitd-gsin.h:25
#define GSI_MEDIA_CACHE
Definition: rawapitd-gsin.h:27
#define GSI_MEDIA_LOCKED
Definition: rawapitd-gsin.h:24
bool_t
Definition: rawapitd.h:29
@ bFalse
Definition: rawapitd.h:30
@ bTrue
Definition: rawapitd.h:31
#define MEDIA_NETWORK
Definition: rawapitd.h:22
#define MEDIA_SHELF
Definition: rawapitd.h:23
#define MEDIA_UNAVAILABLE
Definition: rawapitd.h:25
#define MEDIA_LIBRARY
Definition: rawapitd.h:21
#define MEDIA_FIXED
Definition: rawapitd.h:20
#define MEDIA_OFFSITE
Definition: rawapitd.h:24
static int iPathPrefix
Definition: rawclin.h:78
static char cPathPrefix[16]
Definition: rawclin.h:77
#define MAX_ATLSERVER
Definition: rawcommn.h:263
static char cDataFSHigh2[16]
Definition: rawcommn.h:305
@ STA_ERROR_EOF
Definition: rawcommn.h:552
@ STA_ERROR
Definition: rawcommn.h:551
#define IDENT_WORKSPACE
Definition: rawcommn.h:365
static const char cTooBig[8]
Definition: rawcommn.h:292
#define STATUS_LEN_LONG
Definition: rawcommn.h:357
static char cDataFSHigh1[16]
Definition: rawcommn.h:304
#define MAX_FULL_FILE
Definition: rawcommn.h:327
#define IDENT_STATUS
Definition: rawcommn.h:362
#define VERSION_SRAWOBJATTR
Definition: rawcommn.h:331
#define HEAD_LEN
Definition: rawcommn.h:355
#define MAX_OBJ_HL
Definition: rawcommn.h:337
#define MIN_SEQUENTIAL_FILES
Definition: rawcommn.h:289
#define STATUS_LEN
Definition: rawcommn.h:356
@ QUERY_POOL
Definition: rawcommn.h:443
@ STAGE
Definition: rawcommn.h:440
@ QUERY_WORKSPACE
Definition: rawcommn.h:444
#define IDENT_POOL
Definition: rawcommn.h:364
static const char * pcQM
Definition: rawdefn.h:65
static const char * pcPerc
Definition: rawdefn.h:66
static const char * pcStar
Definition: rawdefn.h:64
int rawGetLLName(char *, const char *, char *)
Definition: rawProcn.c:1107
int rawRecvError(int, int, char *)
Definition: rawProcn.c:1748
int rawRecvHead(int, char *)
Definition: rawProcn.c:1860
char * rawGetPathName(char *)
Definition: rawProcn.c:1274
char cFile[MAX_FULL_FILE]
Definition: rawcommn.h:483
char cOS[MAX_OS]
Definition: rawcommn.h:642
char cNamefs[MAX_OBJ_FS]
Definition: rawcommn.h:633
char cNamehl[MAX_OBJ_HL]
Definition: rawcommn.h:634
int iFileSet
Definition: rawcommn.h:670
unsigned int iRestoHigh
Definition: rawcommn.h:647
char cDateCreate[MAX_DATE]
Definition: rawcommn.h:640
unsigned int iObjHigh
Definition: rawcommn.h:645
unsigned int iFileSize
Definition: rawcommn.h:638
unsigned int iRestoLowHigh
Definition: rawcommn.h:650
int iATLServer
Definition: rawcommn.h:652
unsigned int iFileSize2
Definition: rawcommn.h:639
int iVersion
Definition: rawcommn.h:631
unsigned int iRestoHighHigh
Definition: rawcommn.h:648
char cOwner[MAX_OWNER]
Definition: rawcommn.h:641
char cMgmtClass[MAX_MC+2]
Definition: rawcommn.h:643
unsigned int iRestoHighLow
Definition: rawcommn.h:649
int iMediaClass
Definition: rawcommn.h:644
int iFileType
Definition: rawcommn.h:636
unsigned int iRestoLow
Definition: rawcommn.h:651
int iPoolId
Definition: rawcommn.h:656
char cNode[MAX_NODE]
Definition: rawcommn.h:667
char cStageUser[MAX_OWNER]
Definition: rawcommn.h:674
char cNamell[MAX_OBJ_LL]
Definition: rawcommn.h:635
unsigned int iObjLow
Definition: rawcommn.h:646
char cPoolName[32]
Definition: rawcommn.h:701
unsigned int iRestoLowHigh
Definition: rawclin.h:140
char cNamell[MAX_OBJ_LL]
Definition: rawclin.h:134
int iStageFS
Definition: rawclin.h:149
unsigned int iRestoHighLow
Definition: rawclin.h:139
unsigned int iObjLow
Definition: rawclin.h:136
unsigned int iRestoHigh
Definition: rawclin.h:137
int iCacheFS
Definition: rawclin.h:152
unsigned int iObjHigh
Definition: rawclin.h:135
unsigned int iRestoLow
Definition: rawclin.h:141
unsigned int iRestoHighHigh
Definition: rawclin.h:138
char cNamehl[MAX_OBJ_HL]
Definition: rawclin.h:133
int iStatusLen
Definition: rawcommn.h:729
int iWorkSizeEst
Definition: rawcommn.h:736
int iWorkFilesEst
Definition: rawcommn.h:737
int iWorkFilesStaTemp
Definition: rawcommn.h:735
int iWorkFilesSta
Definition: rawcommn.h:733
int iWorkFilesAll
Definition: rawcommn.h:731
int iWorkSizeStaTemp
Definition: rawcommn.h:734
int iWorkSizeAll
Definition: rawcommn.h:730
int iWorkSizeSta
Definition: rawcommn.h:732