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