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