00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 #include <stdio.h>
00122 #include <string.h>
00123 #include <stdlib.h>
00124 #include <errno.h>
00125
00126 #ifdef Lynx
00127 #include <socket.h>
00128 #include <time.h>
00129 #else
00130 #include <sys/socket.h>
00131 #include <sys/time.h>
00132 #endif
00133
00134 #ifdef Linux
00135 #include <netinet/in.h>
00136 #endif
00137
00138 #include "rawapitd.h"
00139 #include "rawapitd-gsin.h"
00140 #include "rawcommn.h"
00141 #include "rawdefn.h"
00142 #include "rawclin.h"
00143 #include "rawentn.h"
00144 #include "rawapplcli.h"
00145
00146 extern FILE *fLogFile;
00147 extern int *piEntryList;
00148
00149 static unsigned int iint = sizeof(int);
00150 static unsigned int iRetrList = sizeof(srawRetrList);
00151 static unsigned int iFileList = sizeof(srawFileList);
00152
00153 static char cPath[MAX_FULL_FILE] = "";
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 int rawCheckFilelist(char **pcFileList, char **pcObjList,
00166 char *pcArchive, char *pcNodeMaster)
00167 {
00168 char cModule[32] = "rawCheckFilelist";
00169 int iDebug = 0;
00170
00171 char cDelimiter[1] = "";
00172 char *pcfl, *pcol;
00173 int *pifl, *piol;
00174 int ifile0, ifile;
00175 int iobj0, iobj;
00176
00177 srawFileList *psFile, *psFile0;
00178 srawRetrList *psObj, *psObj0;
00179
00180 char cFilell[MAX_OBJ_LL];
00181 char *pcFilell;
00182
00183 bool_t bLastBuf;
00184 int iobjBuf;
00185 int **piptr;
00186 int *pinext;
00187
00188 int ii, jj, iif;
00189 int iRC, idel;
00190
00191 pcfl = *pcFileList;
00192 pifl = (int *) pcfl;
00193 ifile0 = pifl[0];
00194 ifile = ifile0;
00195 psFile = (srawFileList *) ++pifl;
00196 psFile0 = psFile;
00197 pifl--;
00198
00199 pcol = *pcObjList;
00200 piol = (int *) pcol;
00201 iobj0 = piol[0];
00202 iobj = iobj0;
00203 psObj = (srawRetrList *) ++piol;
00204 psObj0 = psObj;
00205 piol--;
00206
00207 pcFilell = cFilell;
00208
00209 if (iDebug)
00210 {
00211 fprintf(fLogFile,
00212 "\n-D- begin %s: initial %d files, %d objects (1st buffer)\n",
00213 cModule, ifile0, iobj0);
00214 fprintf(fLogFile, " first file %s, first obj %s%s%s\n",
00215 psFile->cFile, pcArchive, psObj->cNamehl, psObj->cNamell);
00216 }
00217
00218 iRC = strncmp(psObj->cNamell, pcObjDelim, 1);
00219 if (iRC)
00220 {
00221 iRC = strncmp(psObj->cNamell, pcObjDelimAlt, 1);
00222 if (iRC)
00223 {
00224 fprintf(fLogFile,
00225 "-E- %s: invalid object delimiter %1s found\n",
00226 cModule, psObj->cNamell);
00227 return -1;
00228 }
00229 else
00230 strcpy(cDelimiter, pcObjDelimAlt);
00231 }
00232 else
00233 strcpy(cDelimiter, pcObjDelim);
00234
00235 for (ii = 1; ii <= ifile0; ii++)
00236 {
00237 psObj = psObj0;
00238 iobj = iobj0;
00239 strcpy(cFilell, "");
00240 iRC = rawGetLLName(psFile->cFile, cDelimiter, cFilell);
00241
00242 if (iDebug)
00243 fprintf(fLogFile, " %d: '%s'\n", ii, cFilell);
00244
00245 bLastBuf = bFalse;
00246 iobjBuf = 1;
00247 if (iDebug > 1)
00248 fprintf(fLogFile, "\n*** buffer %d: %d objs\n", iobjBuf, iobj);
00249
00250 while (!bLastBuf)
00251 {
00252
00253 for (jj = 1; jj <= iobj; jj++)
00254 {
00255
00256 iRC = strcmp(cFilell, psObj->cNamell);
00257 if (iRC == 0)
00258 {
00259 if (iDebug) fprintf(fLogFile,
00260 " %s%s%s already archived in gStore\n",
00261 pcArchive, psObj->cNamehl, pcFilell);
00262 else fprintf(fLogFile,
00263 "-W- %s%s%s already archived in gStore\n",
00264 pcArchive, psObj->cNamehl, pcFilell);
00265
00266 strncpy(psFile->cFile, "\n", 1);
00267 ifile--;
00268 if (ifile == 0)
00269 {
00270 if (iDebug) fprintf(fLogFile,
00271 " last file, comparison finished\n");
00272 goto gEndCompare;
00273 }
00274 goto gNextFile;
00275
00276 }
00277
00278 psObj++;
00279 }
00280
00281 piptr = (int **) psObj;
00282 if (*piptr == NULL)
00283 {
00284 bLastBuf = bTrue;
00285 if (iDebug > 1)
00286 fprintf(fLogFile, " %d: last obj buffer\n", iobjBuf);
00287 if (iDebug)
00288 fprintf(fLogFile, "*** %d: %s (%s) to be archived\n",
00289 ii, psFile->cFile, cFilell);
00290 }
00291 else
00292 {
00293 iobjBuf++;
00294 pinext = *piptr;
00295 iobj = *pinext++;
00296 psObj = (srawRetrList *) pinext;
00297 if (iDebug > 1) fprintf(fLogFile,
00298 "\n*** new buffer %d: %d objs, first obj '%s'\n",
00299 iobjBuf, iobj, psObj->cNamell);
00300 }
00301
00302 }
00303
00304 gNextFile:
00305 psFile++;
00306 }
00307
00308 gEndCompare:
00309 idel = ifile0-ifile;
00310 if (iDebug) fprintf(fLogFile,
00311 " %d of %d files removed: %d files remaining\n",
00312 idel, ifile0, ifile);
00313
00314 pifl[0] = ifile;
00315 *pcFileList = (char *) pifl;
00316
00317 if ( (ifile > 0) && (idel > 0) )
00318 {
00319 iif = 1;
00320 psFile = psFile0;
00321 for (ii = 1; ii <= ifile0; ii++)
00322 {
00323
00324 iRC = strncmp(psFile->cFile, "\n", 1);
00325 if (iRC != 0)
00326 {
00327 if (iif >= ifile0)
00328 break;
00329
00330 psFile0++;
00331 psFile++;
00332 iif++;
00333 }
00334 else
00335 {
00336 for (jj = ii+1; jj <= ifile0; jj++)
00337 {
00338 psFile++;
00339 iif++;
00340 iRC = strncmp(psFile->cFile, "\n", 1);
00341 if (iRC == 0)
00342 {
00343 if (iif >= ifile0)
00344 break;
00345 }
00346 else
00347 {
00348 strcpy(psFile0->cFile, psFile->cFile);
00349 if (iDebug > 1) fprintf(fLogFile,
00350 "*** %d: %s\n", iif, psFile0->cFile);
00351 if (iif >= ifile0)
00352 break;
00353
00354 psFile0++;
00355 }
00356 }
00357
00358 }
00359 }
00360
00361 if (iDebug)
00362 fprintf(fLogFile, " file list compressed\n");
00363
00364 }
00365
00366
00367 if (iDebug)
00368 {
00369 fprintf(fLogFile, "-D- end %s\n\n", cModule);
00370 fflush(fLogFile);
00371 }
00372
00373 return idel ;
00374
00375 }
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410 int rawCheckObjlist(
00411 int iFileComp,
00412 int iSort,
00413 char **pcObjList,
00414 char **pcFileList,
00415 char **pcObjComp)
00416 {
00417 char cModule[32]="rawCheckObjlist";
00418 int iDebug = 0;
00419
00420 int iRC;
00421 int iObjComp;
00422 int iDiff = 0;
00423 char cMsg[STATUS_LEN] = "";
00424
00425
00426
00427
00428 int iaValue[MAX_FILE_NO][6];
00429
00430
00431
00432
00433
00434
00435
00436
00437 int iaCompValue[MAX_FILE_NO][6];
00438
00439 int iaIndex[MAX_FILE_NO];
00440
00441
00442 int iaIndNew[MAX_FILE_NO];
00443 int iaValTop[MAX_FILE_NO];
00444 int iaValHiHi[MAX_FILE_NO];
00445 int iaValHiLo[MAX_FILE_NO];
00446 int iaValLoHi[MAX_FILE_NO];
00447 int iaValLoLo[MAX_FILE_NO];
00448
00449 int iif = 0, ii1 = 0, ii2 = 0;
00450 int iisort1 = 0,
00451 iisort2 = 0;
00452 int iitop1 = 0,
00453 iitop2 = 0,
00454 iTopValcur = 0,
00455 iObjTopValcur = 0;
00456 int iihihi1 = 0, iihihi2 = 0, iHiHiValcur = 0, iihihicur = 0;
00457 int iihilo1 = 0, iihilo2 = 0, iHiLoValcur = 0, iihilocur = 0;
00458 int iilohi1 = 0, iilohi2 = 0, iLoHiValcur = 0, iilohicur = 0;
00459
00460 int iFileSort = 0,
00461 iReadCache = 0,
00462 iWriteCache = 0;
00463
00464
00465 int iRestoTop = 0,
00466 iRestoHiHi = 0,
00467 iRestoHiLo = 0,
00468 iRestoLoHi = 0,
00469 iRestoLoLo = 0;
00470
00471
00472 unsigned int iRestoTopValues = 0,
00473 iRestoHiHiValues = 0,
00474 iRestoHiLoValues = 0,
00475 iRestoLoHiValues = 0,
00476 iRestoLoLoValues = 0;
00477
00478 unsigned int iRestoTopMin = 0,
00479 iRestoHiHiMin = 0,
00480 iRestoHiLoMin = 0,
00481 iRestoLoHiMin = 0,
00482 iRestoLoLoMin = 0;
00483
00484 bool_t bRestoSort = bFalse;
00485
00486 bool_t bRestoTop = bFalse,
00487 bRestoHiHi = bFalse,
00488 bRestoHiLo = bFalse,
00489 bRestoLoHi = bFalse,
00490 bRestoLoLo = bFalse;
00491
00492 char *pcfl, *pcol;
00493 int *pifl, *piol;
00494 int iFileAll = 0;
00495 int iobj0 = 0,
00496 iobj = 0;
00497
00498 int iFileBufComp,
00499 iObjBufComp;
00500
00501 char *pcFileComp;
00502 char *pcflcomp, *pcolcomp;
00503 int *piflcomp, *piolcomp;
00504
00505 char *pcFileSort,
00506 *pcObjSort;
00507 char *pcflsort, *pcolsort;
00508 int *piflsort, *piolsort;
00509
00510 int iiObj = 0;
00511 int iiBuf = 0;
00512 int iiFile = 0;
00513
00514 int **piptr;
00515 int *pinext;
00516
00517 srawFileList *psFile, *psFile0;
00518 srawFileList *psFileSort,
00519 *psFileSort0,
00520 *psFileComp,
00521 *psFileComp0;
00522
00523 srawRetrList *psObj;
00524 srawRetrList *psObj0;
00525 srawRetrList *psObjSort,
00526 *psObjSort0,
00527 *psObjComp,
00528 *psObjComp0;
00529
00530 int ii, jj, jjMin = 0;
00531 int icount = 0;
00532
00533 bool_t bInit;
00534
00535
00536 pcfl = *pcFileList;
00537 pifl = (int *) pcfl;
00538 iFileAll = pifl[0];
00539 psFile = (srawFileList *) ++pifl;
00540 psFile0 = psFile;
00541 pifl--;
00542
00543
00544 pcol = *pcObjList;
00545 piol = (int *) pcol;
00546 iobj0 = piol[0];
00547 iobj = iobj0;
00548 psObj = (srawRetrList *) ++piol;
00549 psObj0 = psObj;
00550 piol--;
00551
00552
00553 pcolcomp = *pcObjComp;
00554 piolcomp = (int *) pcolcomp;
00555 psObjComp = (srawRetrList *) ++piolcomp;
00556 psObjComp0 = psObjComp;
00557 piolcomp--;
00558
00559 if (iFileComp >= MAX_FILE_NO)
00560 {
00561 ii = MAX_FILE_NO-1;
00562 fprintf(fLogFile,
00563 "-E- %s: file list too long: %d entries, only %d allowed\n",
00564 cModule, iFileComp, ii);
00565 return -2;
00566 }
00567
00568 if (iDebug)
00569 {
00570 fprintf(fLogFile,
00571 "\n-D- begin %s: overall %d objects, in 1st buffer %d objects\n",
00572 cModule, iFileAll, iobj0);
00573 fprintf(fLogFile, " compressed: %d objects\n", iFileComp);
00574 if (iDebug > 1)
00575 {
00576 if (iSort == 1) fprintf(fLogFile,
00577 " first file %s, first obj %s%s\n",
00578 psFile->cFile, psObj->cNamehl, psObj->cNamell);
00579 else fprintf(fLogFile,
00580 " first obj %s%s\n", psObj->cNamehl, psObj->cNamell);
00581 }
00582 }
00583
00584 if (iDebug == 2)
00585 {
00586 for (jj=1; jj<=iFileAll; jj++)
00587 {
00588 fprintf(fLogFile,
00589 "DDDD %d: file %s (%d)\n", jj, psFile->cFile, psFile);
00590 psFile++;
00591 }
00592 psFile = psFile0;
00593 }
00594
00595
00596
00597 if (iSort == 0)
00598 {
00599 iiBuf = 1;
00600 ii = 0;
00601
00602
00603 for (jj=1; jj<=iFileAll; jj++)
00604 {
00605 iiObj++;
00606 if (strlen(psObj->cNamell) < 2)
00607 {
00608 if (iDebug == 2) fprintf(fLogFile,
00609 " object %d(%d): ignored\n", iiObj, jj);
00610
00611 goto gNextObjUnstage;
00612 }
00613
00614 ii++;
00615 memcpy((char *) psObjComp, (char *) psObj, iRetrList);
00616 if (iDebug) fprintf(fLogFile,
00617 "%d(%d): obj %s%s copied (Comp)\n", iiObj, jj,
00618 psObjComp->cNamehl, psObjComp->cNamell);
00619
00620 psObjComp++;
00621
00622 gNextObjUnstage:
00623 psObj++;
00624 if (iiObj == iobj)
00625 {
00626 if (iDebug) fprintf(fLogFile,
00627 " buffer %d: last obj (no. %d) handled\n",
00628 iiBuf, iiObj);
00629
00630 piptr = (int **) psObj;
00631 if (*piptr == NULL)
00632 {
00633 if (iDebug) fprintf(fLogFile,
00634 " buffer %d: last obj buffer\n", iiBuf);
00635 }
00636 else
00637 {
00638 iiObj = 0;
00639 iiBuf++;
00640 pinext = *piptr;
00641 iobj = *pinext++;
00642 psObj = (srawRetrList *) pinext;
00643 if (iDebug) fprintf(fLogFile,
00644 " new buffer %d, %d objs, first: %s%s|\n",
00645 iiBuf, iobj, psObj->cNamehl, psObj->cNamell);
00646 }
00647 }
00648 }
00649
00650 *piolcomp = ii;
00651 goto gEndCheckObjlist;
00652
00653 }
00654
00655
00656
00657 iFileBufComp = sizeof(int) + iFileComp*sizeof(srawFileList);
00658 if ((pcFileComp = (char *) calloc(
00659 (unsigned) iFileBufComp, sizeof(char) ) ) == NULL)
00660 {
00661 fprintf(fLogFile,
00662 "-E- %s: allocating filelist buffer (Comp, %d byte)\n",
00663 cModule, iFileBufComp);
00664 if (errno)
00665 fprintf(fLogFile, " %s\n", strerror(errno));
00666 perror("-E- allocating filelist buffer (Comp)");
00667
00668 return -2;
00669 }
00670 if (iDebug) fprintf(fLogFile,
00671 " filelist buffer (Comp) allocated (size %d)\n", iFileBufComp);
00672
00673 piflcomp = (int *) pcFileComp;
00674 piflcomp[0] = iFileComp;
00675 psFileComp = (srawFileList *) ++piflcomp;
00676 psFileComp0 = psFileComp;
00677
00678 if ( (pcFileSort = (char *) calloc(
00679 (unsigned) iFileBufComp, sizeof(char)) ) == NULL)
00680 {
00681 fprintf(fLogFile,
00682 "-E- %s: allocating filelist buffer (Sort, %d byte)\n",
00683 cModule, iFileBufComp);
00684 if (errno)
00685 fprintf(fLogFile, " %s\n", strerror(errno));
00686 perror("-E- allocating filelist buffer (Sort)");
00687
00688 return(-2);
00689 }
00690 if (iDebug) fprintf(fLogFile,
00691 " filelist buffer (Sort) allocated (size %d)\n", iFileBufComp);
00692
00693 piflsort = (int *) pcFileSort;
00694 piflsort[0] = iFileComp;
00695 psFileSort = (srawFileList *) ++piflsort;
00696 psFileSort0 = psFileSort;
00697
00698 iObjBufComp = sizeof(int) + iFileComp*sizeof(srawRetrList);
00699 if ( (pcObjSort = (char *) calloc(
00700 (unsigned) iObjBufComp, sizeof(char)) ) == NULL )
00701 {
00702 fprintf(fLogFile,
00703 "-E- %s: allocating objectlist buffer (%d byte)\n",
00704 cModule, iObjBufComp);
00705 if (errno)
00706 fprintf(fLogFile, " %s\n", strerror(errno));
00707 perror("-E- allocating objlist buffer");
00708
00709 return(-3);
00710 }
00711 if (iDebug) fprintf(fLogFile,
00712 " objlist buffer (Sort) allocated (size %d)\n", iObjBufComp);
00713
00714 pcolsort = pcObjSort;
00715 piolsort = (int *) pcolsort;
00716 piolsort[0] = iFileComp;
00717 psObjSort = (srawRetrList *) ++piolsort;
00718 psObjSort0 = psObjSort;
00719
00720
00721
00722 for (jj=1; jj<=iFileAll; jj++)
00723 {
00724 iaIndex[jj] = -1;
00725 for (ii=0; ii<=5; ii++)
00726 {
00727 if (ii == 0)
00728 iaValue[jj][ii] = -1;
00729 else
00730 iaValue[jj][ii] = 0;
00731 }
00732 }
00733
00734 psObj = psObj0;
00735 iobj = iobj0;
00736 iiObj = 0;
00737 iiBuf = 1;
00738
00739 if (iDebug)
00740 fprintf(fLogFile, "scan objects for sort criteria:\n");
00741
00742
00743 for (jj=1; jj<=iFileAll; jj++)
00744 {
00745 iiObj++;
00746
00747 if (iDebug == 2) fprintf(fLogFile,
00748 "DDD %d (comp %d): obj %s (%d), file %s (%d)\n",
00749 iiObj, jj, psObj->cNamell, psObj, psFile->cFile, psFile);
00750
00751 if (strlen(psObj->cNamell) < 2)
00752 {
00753 iaValue[jj][0] = 0;
00754 if (iDebug == 2) fprintf(fLogFile,
00755 " object %d(%d): ignored\n", iiObj, jj);
00756
00757 goto gNextValue;
00758 }
00759
00760 if (psObj->iStageFS)
00761 {
00762 if (iDebug == 2) fprintf(fLogFile,
00763 " object %d(%d) %s%s: in read cache\n",
00764 iiObj, jj, psObj->cNamehl, psObj->cNamell);
00765
00766 iReadCache++;
00767 iaValue[jj][0] = 1;
00768
00769
00770 memcpy((char *) psObjComp, (char *) psObj, iRetrList);
00771 memcpy(psFileComp->cFile, psFile->cFile, iFileList);
00772
00773 if (iDebug)
00774 {
00775 fprintf(fLogFile,
00776 "%d: read cache obj %s%s (objId %u-%u) copied (Comp)\n",
00777 iReadCache, psObjComp->cNamehl, psObjComp->cNamell,
00778 psObjComp->iObjHigh, psObjComp->iObjLow);
00779 fprintf(fLogFile,
00780 " orig file name %s (%d)\n",
00781 psFile->cFile, psFile);
00782 fprintf(fLogFile,
00783 " file name %s copied (Comp: %d)\n",
00784 psFileComp->cFile, psFileComp);
00785 if (jj == iFileAll) fprintf(fLogFile,
00786 " in last buffer %d: last obj (no. %d) handled\n",
00787 iiBuf, iiObj);
00788 }
00789
00790
00791
00792
00793 psObjComp++;
00794 psFileComp++;
00795 goto gNextValue;
00796 }
00797
00798 if (psObj->iCacheFS)
00799 {
00800 if (iDebug == 2) fprintf(fLogFile,
00801 " object %d(%d) %s%s: in write cache\n",
00802 iiObj, jj, psObj->cNamehl, psObj->cNamell);
00803
00804 iWriteCache++;
00805 iaValue[jj][0] = 2;
00806
00807
00808 memcpy((char *) psObjSort, (char *) psObj, iRetrList);
00809 memcpy(psFileSort->cFile, psFile->cFile, iFileList);
00810 if (iDebug)
00811 {
00812 fprintf(fLogFile,
00813 "%d: write cache obj %s%s (%u-%u) copied (Sort)\n",
00814 iWriteCache, psObjSort->cNamehl, psObjSort->cNamell,
00815 psObjSort->iObjHigh, psObjSort->iObjLow);
00816
00817 if (jj == iFileAll) fprintf(fLogFile,
00818 " in last buffer %d: last obj (no. %d) handled\n",
00819 iiBuf, iiObj);
00820 }
00821
00822 psObjSort++;
00823 psFileSort++;
00824 goto gNextValue;
00825 }
00826
00827 iaValue[jj][0] = 3;
00828 if (psObj->iRestoHigh)
00829 {
00830 iaValue[jj][1] = psObj->iRestoHigh;
00831 iRestoTop++;
00832 if (iDebug == 2) fprintf(fLogFile,
00833 " object %d(%d) %s%s: top restore field %d\n",
00834 iiObj, jj, psObj->cNamehl, psObj->cNamell, iaValue[jj][1]);
00835 }
00836 if (psObj->iRestoHighHigh)
00837 {
00838 iaValue[jj][2] = psObj->iRestoHighHigh;
00839 iRestoHiHi++;
00840 fprintf(fLogFile,
00841 "-W- object %d(%d) %s%s: hihi restore field %d\n",
00842 iiObj, jj, psObj->cNamehl, psObj->cNamell, iaValue[jj][2]);
00843 }
00844 if (psObj->iRestoHighLow)
00845 {
00846 iaValue[jj][3] = psObj->iRestoHighLow;
00847 iRestoHiLo++;
00848 if (iDebug == 2) fprintf(fLogFile,
00849 " object %d(%d) %s%s: hilo restore field %d\n",
00850 iiObj, jj, psObj->cNamehl, psObj->cNamell, iaValue[jj][3]);
00851 }
00852 if (psObj->iRestoLowHigh)
00853 {
00854 iaValue[jj][4] = psObj->iRestoLowHigh;
00855 iRestoLoHi++;
00856 fprintf(fLogFile,
00857 "-W- object %d(%d) %s%s: lohi restore field %d\n",
00858 iiObj, jj, psObj->cNamehl, psObj->cNamell, iaValue[jj][4]);
00859 }
00860 if (psObj->iRestoLow)
00861 {
00862 iaValue[jj][5] = psObj->iRestoLow;
00863 iRestoLoLo++;
00864 if (iDebug == 2) fprintf(fLogFile,
00865 " object %d(%d) %s%s: lolo restore field %d\n",
00866 iiObj, jj, psObj->cNamehl, psObj->cNamell, iaValue[jj][5]);
00867 }
00868
00869 gNextValue:
00870 psObj++;
00871 psFile++;
00872 if (iiObj == iobj)
00873 {
00874 if (iDebug) fprintf(fLogFile,
00875 " buffer %d: last obj (no. %d) handled\n",
00876 iiBuf, iiObj);
00877
00878 piptr = (int **) psObj;
00879 if (*piptr == NULL)
00880 {
00881 if (iDebug) fprintf(fLogFile,
00882 " buffer %d: last obj buffer\n", iiBuf);
00883 }
00884 else
00885 {
00886 iiObj = 0;
00887 iiBuf++;
00888 pinext = *piptr;
00889 iobj = *pinext++;
00890 psObj = (srawRetrList *) pinext;
00891 if (iDebug) fprintf(fLogFile,
00892 " new buffer %d, %d objs, first: %s%s|\n",
00893 iiBuf, iobj, psObj->cNamehl, psObj->cNamell);
00894 }
00895 }
00896 }
00897
00898 if (iDebug) fprintf(fLogFile,
00899 " usage of restore fields: %u-%u-%u-%u-%u\n",
00900 iRestoTop, iRestoHiHi, iRestoHiLo, iRestoLoHi, iRestoLoLo);
00901
00902
00903
00904 if (iWriteCache)
00905 {
00906 psObjSort = psObjSort0;
00907 psFileSort = psFileSort0;
00908
00909 for (ii=1; ii<=iWriteCache; ii++)
00910 {
00911 memcpy((char *) psObjComp, (char *) psObjSort, iRetrList);
00912 memcpy(psFileComp->cFile, psFileSort->cFile, iFileList);
00913
00914 psObjSort++;
00915 psFileSort++;
00916 psObjComp++;
00917 psFileComp++;
00918
00919 }
00920 }
00921
00922 if ( ((iReadCache) || (iWriteCache)) && (iDebug == 2) )
00923 {
00924 psObjComp = psObjComp0;
00925 psFileComp = psFileComp0;
00926
00927 if (iReadCache)
00928 {
00929 fprintf(fLogFile,
00930 "%d read cache entries (Comp)\n", iReadCache);
00931 for (ii=1; ii<=iReadCache; ii++)
00932 {
00933 fprintf(fLogFile, " %d: obj %s%s, file %s\n",
00934 ii, psObjComp->cNamehl, psObjComp->cNamell,
00935 psFileComp->cFile);
00936 psObjComp++;
00937 psFileComp++;
00938 }
00939 }
00940
00941 if (iWriteCache)
00942 {
00943 fprintf(fLogFile,
00944 "%d write cache entries (Comp)\n", iWriteCache);
00945 for (ii=1; ii<=iWriteCache; ii++)
00946 {
00947 jj = iReadCache + ii;
00948 fprintf(fLogFile, " %d: obj %s%s, file %s\n",
00949 jj, psObjComp->cNamehl, psObjComp->cNamell,
00950 psFileComp->cFile);
00951 psObjComp++;
00952 psFileComp++;
00953 }
00954 }
00955 }
00956
00957
00958 if (iReadCache + iWriteCache == iFileComp)
00959 goto gEndCheckObjlist;
00960
00961
00962
00963 iFileSort = iFileComp - iReadCache - iWriteCache;
00964 psObjSort = (srawRetrList *) piolsort;
00965 psFileSort = (srawFileList *) piflsort;
00966
00967 psObj = psObj0;
00968 psFile = psFile0;
00969 iobj = iobj0;
00970 iiObj = 0;
00971 iiBuf = 1;
00972 ii = 0;
00973 if (iDebug) fprintf(fLogFile,
00974 "DDD TSM restore values before sorting:\n");
00975
00976
00977 for (jj=1; jj<=iFileAll; jj++)
00978 {
00979 iiObj++;
00980 if (iaValue[jj][0] < 3)
00981 {
00982 if (iDebug)
00983 {
00984 fprintf(fLogFile,
00985 " %d: (%d) ignored", jj, iaValue[jj][0]);
00986 if (psObj->iStageFS)
00987 fprintf(fLogFile, " (RC)\n");
00988 else if (psObj->iCacheFS)
00989 fprintf(fLogFile, " (WC)\n");
00990 else
00991 fprintf(fLogFile, "\n");
00992 }
00993
00994 goto gNextObjCompress;
00995 }
00996
00997 ii++;
00998 iaCompValue[ii][0] = iaValue[jj][0];
00999 iaCompValue[ii][1] = iaValue[jj][1];
01000 iaCompValue[ii][2] = iaValue[jj][2];
01001 iaCompValue[ii][3] = iaValue[jj][3];
01002 iaCompValue[ii][4] = iaValue[jj][4];
01003 iaCompValue[ii][5] = iaValue[jj][5];
01004
01005 if (iDebug) fprintf(fLogFile,
01006 " %d(%d): %d %d-%d-%d-%d-%d\n", jj, ii,
01007 iaValue[jj][0], iaValue[jj][1], iaValue[jj][2],
01008 iaValue[jj][3], iaValue[jj][4], iaValue[jj][5]);
01009
01010 memcpy((char *) psObjSort, (char *) psObj, iRetrList);
01011 memcpy(psFileSort->cFile, psFile->cFile, iFileList);
01012 psObjSort++;
01013 psFileSort++;
01014
01015 gNextObjCompress:
01016 psObj++;
01017 psFile++;
01018 if (iiObj == iobj)
01019 {
01020 if (iDebug == 2) fprintf(fLogFile,
01021 " buffer %d: last obj (no. %d) handled\n",
01022 iiBuf, iiObj);
01023
01024 piptr = (int **) psObj;
01025 if (*piptr == NULL)
01026 {
01027 if (iDebug == 2) fprintf(fLogFile,
01028 " buffer %d: last obj buffer\n", iiBuf);
01029 }
01030 else
01031 {
01032 iiObj = 0;
01033 iiBuf++;
01034 pinext = *piptr;
01035 iobj = *pinext++;
01036 psObj = (srawRetrList *) pinext;
01037 if (iDebug == 2) fprintf(fLogFile,
01038 " new buffer %d, %d objs, first: %s%s\n",
01039 iiBuf, iobj, psObj->cNamehl, psObj->cNamell);
01040 }
01041 }
01042 }
01043
01044 if (ii != iFileSort)
01045 {
01046 fprintf(fLogFile,
01047 "-E- %s: inconsistent no. of TSM files: %d - %d\n",
01048 cModule, iFileSort, ii);
01049 return -2;
01050 }
01051
01052 psObjSort = (srawRetrList *) piolsort;
01053 psFileSort = (srawFileList *) piflsort;
01054
01055
01056
01057 if (iDebug == 2) fprintf(fLogFile,
01058 "DDD list of compressed TSM objs/files (ps...Sort):\n");
01059
01060 for (jj=1; jj<=iFileSort; jj++)
01061 {
01062 if (iRestoTop)
01063 iaValTop[jj] = iaCompValue[jj][1];
01064 else
01065 iaValTop[jj] = 0;
01066
01067 if (iRestoHiHi)
01068 iaValHiHi[jj] = iaCompValue[jj][2];
01069 else
01070 iaValHiHi[jj] = 0;
01071
01072 if (iRestoHiLo)
01073 iaValHiLo[jj] = iaCompValue[jj][3];
01074 else
01075 iaValHiLo[jj] = 0;
01076
01077 if (iRestoLoHi)
01078 iaValLoHi[jj] = iaCompValue[jj][4];
01079 else
01080 iaValLoHi[jj] = 0;
01081
01082 if (iRestoLoLo)
01083 iaValLoLo[jj] = iaCompValue[jj][5];
01084 else
01085 iaValLoLo[jj] = 0;
01086
01087 iaIndex[jj] = jj;
01088
01089 if (iDebug == 2)
01090 {
01091 fprintf(fLogFile, " %d: obj %s%s, file %s\n",
01092 jj, psObjSort->cNamehl, psObjSort->cNamell,
01093 psFileSort->cFile);
01094
01095 psObjSort++;
01096 psFileSort++;
01097 }
01098 }
01099
01100 iisort1 = 1;
01101 iisort2 = iFileSort;
01102
01103 if (iRestoTop)
01104 {
01105 iRC = rawSortValues(iaValTop, iFileSort, iisort1, iisort2,
01106 iaIndex, iaIndNew);
01107
01108
01109 iDiff = 0;
01110 for (jj=iisort1; jj<=iisort2; jj++)
01111 {
01112 if (iaIndNew[jj] != iaIndex[jj])
01113 {
01114 ii1 = iaIndNew[jj];
01115 if (iRestoHiHi)
01116 iaValHiHi[jj] = iaCompValue[ii1][2];
01117 if (iRestoHiLo)
01118 iaValHiLo[jj] = iaCompValue[ii1][3];
01119 if (iRestoLoHi)
01120 iaValLoHi[jj] = iaCompValue[ii1][4];
01121 if (iRestoLoLo)
01122 iaValLoLo[jj] = iaCompValue[ii1][5];
01123 iDiff++;
01124 }
01125 }
01126
01127
01128 memcpy(&iaIndex[iisort1], &iaIndNew[iisort1],
01129 (unsigned) iFileSort*iint);
01130
01131 if (iDebug == 2)
01132 {
01133 fprintf(fLogFile,
01134 "DDD restore order after top sorting (%d changes):\n",
01135 iDiff);
01136 for (jj=iisort1; jj<=iisort2; jj++)
01137 {
01138 fprintf(fLogFile,
01139 " %d: index %d, values: %u-%u-%u-%u-%u\n",
01140 jj, iaIndNew[jj], iaValTop[jj],
01141 iaValHiHi[jj], iaValHiLo[jj],
01142 iaValLoHi[jj], iaValLoLo[jj]);
01143 }
01144 }
01145
01146 iRestoTopValues = 1;
01147 iRestoTopMin = iaValTop[iisort1];
01148 for (jj=iisort1+1; jj<=iisort2; jj++)
01149 {
01150 if (iaValTop[jj] > iRestoTopMin)
01151 {
01152 iRestoTopMin = iaValTop[jj];
01153 iRestoTopValues++;
01154 }
01155 }
01156
01157 if (iDebug) fprintf(fLogFile,
01158 "%d different top restore values\n", iRestoTopValues);
01159
01160 iitop1 = iisort1;
01161
01162
01163
01164 for (iTopValcur=1; iTopValcur<=iRestoTopValues; iTopValcur++)
01165 {
01166 if (iTopValcur == iRestoTopValues)
01167 iitop2 = iFileSort;
01168 else
01169 {
01170 iRestoTopMin = iaValTop[iitop1];
01171 for (jj=iitop1+1; jj<=iFileSort; jj++)
01172 {
01173 if (iaValTop[jj] > iRestoTopMin)
01174 {
01175 iitop2 = jj-1;
01176 break;
01177 }
01178
01179 if (jj == iFileSort)
01180 iitop2 = jj;
01181 }
01182 }
01183
01184 if (iitop1 == iitop2)
01185 {
01186 if (iDebug) fprintf(fLogFile,
01187 " %d. top restore value %d: only one object (%d)\n",
01188 iTopValcur, iaValTop[iitop1], iitop1);
01189
01190 if (iTopValcur == iRestoTopValues)
01191 break;
01192 else
01193 {
01194 iitop1 = iitop2 + 1;
01195 continue;
01196 }
01197 }
01198 else if (iDebug) fprintf(fLogFile,
01199 " %d. top restore value %d: objs %d - %d\n",
01200 iTopValcur, iaValTop[iitop1], iitop1, iitop2);
01201
01202
01203 if (iRestoHiHi)
01204 {
01205 ;
01206 }
01207
01208
01209 if (iRestoHiLo)
01210 {
01211 if (iitop2 - iitop1)
01212 {
01213 iRC = rawSortValues(iaValHiLo, iFileSort, iitop1, iitop2,
01214 iaIndex, iaIndNew);
01215
01216
01217 iDiff = 0;
01218 for (jj=iitop1; jj<=iitop2; jj++)
01219 {
01220 if (iaIndNew[jj] != iaIndex[jj])
01221 {
01222 ii1 = iaIndNew[jj];
01223 if (iRestoTop)
01224 iaValTop[jj] = iaCompValue[ii1][1];
01225 if (iRestoHiHi)
01226 iaValHiHi[jj] = iaCompValue[ii1][2];
01227 if (iRestoLoHi)
01228 iaValLoHi[jj] = iaCompValue[ii1][4];
01229 if (iRestoLoLo)
01230 iaValLoLo[jj] = iaCompValue[ii1][5];
01231 iDiff++;
01232 }
01233 }
01234
01235
01236 ii1 = iitop2 - iitop1 + 1;
01237 memcpy(&iaIndex[iitop1], &iaIndNew[iitop1],
01238 (unsigned) ii1*iint);
01239
01240 if (iDebug == 2)
01241 {
01242 fprintf(fLogFile,
01243 " restore order after hilo sorting (%d - %d: %d changes):\n",
01244 iitop1, iitop2, iDiff);
01245 for (jj=iitop1; jj<=iitop2; jj++)
01246 {
01247 fprintf(fLogFile,
01248 " %d: index %d, values: %u-%u-%u-%u-%u\n",
01249 jj, iaIndNew[jj], iaValTop[jj],
01250 iaValHiHi[jj], iaValHiLo[jj],
01251 iaValLoHi[jj], iaValLoLo[jj]);
01252 }
01253 }
01254
01255 iRestoHiLoValues = 1;
01256 iRestoHiLoMin = iaValHiLo[iitop1];
01257
01258 for (jj=iitop1+1; jj<=iitop2; jj++)
01259 {
01260 if (iaValHiLo[jj] > iRestoHiLoMin)
01261 {
01262 iRestoHiLoMin = iaValHiLo[jj];
01263 iRestoHiLoValues++;
01264 }
01265 }
01266
01267 if (iDebug) fprintf(fLogFile,
01268 " %d different hilo restore values\n", iRestoHiLoValues);
01269
01270 }
01271 else
01272 iRestoHiLoValues = 1;
01273
01274 iihilo1 = iitop1;
01275
01276
01277
01278 for (iHiLoValcur=1; iHiLoValcur<=iRestoHiLoValues; iHiLoValcur++)
01279 {
01280 if (iHiLoValcur == iRestoHiLoValues)
01281 iihilo2 = iitop2;
01282 else
01283 {
01284 iRestoHiLoMin = iaValHiLo[iihilo1];
01285 for (jj=iitop1+1; jj<=iitop2; jj++)
01286 {
01287 if (iaValHiLo[jj] > iRestoHiLoMin)
01288 {
01289 iihilo2 = jj-1;
01290 break;
01291 }
01292
01293 if (jj == iitop2)
01294 iihilo2 = jj;
01295 }
01296 }
01297
01298 if (iihilo1 == iihilo2)
01299 {
01300 if (iDebug) fprintf(fLogFile,
01301 " %d. hilo restore value %d: only one object (%d)\n",
01302 iHiLoValcur, iaValHiLo[iihilo1], iihilo1);
01303
01304 if (iHiLoValcur == iRestoHiLoValues)
01305 break;
01306 else
01307 {
01308 iihilo1 = iihilo2 + 1;
01309 continue;
01310 }
01311 }
01312 else if (iDebug) fprintf(fLogFile,
01313 " %d. hilo restore value %d: objs %d - %d\n",
01314 iHiLoValcur, iaValHiLo[iihilo1], iihilo1, iihilo2);
01315
01316
01317 if (iRestoLoHi)
01318 {
01319 ;
01320 }
01321
01322 if (iRestoLoLo)
01323 {
01324 if (iihilo2 - iihilo1)
01325 {
01326 iRC = rawSortValues(iaValLoLo, iFileSort,
01327 iihilo1, iihilo2, iaIndex, iaIndNew);
01328
01329
01330 iDiff = 0;
01331 for (jj=iihilo1; jj<=iihilo2; jj++)
01332 {
01333 if (iaIndNew[jj] != iaIndex[jj])
01334 {
01335 ii1 = iaIndNew[jj];
01336 if (iRestoTop)
01337 iaValTop[jj] = iaCompValue[ii1][1];
01338 if (iRestoHiHi)
01339 iaValHiHi[jj] = iaCompValue[ii1][2];
01340 if (iRestoHiLo)
01341 iaValHiLo[jj] = iaCompValue[ii1][3];
01342 if (iRestoLoHi)
01343 iaValLoHi[jj] = iaCompValue[ii1][4];
01344 iDiff++;
01345 }
01346 }
01347
01348
01349 ii1 = iihilo2 - iihilo1 + 1;
01350 memcpy(&iaIndex[iihilo1], &iaIndNew[iihilo1],
01351 (unsigned) ii1*iint);
01352
01353 if (iDebug == 2)
01354 {
01355 fprintf(fLogFile,
01356 " restore order after lolo sorting (%d - %d: %d changes):\n",
01357 iihilo1, iihilo2, iDiff);
01358 for (jj=iihilo1; jj<=iihilo2; jj++)
01359 {
01360 fprintf(fLogFile,
01361 " %d: index %d, values: %u-%u-%u-%u-%u\n",
01362 jj, iaIndNew[jj], iaValTop[jj],
01363 iaValHiHi[jj], iaValHiLo[jj],
01364 iaValLoHi[jj], iaValLoLo[jj]);
01365 }
01366 }
01367 }
01368 else
01369 iRestoLoLoValues = 1;
01370
01371 }
01372 else
01373 iRestoLoLoValues = 0;
01374
01375 iihilo1 = iihilo2 + 1;
01376
01377 }
01378
01379 }
01380 else
01381 iRestoHiLoValues = 0;
01382
01383 iitop1 = iitop2 + 1;
01384
01385 }
01386 }
01387 else
01388 iRestoTopValues = 0;
01389
01390 psObjSort = (srawRetrList *) piolsort;
01391 psFileSort = (srawFileList *) piflsort;
01392
01393 if (iDebug == 2)
01394 {
01395 fprintf(fLogFile,
01396 "DDD final restore order after sorting:\n");
01397 for (jj=iisort1; jj<=iisort2; jj++)
01398 {
01399 ii = iaIndex[jj];
01400 fprintf(fLogFile,
01401 " %d: index %d, values: %u-%u-%u-%u-%u\n",
01402 jj, iaIndex[jj], iaCompValue[ii][1], iaCompValue[ii][2],
01403 iaCompValue[ii][3], iaCompValue[ii][4], iaCompValue[ii][5]);
01404 }
01405 }
01406
01407
01408
01409 psObjSort = (srawRetrList *) piolsort;
01410 psFileSort = (srawFileList *) piflsort;
01411
01412 psObj = psObj0;
01413 psFile = psFile0;
01414 iobj = iobj0;
01415 iiObj = 0;
01416 iiBuf = 1;
01417 icount = 0;
01418
01419 if (iDebug == 2) fprintf(fLogFile,
01420 "DDD copy TSM objects to temp destination for compression\n");
01421
01422 for (jj = 1; jj <= iFileAll; jj++)
01423 {
01424
01425 if (iaValue[jj][0] < 3)
01426 {
01427 if (iDebug == 2)
01428 {
01429 fprintf(fLogFile, " (%d): ignored", jj);
01430 if (psObj->iStageFS)
01431 fprintf(fLogFile, " (RC)\n");
01432 else if (psObj->iCacheFS)
01433 fprintf(fLogFile, " (WC)\n");
01434 else
01435 fprintf(fLogFile, "\n");
01436 }
01437
01438 iiObj++;
01439 psObj++;
01440 psFile++;
01441
01442 goto gNextCopy2Temp;
01443 }
01444
01445 iiObj++;
01446 icount++;
01447
01448 memcpy((char *) psObjSort, (char *) psObj, iRetrList);
01449 memcpy(psFileSort->cFile, psFile->cFile, iFileList);
01450
01451 if (iDebug == 2)
01452 {
01453 fprintf(fLogFile,
01454 " %d(%d): obj %s%s (objId %u-%u) copied (Comp), retrId %u-%u-%u-%u-%u\n",
01455 iiObj, jj, psObjSort->cNamehl, psObjSort->cNamell,
01456 psObjSort->iObjHigh, psObjSort->iObjLow,
01457 psObjSort->iRestoHigh, psObjSort->iRestoHighHigh,
01458 psObjSort->iRestoHighLow, psObjSort->iRestoLowHigh,
01459 psObjSort->iRestoLow);
01460 }
01461
01462 psObj++;
01463 psFile++;
01464 psObjSort++;
01465 psFileSort++;
01466
01467
01468 gNextCopy2Temp:
01469 if (iiObj == iobj)
01470 {
01471 if (iDebug > 1) fprintf(fLogFile,
01472 " buffer %d: last obj (no. %d) handled\n",
01473 iiBuf, iiObj);
01474 piptr = (int **) psObj;
01475 if (*piptr == NULL)
01476 {
01477 if (iDebug > 1) fprintf(fLogFile,
01478 " %d: last obj buffer\n", iiBuf);
01479 }
01480 else
01481 {
01482 iiObj = 0;
01483 iiBuf++;
01484 pinext = *piptr;
01485 iobj = *pinext++;
01486 psObj = (srawRetrList *) pinext;
01487 if (iDebug > 1) fprintf(fLogFile,
01488 " %d: new buffer, %d objs, first: |%s%s|\n",
01489 iiBuf, iobj, psObj->cNamehl, psObj->cNamell);
01490 }
01491 }
01492 }
01493
01494 if (iDebug == 2)
01495 {
01496 psObjSort = (srawRetrList *) piolsort;
01497 psFileSort = (srawFileList *) piflsort;
01498 fprintf(fLogFile,
01499 "DDD compressed list of TSM objects (not yet sorted):\n");
01500
01501 for (jj=1; jj<=iFileSort; jj++)
01502 {
01503 fprintf(fLogFile, " %d: obj %s%s, file %s\n",
01504 jj, psObjSort->cNamehl, psObjSort->cNamell, psFileSort->cFile);
01505
01506 psObjSort++;
01507 psFileSort++;
01508 }
01509 }
01510
01511 if (icount != iFileSort)
01512 {
01513 fprintf(fLogFile,
01514 "-E- %s: unexpected no. of objects found: %d, expected %d\n",
01515 cModule, icount, iFileSort);
01516 return -5;
01517 }
01518
01519
01520
01521
01522 psObjSort = (srawRetrList *) piolsort;
01523 psFileSort = (srawFileList *) piflsort;
01524
01525 if (iDebug == 2) fprintf(fLogFile,
01526 "DDD copy TSM objects in correct order to final destination\n");
01527
01528 ii1 = 1;
01529 for (jj = 1; jj <= iFileSort; jj++)
01530 {
01531 ii2 = iaIndex[jj];
01532 iDiff = ii2 - ii1;
01533 psObjSort += iDiff;
01534 psFileSort += iDiff;
01535
01536 icount++;
01537
01538 memcpy((char *) psObjComp, (char *) psObjSort, iRetrList);
01539 memcpy(psFileComp->cFile, psFileSort->cFile, iFileList);
01540
01541 if (iDebug == 2)
01542 {
01543 fprintf(fLogFile,
01544 " %d: TSM obj %s%s (index %d, objId %u-%u) copied (Comp), retrId %u-%u-%u-%u-%u\n",
01545 jj, psObjSort->cNamehl, psObjSort->cNamell, ii2,
01546 psObjSort->iObjHigh, psObjSort->iObjLow,
01547 psObjSort->iRestoHigh, psObjSort->iRestoHighHigh,
01548 psObjSort->iRestoHighLow, psObjSort->iRestoLowHigh, psObjSort->iRestoLow);
01549 }
01550
01551 psObjComp++;
01552 psFileComp++;
01553 ii1 = ii2;
01554
01555 }
01556
01557 iFileAll = iReadCache + iWriteCache + iFileSort;
01558 if (iDebug)
01559 {
01560 psObjComp = psObjComp0;
01561 psFileComp = psFileComp0;
01562 fprintf(fLogFile,
01563 "final list of all objects (compressed and sorted):\n");
01564
01565 for (jj=1; jj<=iFileAll; jj++)
01566 {
01567 fprintf(fLogFile,
01568 " %d: obj %s%s, file %s, objId %u-%u, retrId %u-%u-%u-%u-%u",
01569 jj, psObjComp->cNamehl, psObjComp->cNamell, psFileComp->cFile,
01570 psObjComp->iObjHigh, psObjComp->iObjLow,
01571 psObjComp->iRestoHigh, psObjComp->iRestoHighHigh,
01572 psObjComp->iRestoHighLow, psObjComp->iRestoLowHigh,
01573 psObjComp->iRestoLow);
01574 if (psObjComp->iStageFS)
01575 fprintf(fLogFile, " (RC)\n");
01576 else if (psObjComp->iCacheFS)
01577 fprintf(fLogFile, " (WC)\n");
01578 else
01579 fprintf(fLogFile, "\n");
01580
01581 psObjComp++;
01582 psFileComp++;
01583 }
01584 }
01585
01586 gEndCheckObjlist:
01587
01588 if (iSort)
01589 {
01590 memset(pcfl, 0x00, (unsigned) iFileBufComp);
01591 memcpy(pcfl, pcFileComp, (unsigned) iFileBufComp);
01592 }
01593
01594 if (iDebug) fprintf(fLogFile,
01595 "-D- end %s\n\n", cModule);
01596
01597 return 0;
01598
01599 }
01600
01601
01602
01603
01604
01605
01606
01607
01608 int rawDelFile( int iSocket, srawComm *psComm)
01609 {
01610 char cModule[32] = "rawDelFile";
01611 int iDebug = 0;
01612
01613 int iFSidRC = 0;
01614 int iFSidWC = 0;
01615
01616 int iRC;
01617 int iBufComm;
01618 char *pcc;
01619 void *pBuf;
01620 char cMsg[STATUS_LEN] = "";
01621
01622 srawStatus sStatus;
01623
01624 iBufComm = ntohl(psComm->iCommLen) + HEAD_LEN;
01625 if (iDebug) printf(
01626 "\n-D- begin %s: delete file %s%s%s\n",
01627 cModule, psComm->cNamefs, psComm->cNamehl, psComm->cNamell);
01628
01629 if (psComm->iStageFSid)
01630 iFSidRC = ntohl(psComm->iStageFSid);
01631 if (psComm->iFSidWC)
01632 iFSidWC = ntohl(psComm->iFSidWC);
01633
01634 if (iDebug)
01635 {
01636 printf(" object %s%s%s found (objId %u-%u)",
01637 psComm->cNamefs, psComm->cNamehl, psComm->cNamell,
01638 ntohl(psComm->iObjHigh), ntohl(psComm->iObjLow));
01639 if (iFSidRC) printf(
01640 ", on %s in read cache FS %d\n", psComm->cNodeRC, iFSidRC);
01641 else
01642 printf( "\n");
01643 if (iFSidWC) printf(
01644 " on %s in write cache FS %d\n", psComm->cNodeWC, iFSidWC);
01645 }
01646
01647 psComm->iAction = htonl(REMOVE);
01648
01649 pcc = (char *) psComm;
01650 if ( (iRC = send( iSocket, pcc, (unsigned) iBufComm, 0 )) < iBufComm)
01651 {
01652 if (iRC < 0) printf(
01653 "-E- %s: sending delete request for file %s (%d byte)\n",
01654 cModule, psComm->cNamell, iBufComm);
01655 else printf(
01656 "-E- %s: delete request for file %s (%d byte) incompletely sent (%d byte)\n",
01657 cModule, psComm->cNamell, iBufComm, iRC);
01658 if (errno)
01659 printf(" %s\n", strerror(errno));
01660 perror("-E- sending delete request");
01661
01662 return -1;
01663 }
01664
01665 if (iDebug) printf(
01666 " delete command sent to server (%d bytes), look for reply\n",
01667 iBufComm);
01668
01669
01670
01671 pcc = (char *) &sStatus;
01672 iRC = rawRecvStatus(iSocket, pcc);
01673 if (iRC != HEAD_LEN)
01674 {
01675 if (iRC < HEAD_LEN) printf(
01676 "-E- %s: receiving status buffer\n", cModule);
01677 else
01678 {
01679 printf("-E- %s: message received from server:\n", cModule);
01680 printf("%s", sStatus.cStatus);
01681 }
01682 if (iDebug)
01683 printf("\n-D- end %s\n\n", cModule);
01684
01685 return(-1);
01686 }
01687
01688 if (iDebug)
01689 printf(" status (%d) received from server (%d bytes)\n",
01690 sStatus.iStatus, iRC);
01691
01692 printf("-I- Object %s%s%s successfully deleted",
01693 psComm->cNamefs, psComm->cNamehl, psComm->cNamell);
01694 if (iFSidRC)
01695 printf( " (staged)\n");
01696 else
01697 printf( "\n");
01698 if (iFSidWC)
01699 printf( " was in write cache\n");
01700
01701 if (iDebug)
01702 printf("-D- end %s\n\n", cModule);
01703
01704 return 0;
01705
01706 }
01707
01708
01709
01710
01711
01712
01713
01714
01715 int rawDelList( int iSocketMaster,
01716
01717 int iDataMover,
01718 srawDataMoverAttr *pDataMover0,
01719 srawComm *psComm,
01720 char **pcFileList,
01721 char **pcObjList)
01722 {
01723 char cModule[32] = "rawDelList";
01724 int iDebug = 0;
01725
01726 int iSocket;
01727 char *pcfl, *pcol;
01728 int *pifl, *piol;
01729 int ifile;
01730 int iobj0, iobj;
01731 int iobjBuf;
01732
01733 srawFileList *psFile, *psFile0;
01734 srawRetrList *psObj;
01735 srawDataMoverAttr *pDataMover;
01736
01737 char *pcc, *pdelim;
01738
01739 bool_t bDelete, bDelDone;
01740 int **piptr;
01741
01742 int ii, jj, kk;
01743 int iRC, idel;
01744
01745 pcfl = *pcFileList;
01746 pifl = (int *) pcfl;
01747 ifile = pifl[0];
01748 psFile = (srawFileList *) ++pifl;
01749 psFile0 = psFile;
01750 pifl--;
01751
01752 if (iDebug)
01753 {
01754 printf("\n-D- begin %s\n", cModule);
01755 printf(" initial %d files, first file %s\n",
01756 ifile, psFile0->cFile);
01757 }
01758
01759 pDataMover = pDataMover0;
01760 pcol = *pcObjList;
01761 piol = (int *) pcol;
01762 iobj0 = 0;
01763
01764 iobjBuf = 0;
01765 idel = 0;
01766 bDelDone = bFalse;
01767 while (!bDelDone)
01768 {
01769 iobjBuf++;
01770 iobj = piol[0];
01771 psObj = (srawRetrList *) ++piol;
01772
01773 if (iDebug)
01774 printf(" buffer %d: %d objects, first obj %s%s (server %d)\n",
01775 iobjBuf, iobj, psObj->cNamehl, psObj->cNamell, psObj->iATLServer);
01776
01777 psComm->iAction = htonl(REMOVE);
01778 for (ii=1; ii<=iobj; ii++)
01779 {
01780 iobj0++;
01781 pcc = (char *) psObj->cNamell;
01782 pcc++;
01783
01784 if (iDebug) printf(
01785 " obj %d: %s%s, objId %d-%d\n",
01786 ii, psObj->cNamehl, psObj->cNamell,
01787 psObj->iObjHigh, psObj->iObjLow);
01788
01789 bDelete = bFalse;
01790 psFile = psFile0;
01791 for (jj=1; jj<=ifile; jj++)
01792 {
01793 if (iDebug) printf(
01794 " file %d: %s\n", jj, psFile->cFile);
01795
01796 pdelim = strrchr(psFile->cFile, *pcFileDelim);
01797 if (pdelim == NULL)
01798 {
01799 #ifdef VMS
01800 pdelim = strrchr(psFile->cFile, *pcFileDelim2);
01801 if (pdelim != NULL) pdelim++;
01802 else
01803 #endif
01804 pdelim = psFile->cFile;
01805 }
01806 else pdelim++;
01807
01808 iRC = strcmp(pdelim, pcc);
01809 if ( iRC == 0 )
01810 {
01811 bDelete = bTrue;
01812 break;
01813 }
01814 psFile++;
01815 }
01816
01817 if (bDelete)
01818 {
01819 if (iDebug)
01820 {
01821 printf(" matching file %d: %s, obj %d: %s%s",
01822 jj, psFile->cFile, ii, psObj->cNamehl, psObj->cNamell);
01823 if (psObj->iStageFS)
01824 printf(", on DM %s in StageFS %d\n",
01825 psObj->cMoverStage, psObj->iStageFS);
01826 else if (psObj->iCacheFS)
01827 {
01828 printf(", on DM %s in ArchiveFS %d\n",
01829 psObj->cMoverStage, psObj->iCacheFS);
01830 printf(" archived at %s by %s\n",
01831 psObj->cArchiveDate, psObj->cOwner);
01832 }
01833 else
01834 printf(" (not in disk pool)\n");
01835 }
01836
01837 psComm->iObjHigh = htonl(psObj->iObjHigh);
01838 psComm->iObjLow = htonl(psObj->iObjLow);
01839 psComm->iATLServer = htonl(psObj->iATLServer);
01840
01841 if (psObj->iStageFS)
01842 {
01843 psComm->iPoolIdRC = htonl(psObj->iPoolId);
01844 psComm->iStageFSid = htonl(psObj->iStageFS);
01845 strcpy(psComm->cNodeRC, psObj->cMoverStage);
01846 }
01847 else
01848 {
01849 psComm->iPoolIdRC = htonl(0);
01850 psComm->iStageFSid = htonl(0);
01851 strcpy(psComm->cNodeRC, "");
01852 }
01853
01854 if (psObj->iCacheFS)
01855 {
01856 if (psObj->iStageFS)
01857 psComm->iPoolIdWC = htonl(0);
01858 else
01859 psComm->iPoolIdWC = htonl(psObj->iPoolId);
01860 psComm->iFSidWC = htonl(psObj->iCacheFS);
01861 strcpy(psComm->cNodeWC, psObj->cMoverCache);
01862 }
01863 else
01864 {
01865 psComm->iPoolIdWC = htonl(0);
01866 psComm->iFSidWC = htonl(0);
01867 strcpy(psComm->cNodeWC, "");
01868 }
01869
01870 iRC = rawGetLLName(psFile->cFile,
01871 pcObjDelim, psComm->cNamell);
01872
01873 if (iDataMover > 1)
01874 {
01875 if ((strcmp(pDataMover->cNode,psObj->cMoverStage) == 0) ||
01876 (strlen(psObj->cMoverStage) == 0))
01877 {
01878 iSocket = pDataMover->iSocket;
01879 if (iDebug) printf(
01880 " current data mover %s, socket %d\n",
01881 pDataMover->cNode, iSocket);
01882 }
01883 else
01884 {
01885 pDataMover = pDataMover0;
01886 for (kk=1; kk<=iDataMover; kk++)
01887 {
01888 if (strcmp(pDataMover->cNode,
01889 psObj->cMoverStage) == 0)
01890 break;
01891 pDataMover++;
01892 }
01893
01894 if (kk > iDataMover)
01895 {
01896 printf("-E- %s: data mover %s not found in list\n",
01897 cModule, psObj->cMoverStage);
01898 return -1;
01899 }
01900
01901 iSocket = pDataMover->iSocket;
01902 if (iDebug) printf(
01903 " new data mover %s, socket %d\n",
01904 pDataMover->cNode, iSocket);
01905 }
01906 }
01907
01908 iRC = rawDelFile(iSocketMaster, psComm);
01909 if (iRC)
01910 {
01911 if (iDebug)
01912 printf(" rawDelFile: rc = %d\n", iRC);
01913 if (iRC < 0)
01914 {
01915 printf("-E- %s: file %s could not be deleted\n",
01916 cModule, psFile->cFile);
01917 if (iDebug)
01918 printf("-D- end %s\n\n", cModule);
01919
01920 return -1;
01921 }
01922
01923
01924 }
01925
01926 idel++;
01927
01928 }
01929 else if (iDebug) printf(
01930 " file %s: obj %s%s not found in gStore\n",
01931 psFile0->cFile, psObj->cNamehl, psObj->cNamell);
01932
01933 psObj++;
01934
01935 }
01936
01937 piptr = (int **) psObj;
01938 if (*piptr == NULL) bDelDone = bTrue;
01939 else piol = *piptr;
01940
01941 }
01942
01943 if (iDebug)
01944 printf("-D- end %s\n\n", cModule);
01945
01946 return(idel);
01947
01948 }
01949
01950
01951
01952
01953
01954
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964 int rawGetFilelistEntries( char *pcFileName,
01965 int *piDataFS,
01966 char *pcDataFS,
01967 int *piEntries,
01968 int *piGlobalDir)
01969 {
01970 char cModule[32] = "rawGetFilelistEntries";
01971 int iDebug = 0;
01972
01973 char cMsg[STATUS_LEN] = "";
01974 int ii, jj;
01975 int iDelCount = 0;
01976 int iFilesIgnored = 0;
01977 int iGlobalDir = 0;
01978 int iDataFS = 0;
01979 int imax = MAX_FULL_FILE - 1;
01980 char cPath[MAX_FULL_FILE] = "";
01981 char cEntry[MAX_FULL_FILE] = "";
01982 char cTemp[MAX_FULL_FILE] = "";
01983 char cFileName[MAX_FULL_FILE] = "";
01984 char cQualifier[16] = ".filelist";
01985 const char *pcLeading = "@";
01986 char *pcc;
01987 char *ploc;
01988 char *pccT = NULL;
01989 char *pccE;
01990
01991 int iRemove = 0;
01992 int iGeneric = 0;
01993 int iSingle = 0;
01994 int iRC;
01995 int iError;
01996
01997 int iGenericEntries = 0;
01998 int iSingleEntries = 0;
01999 int iEntries = -1;
02000 FILE *fiFile = NULL;
02001
02002 int iMaxEntries;
02003 int iSizeBuffer;
02004 int *piFilelist, *piFilelisto;
02005 srawFileList *pFilelist,
02006 *pFilelistc,
02007 *pFilelistco,
02008 *pFilelistc0;
02009
02010 if (iDebug)
02011 printf("\n-D- begin %s\n", cModule);
02012
02013 iDataFS = *piDataFS;
02014 piFilelist = piEntryList;
02015 iPathPrefix = strlen(cPathPrefix);
02016
02017 if ((int) strlen(pcFileName) >= imax)
02018 {
02019 fprintf(fLogFile,
02020 "-E- %s: file name too long (max %d)\n",
02021 cModule, --imax);
02022 iError = -1;
02023 goto gErrorFilelist;
02024 }
02025 strcpy(cFileName, pcFileName);
02026
02027 pccT = (char *) strrchr(pcFileName, *pcLeading);
02028 if (pccT)
02029 {
02030 pccE = (char *) strrchr(pccT, *pcObjDelim);
02031 if (pccE)
02032 pccT = NULL;
02033 }
02034
02035 if (pccT == NULL)
02036 {
02037 if (iDebug) fprintf(fLogFile,
02038 " no leading '%s' in file name %s\n", pcLeading, pcFileName);
02039 goto gEndFilelist;
02040 }
02041
02042 pcc = cQualifier;
02043 ploc = strrchr(cFileName, pcc[0]);
02044 if (ploc != NULL)
02045 {
02046 ploc++;
02047 pcc++;
02048 if (strcmp(ploc, pcc) != 0)
02049 {
02050 if (iDebug) fprintf(fLogFile,
02051 " no trailing %s\n", cQualifier);
02052 goto gEndFilelist;
02053 }
02054 }
02055 else
02056 {
02057 if (iDebug) fprintf(fLogFile,
02058 " no trailing %s in file name %s\n", cQualifier, pcFileName);
02059 goto gEndFilelist;
02060 }
02061
02062 if (iDebug) fprintf(fLogFile,
02063 " %s is a filelist\n", cFileName);
02064
02065 fiFile = fopen(pcFileName, "r");
02066 if (fiFile == NULL)
02067 {
02068 fprintf(fLogFile, "-E- %s: opening filelist %s\n",
02069 cModule, pcFileName);
02070 if (errno)
02071 fprintf(fLogFile, " %s\n", strerror(errno));
02072 perror("-E- opening filelist");
02073
02074 iError = -1;
02075 goto gErrorFilelist;
02076 }
02077 if (iDebug) fprintf(fLogFile,
02078 " filelist %s opened\n", pcFileName);
02079
02080 piFilelisto = piFilelist;
02081 iMaxEntries = *piFilelist;
02082 if (iDebug) fprintf(fLogFile,
02083 " max no. of entries in filelist buffer: %d\n", iMaxEntries);
02084 if (iDebug == 2) fprintf(fLogFile,
02085 "DDD piFilelist %p, *piFilelist %d\n",
02086 piFilelist, *piFilelist);
02087
02088 pFilelist = (srawFileList *) &(piFilelist[1]);
02089
02090 pFilelistc = pFilelist;
02091 pccE = cEntry;
02092 iEntries = 0;
02093 for(;;)
02094 {
02095 pccE = fgets(cEntry, imax, fiFile);
02096
02097 if ( (pccE != NULL) && (strlen(pccE) > 1) )
02098 {
02099
02100 ii = strlen(pccE);
02101 memset(cTemp, '\0', strlen(cTemp));
02102 pccT = cTemp;
02103 iDelCount = 0;
02104 while (ii-- > 0)
02105 {
02106 if ( (*pccE != '\0') && (*pccE != '\n') && (*pccE != '\r') &&
02107 (*pccE != ' ') )
02108 {
02109 strncpy(pccT, pccE, 1);
02110 pccT++;
02111 }
02112 else
02113 iDelCount++;
02114
02115 pccE++;
02116
02117 }
02118 strncpy(pccT, "\0", 1);
02119
02120 if (iDebug == 2) fprintf(fLogFile,
02121 "'%s' -> '%s': %d chars removed\n", cEntry, cTemp, iDelCount);
02122
02123
02124 if (iEntries == 0)
02125 {
02126 if (strncmp(cTemp, cPathPrefix, (unsigned) iPathPrefix) == 0)
02127 {
02128 iGlobalDir = 1;
02129
02130 if (iDebug) fprintf(fLogFile,
02131 " path prefix '%s' in first filelist entry found\n",
02132 cPathPrefix);
02133
02134 pccT = cTemp;
02135 for (ii=1; ii<=iPathPrefix; ii++)
02136 { pccT++; }
02137
02138 if (strlen(pccT) == 0)
02139 {
02140 fprintf(fLogFile,
02141 "-W- no path name found after path prefix: %s\n",
02142 cEntry);
02143 continue;
02144 }
02145
02146 ii = strlen(pccT) - 1;
02147 pcc = pccT;
02148 pcc += ii;
02149 if (strncmp(pcc, "/", 1) == 0)
02150 strncpy(cPath, pccT, (unsigned) ii);
02151 else
02152 strcpy(cPath, pccT);
02153
02154 if (iDebug) fprintf(fLogFile,
02155 " path '%s' for files in filelist\n", cPath);
02156
02157 if ( (strncmp(cPath, cDataFSHigh1,
02158 strlen(cDataFSHigh1)) == 0) ||
02159 (strncmp(cPath, cDataFSHigh2,
02160 strlen(cDataFSHigh2)) == 0) )
02161 {
02162 iDataFS = 1;
02163 strcpy(pcDataFS, cPath);
02164
02165 if (iDebug) fprintf(fLogFile,
02166 " central data FS path %s\n", cPath);
02167 }
02168
02169 continue;
02170
02171 }
02172 }
02173
02174 if (strncmp(cTemp, cPathPrefix, (unsigned) iPathPrefix) == 0)
02175 {
02176 fprintf(fLogFile,
02177 "-E- only one path specification in file list allowed, %s and following files ignored\n",
02178 cTemp);
02179 break;
02180 }
02181
02182
02183 while ( (ploc = strchr(cTemp, *pcPerc)) != NULL)
02184 {
02185 if (iDebug)
02186 fprintf(fLogFile, "-W- replace %s", cTemp);
02187 *ploc = *pcQM;
02188 if (iDebug)
02189 fprintf(fLogFile, " by %s\n", cTemp);
02190 }
02191
02192 if ( (iEntries == iMaxEntries) &&
02193 (iEntries > 0) )
02194 {
02195 iMaxEntries += iMaxEntries;
02196 if (iDebug) fprintf(fLogFile,
02197 " entry buffer full, reallocate: max %d entries\n",
02198 iMaxEntries);
02199
02200 iSizeBuffer = iMaxEntries*MAX_FULL_FILE + sizeof(int);
02201 piFilelisto = piFilelist;
02202 piFilelist = (int *) calloc(
02203 (unsigned) iSizeBuffer, sizeof(char) );
02204 if (piFilelist == NULL)
02205 {
02206 fprintf(fLogFile,
02207 "-E- %s: reallocating filelist buffer (size %d)\n",
02208 cModule, iSizeBuffer);
02209 if (errno)
02210 fprintf(fLogFile, " %s\n", strerror(errno));
02211 perror("-E- reallocating filelist buffer");
02212
02213 iError = -1;
02214 goto gErrorFilelist;
02215 }
02216
02217 if (iDebug) fprintf(fLogFile,
02218 " filelist entry buffer reallocated (size %d)\n",
02219 iSizeBuffer);
02220
02221 *piFilelist = iMaxEntries;
02222 if (iDebug == 2) fprintf(fLogFile,
02223 "DDD piFilelist %p, *piFilelist %d\n",
02224 piFilelist, *piFilelist);
02225
02226 pFilelistc = (srawFileList *) &(piFilelist[1]);
02227 pFilelistco = pFilelist;
02228 pFilelist = pFilelistc;
02229
02230 for (ii=1; ii<=iEntries; ii++)
02231 {
02232 if (iDebug == 2) fprintf(fLogFile,
02233 "DDD pFilelistc %p\n", pFilelistc);
02234 strcpy(pFilelistc->cFile, pFilelistco->cFile);
02235 pFilelistc++;
02236 pFilelistco++;
02237 }
02238
02239 if (iDebug) fprintf(fLogFile,
02240 " %d old entries copied to new buffer, next:\n",
02241 iEntries);
02242
02243 if (iDebug == 2) fprintf(fLogFile,
02244 "DDD free piFilelisto %p\n", piFilelisto);
02245 free(piFilelisto);
02246 piFilelisto = piFilelist;
02247
02248 }
02249
02250 if (iDebug == 2) fprintf(fLogFile,
02251 "DDD pFilelistc %p\n", pFilelistc);
02252
02253 if ( (ploc = strchr(cTemp, *pcObjDelim)) != NULL)
02254 {
02255 iFilesIgnored++;
02256 if (iFilesIgnored == 1) fprintf(fLogFile,
02257 "-W- file-specific path not yet implemented in filelist\n");
02258 fprintf(fLogFile, "-W- %s ignored\n", cTemp);
02259 continue;
02260 }
02261
02262 if (iGlobalDir)
02263 {
02264 strcpy(pFilelistc->cFile, cPath);
02265 strncat(pFilelistc->cFile, "/", 1);
02266 }
02267 strcat(pFilelistc->cFile, cTemp);
02268 iEntries++;
02269
02270 if (iDebug) fprintf(fLogFile,
02271 " %3d: %s \n", iEntries, pFilelistc->cFile);
02272
02273 pFilelistc++;
02274 }
02275 else
02276 break;
02277
02278 }
02279
02280 *piGlobalDir = iGlobalDir;
02281
02282 pFilelistc = pFilelist;
02283 if (iDebug)
02284 {
02285 fprintf(fLogFile, " after allocation:\n");
02286 for (ii=1; ii<=iEntries; ii++)
02287 {
02288 fprintf(fLogFile,
02289 " %3da: %s \n", ii, pFilelistc->cFile);
02290 pFilelistc++;
02291 }
02292 }
02293
02294
02295 if (iEntries)
02296 {
02297 pFilelistc = pFilelist;
02298 iRemove = 0;
02299 for (ii=1; ii<iEntries; ii++)
02300 {
02301 if (strlen(pFilelistc->cFile) == 0)
02302 {
02303 pFilelistc++;
02304 continue;
02305 }
02306
02307 pFilelistco = pFilelistc;
02308 pFilelistco++;
02309 for (jj=ii+1; jj<=iEntries; jj++)
02310 {
02311 if (strcmp(pFilelistc->cFile, pFilelistco->cFile) == 0)
02312 {
02313 if (iDebug)
02314 fprintf(fLogFile, "-W- duplicate entry %s removed\n",
02315 pFilelistco->cFile);
02316 strcpy(pFilelistco->cFile, "");
02317 iRemove++;
02318 }
02319 pFilelistco++;
02320 }
02321
02322 pFilelistc++;
02323 }
02324
02325 if (iDebug)
02326 {
02327 if (iRemove) fprintf(fLogFile,
02328 " %d duplicate entries found in list\n", iRemove);
02329 else fprintf(fLogFile,
02330 " no duplicate entries found in list\n");
02331 }
02332 }
02333 else
02334 {
02335 if (iDebug)
02336 fprintf(fLogFile, " no valid entries found in list\n");
02337 goto gEndFilelist;
02338 }
02339
02340 pFilelistc = pFilelist;
02341 if (iDebug)
02342 {
02343 fprintf(fLogFile, " after removal of duplicates:\n");
02344 for (ii=1; ii<=iEntries; ii++)
02345 {
02346 fprintf(fLogFile,
02347 " %3db: %s \n", ii, pFilelistc->cFile);
02348 pFilelistc++;
02349 }
02350 }
02351
02352
02353 if (iRemove)
02354 {
02355 pFilelistc = pFilelist;
02356 for (ii=1; ii<iEntries; ii++)
02357 {
02358 if (strlen(pFilelistc->cFile) == 0)
02359 {
02360 pFilelistco = pFilelistc;
02361 pFilelistco++;
02362 pFilelistc0 = pFilelistc;
02363 for (jj=ii+1; jj<=iEntries; jj++)
02364 {
02365 strcpy(pFilelistc0->cFile, pFilelistco->cFile);
02366 pFilelistc0++;
02367 pFilelistco++;
02368 }
02369 continue;
02370
02371 }
02372 pFilelistc++;
02373 }
02374 iEntries -= iRemove;
02375 }
02376
02377 *piFilelist = iEntries;
02378
02379
02380 pFilelistc = pFilelist;
02381 for (ii=1; ii<=iEntries; ii++)
02382 {
02383 ploc = strchr(pFilelistc->cFile, *pcStar);
02384 if (ploc != NULL)
02385 iGeneric = 1;
02386 else
02387 {
02388 ploc = strchr(pFilelistc->cFile, *pcQM);
02389 if (ploc != NULL)
02390 iGeneric = 1;
02391 else
02392 {
02393 ploc = strchr(pFilelistc->cFile, *pcPerc);
02394 if (ploc != NULL)
02395 iGeneric = 1;
02396 else
02397 iSingle = 1;
02398 }
02399 }
02400 if ( (iGeneric) && (iSingle) )
02401 break;
02402
02403 pFilelistc++;
02404 }
02405
02406
02407 if ( (iGeneric) && (iSingle) )
02408 {
02409 piFilelisto = piFilelist;
02410
02411
02412 iSizeBuffer = iEntries*MAX_FULL_FILE + sizeof(int);
02413 piFilelist = (int *) calloc((unsigned) iSizeBuffer, sizeof(char));
02414 if (piFilelist == NULL)
02415 {
02416 fprintf(fLogFile,
02417 "-E- %s: allocating ordered filelist buffer (size %d)\n",
02418 cModule, iSizeBuffer);
02419 if (errno)
02420 fprintf(fLogFile, " %s\n", strerror(errno));
02421 perror("-E- allocating ordered filelist buffer");
02422
02423 iError = -1;
02424 goto gErrorFilelist;
02425 }
02426
02427 if (iDebug) fprintf(fLogFile,
02428 " ordered filelist buffer allocated (size %d)\n",
02429 iSizeBuffer);
02430
02431 if (iDebug == 2) fprintf(fLogFile,
02432 "DDD piFilelist %p, *piFilelist %d\n",
02433 piFilelist, *piFilelist);
02434
02435 pFilelistc = (srawFileList *) &(piFilelist[1]);
02436 pFilelist = pFilelistc;
02437 pFilelistco = (srawFileList *) &(piFilelisto[1]);
02438 iGenericEntries = 0;
02439
02440
02441 for (ii=1; ii<=iEntries; ii++)
02442 {
02443 iGeneric = 0;
02444 iSingle = 0;
02445 ploc = strchr(pFilelistco->cFile, *pcStar);
02446 if (ploc != NULL)
02447 iGeneric = 1;
02448 else
02449 {
02450 ploc = strchr(pFilelistco->cFile, *pcQM);
02451 if (ploc != NULL)
02452 iGeneric = 1;
02453 else
02454 {
02455 ploc = strchr(pFilelistco->cFile, *pcPerc);
02456 if (ploc != NULL)
02457 iGeneric = 1;
02458 else
02459 iSingle = 1;
02460 }
02461 }
02462
02463 if (iGeneric)
02464 {
02465 strcpy(pFilelistc->cFile, pFilelistco->cFile);
02466 strcpy(pFilelistco->cFile, "");
02467 pFilelistc++;
02468 iGenericEntries++;
02469 }
02470 pFilelistco++;
02471
02472 }
02473
02474 pFilelistco = (srawFileList *) &(piFilelisto[1]);
02475 iSingleEntries = 0;
02476
02477
02478 for (ii=1; ii<=iEntries; ii++)
02479 {
02480 if (strlen(pFilelistco->cFile) != 0)
02481 {
02482 strcpy(pFilelistc->cFile, pFilelistco->cFile);
02483 pFilelistc++;
02484 iSingleEntries++;
02485 }
02486 pFilelistco++;
02487 }
02488
02489 if (iDebug) fprintf(fLogFile,
02490 " %d generic file names, followed by %d non-generic file names\n",
02491 iGenericEntries, iSingleEntries);
02492
02493 }
02494
02495 pFilelistc = pFilelist;
02496 if (iDebug)
02497 {
02498 fprintf(fLogFile, " after reordering:\n");
02499 for (ii=1; ii<=iEntries; ii++)
02500 {
02501 fprintf(fLogFile,
02502 " %3dc: %s \n", ii, pFilelistc->cFile);
02503 pFilelistc++;
02504 }
02505 }
02506
02507 gEndFilelist:
02508 *piEntries = iEntries;
02509 iError = 0;
02510
02511 if ( (iDebug == 2) && (pccT) ) fprintf(fLogFile,
02512 "DDD piFilelist %p, *piFilelist %d\n",
02513 piFilelist, *piFilelist);
02514
02515 gErrorFilelist:
02516 if (fiFile)
02517 {
02518 iRC = fclose(fiFile);
02519 if (iRC)
02520 {
02521 fprintf(fLogFile, "-E- %s: closing filelist %s\n",
02522 cModule, pcFileName);
02523 if (errno)
02524 fprintf(fLogFile, " %s\n", strerror(errno));
02525 perror("-E- closing filelist");
02526 }
02527 }
02528
02529 *piDataFS = iDataFS;
02530 piEntryList = piFilelist;
02531
02532 if (iDebug)
02533 printf("-D- end %s\n\n", cModule);
02534
02535 return iError;
02536
02537 }
02538
02539
02540
02541
02542
02543
02544
02545
02546 int rawGetWSInfo( srawCliActionComm *pCliActionComm,
02547 srawPoolStatus *pPoolInfo,
02548 srawWorkSpace **ppWorkSpace)
02549 {
02550 char cModule[32] = "rawGetWSInfo";
02551 int iDebug = 0;
02552
02553 int iRC;
02554 int iSocket;
02555 int iPoolInfo;
02556 int iPrintPoolInfo;
02557 int iWorkSpaceInfo;
02558 char cMsg[STATUS_LEN] = "";
02559
02560 int iAction;
02561 int iATLServer = 0;
02562
02563 int iBuf;
02564 int ii;
02565 int iIdent;
02566 int iStatus;
02567 int iAttrLen;
02568
02569 int iPoolId;
02570 int iPoolMode = 0;
02571 int iSleepClean = 0;
02572
02573 int iPoolmax;
02574 int iPoolcur;
02575 int iBufPool;
02576
02577 char cPoolNameRand[32] = "RetrievePool";
02578 char cPoolNameTemp[32] = "StagePool";
02579 int iHardwareFree = 0;
02580 int iPoolRandFree = 0;
02581 int iPoolRandUsed;
02582 int iRandomExcess = 0;
02583
02584 int iPoolTempAvail = 0;
02585 int iPoolTempMax = 0;
02586 int iPoolTempMaxWS = 0;
02587 int iPoolTempFree = 0;
02588 int iPoolTempUsed;
02589 int iPoolTempCheck;
02590
02591 int iTempSizeUnavail = 0;
02592
02593
02594 int iWorkSizeNew;
02595
02596 int iWorkSizeAll;
02597 int iWorkFilesAll;
02598 int iWorkSizeSta = 0;
02599 int iWorkFilesSta = 0;
02600
02601 int iWorkSizeStaTemp = 0;
02602
02603 int iWorkFilesStaTemp = 0;
02604 int iWorkSizeStaRand = 0;
02605
02606 int iWorkFilesStaRand = 0;
02607 int iWorkSizeEst = 0;
02608 int iWorkFilesEst = 0;
02609
02610 int iWorkStatus = 0;
02611
02612
02613 int *piBuffer;
02614 char *pcc;
02615 char cMsgPref[8] = "";
02616 char cMisc[128] = "";
02617 char pcGenFile[MAX_FULL_FILE] = "";
02618
02619 srawWorkSpace *pWorkSpace;
02620 srawPoolStatusData *pPoolInfoData, *pPoolInfoData0;
02621
02622 if (iDebug)
02623 printf("\n-D- begin %s\n", cModule);
02624
02625 piBuffer = pCliActionComm->piBuffer;
02626 iSocket = pCliActionComm->iSocket;
02627 iAction = pCliActionComm->iAction;
02628
02629 iPoolInfo = 1;
02630 if (iAction == QUERY_POOL)
02631 {
02632 iPoolId = pCliActionComm->iStatus;
02633 iPrintPoolInfo = 1;
02634 iWorkSpaceInfo = 0;
02635 }
02636 else
02637 {
02638 strcpy(pcGenFile, pCliActionComm->pcFile);
02639 iPoolId = 2;
02640 if (pCliActionComm->iStatus)
02641 iPrintPoolInfo = 1;
02642 else
02643 iPrintPoolInfo = 0;
02644 iWorkSpaceInfo = 1;
02645 }
02646
02647 if (iDebug)
02648 {
02649 printf(" action %d", iAction);
02650 if (iPrintPoolInfo)
02651 printf(", print pool info");
02652 if (iAction == QUERY_POOL)
02653 printf(", poolId %d\n", iPoolId);
02654 else
02655 printf("\n");
02656 }
02657
02658 if (iPoolInfo)
02659 {
02660 pcc = (char *) piBuffer;
02661 pPoolInfo = (srawPoolStatus *) piBuffer;
02662 iRC = rawRecvHead(iSocket, pcc);
02663 if (iRC <= 0)
02664 {
02665 printf("-E- receiving header pool status from master server\n");
02666 return -1;
02667 }
02668
02669 iIdent = ntohl(pPoolInfo->iIdent);
02670 iStatus = ntohl(pPoolInfo->iPoolNo);
02671 iAttrLen = ntohl(pPoolInfo->iStatusLen);
02672
02673 if (iDebug) printf(
02674 " header pool status received (%d bytes): ident %d, status %d, attrlen %d\n",
02675 iRC, iIdent, iStatus, iAttrLen);
02676
02677
02678 if (iIdent != IDENT_POOL)
02679 {
02680 if (iIdent == IDENT_STATUS)
02681 {
02682 if ( (iStatus == STA_ERROR) || (iStatus == STA_ERROR_EOF) )
02683 {
02684 printf("-E- received error status from server");
02685 if (iDebug)
02686 printf(" instead of pool info:\n");
02687 else printf(":\n");
02688
02689 if (iAttrLen > 0)
02690 {
02691 pcc = cMsg;
02692 iRC = rawRecvError(iSocket, iAttrLen, pcc);
02693 if (iRC < 0) printf(
02694 "-E- receiving error msg from server, rc = %d\n",
02695 iRC);
02696 else printf(" %s\n", pcc);
02697 }
02698 else printf(" no error message available\n");
02699
02700 }
02701 else
02702 {
02703 printf(
02704 "-E- unexpected status (type %d) received from server\n",
02705 iStatus);
02706 }
02707 }
02708 else
02709 {
02710 printf(
02711 "-E- unexpected header (%d) received from server\n",
02712 iIdent);
02713 }
02714
02715 return -1;
02716
02717 }
02718
02719 iPoolmax = iStatus;
02720 iBufPool = iAttrLen;
02721
02722 pcc += HEAD_LEN;
02723 pPoolInfoData = (srawPoolStatusData *) pcc;
02724 pPoolInfoData0 = pPoolInfoData;
02725
02726
02727 iBuf = iBufPool;
02728 while(iBuf > 0)
02729 {
02730 if ( (iRC = recv( iSocket, pcc, (unsigned) iBuf, 0 )) <= 0)
02731 {
02732 if (iRC < 0) printf(
02733 "-E- %s: receiving pool info\n", cModule);
02734 else
02735 {
02736 ii = iBufPool - iBuf;
02737 printf(
02738 "-E- %s: connection to entry server broken, %d byte of pool info (%d byte) received\n",
02739 cModule, ii, iBufPool);
02740 }
02741 if (errno)
02742 printf(" %s\n", strerror(errno));
02743 perror("-E- receiving pool info");
02744
02745 return -1;
02746 }
02747
02748 iBuf -= iRC;
02749 pcc += iRC;
02750
02751 }
02752
02753 if (iDebug) printf(
02754 " stage pool status received (%d bytes)\n", iBufPool);
02755
02756 iATLServer = 1;
02757
02758 if ( (iAction == QUERY_POOL) || (iAction == QUERY_WORKSPACE) ||
02759 (iAction == STAGE) )
02760 for (iPoolcur=1; iPoolcur<=iPoolmax; iPoolcur++)
02761 {
02762 if (iPoolcur == 1)
02763 {
02764 iHardwareFree = ntohl(pPoolInfoData->iFreeSizeHW);
02765 iPoolRandFree = ntohl(pPoolInfoData->iFreeSize);
02766 }
02767 if (iPoolcur == 2)
02768 iPoolTempFree = ntohl(pPoolInfoData->iFreeSize);
02769
02770 if (strcmp(pPoolInfoData->cPoolName, "RetrievePool") == 0)
02771 iPoolMode = 1;
02772 if (strcmp(pPoolInfoData->cPoolName, "StagePool") == 0)
02773 iPoolMode = 2;
02774
02775 if ( (iAction == QUERY_POOL) || (iAction == QUERY_WORKSPACE) )
02776 {
02777 if (iPoolMode == 1)
02778 {
02779 if (iPrintPoolInfo) printf(
02780 "-I- overall HW space ATL server%d %8d MByte, free %8d MByte\n",
02781 iATLServer,
02782 ntohl(pPoolInfoData->iMaxSizeHW), iHardwareFree);
02783
02784 if ( (iPoolId == iPoolMode) || (iPoolId == 0) )
02785 {
02786 printf(" %s: used for 'gstore retrieve'\n",
02787 pPoolInfoData->cPoolName);
02788
02789 iPoolRandUsed = ntohl(pPoolInfoData->iMaxSize) -
02790 iPoolRandFree;
02791 if (iPoolRandFree < 0)
02792 iRandomExcess = -iPoolRandFree;
02793
02794 printf(
02795 " used space %8d MByte, %d files stored\n",
02796 iPoolRandUsed, ntohl(pPoolInfoData->iFiles));
02797
02798 if (iAction == QUERY_POOL)
02799 {
02800 if (iHardwareFree > 0) printf(
02801 " free space (%8d MByte) shared with StagePool\n",
02802 iHardwareFree);
02803 printf(" no min file lifetime\n");
02804 }
02805
02806 }
02807 }
02808
02809 if (iPoolMode == 2)
02810 {
02811 if ( (iPoolId == iPoolMode) || (iPoolId == 0) )
02812 {
02813 if (iPrintPoolInfo) printf(
02814 " %s: used for 'gstore stage'\n",
02815 pPoolInfoData->cPoolName);
02816 iPoolTempAvail = ntohl(pPoolInfoData->iFileAvail);
02817
02818 iPoolTempUsed = ntohl(pPoolInfoData->iMaxSize) -
02819 iPoolTempFree;
02820 iPoolTempFree = iHardwareFree;
02821 if (iPoolTempFree < 0)
02822 iPoolTempFree = 0;
02823
02824 if (iHardwareFree < iPoolTempFree)
02825 iTempSizeUnavail = iPoolTempFree - iHardwareFree;
02826
02827 if ( (iPoolTempFree >= 0) && (iPrintPoolInfo) )
02828 {
02829 printf( " used space %8d MByte, %d files stored\n",
02830 iPoolTempUsed, ntohl(pPoolInfoData->iFiles));
02831 if ( (iAction == QUERY_POOL) &&
02832 (iPoolTempFree > 0) ) printf(
02833 " free space (%8d MByte) shared with RetrievePool\n",
02834 iHardwareFree);
02835 }
02836 if (iPrintPoolInfo) printf(
02837 " min file availability of %d days guaranteed\n",
02838 ntohl(pPoolInfoData->iFileAvail));
02839
02840 }
02841 }
02842 }
02843
02844 if ( (iPoolMode == 2) &&
02845 ((iAction == STAGE) || (iAction == QUERY_WORKSPACE)) )
02846 {
02847 iPoolTempMax = ntohl(pPoolInfoData->iMaxSize);
02848 iPoolTempMaxWS = ntohl(pPoolInfoData->iMaxWorkSize);
02849 iPoolTempCheck = ntohl(pPoolInfoData->iCheckSize);
02850 }
02851
02852 pPoolInfoData++;
02853
02854 }
02855 pPoolInfoData = pPoolInfoData0;
02856
02857 }
02858
02859
02860
02861 if (iWorkSpaceInfo)
02862 {
02863 pWorkSpace = (srawWorkSpace *) pcc;
02864 *ppWorkSpace = pWorkSpace;
02865
02866 iRC = rawRecvHead(iSocket, pcc);
02867 if (iRC <= 0)
02868 {
02869 printf("-E- receiving work space buffer header\n");
02870 return -1;
02871 }
02872 if (iDebug)
02873 printf("-D- header work space buffer received (%d bytes)\n",
02874 iRC);
02875
02876 iIdent = ntohl(pWorkSpace->iIdent);
02877 iStatus = ntohl(pWorkSpace->iWorkId);
02878 iAttrLen = ntohl(pWorkSpace->iStatusLen);
02879
02880
02881 if (iIdent != IDENT_WORKSPACE)
02882 {
02883 if (iIdent == IDENT_STATUS)
02884 {
02885 if ( (iStatus == STA_ERROR) || (iStatus == STA_ERROR_EOF) )
02886 {
02887 if (iDebug) printf("\n");
02888 printf("-E- received error status from server");
02889 if (iDebug)
02890 printf(" instead of work space info:\n");
02891 else printf(":\n");
02892
02893 if (iAttrLen > 0)
02894 {
02895 pcc = (char *) piBuffer;
02896 iRC = rawRecvError(iSocket, iAttrLen, pcc);
02897 if (iRC < 0) printf(
02898 "-E- receiving error msg from server, rc = %d\n",
02899 iRC);
02900 else printf(" %s\n", pcc);
02901 }
02902 else printf(" no error message available\n");
02903
02904 }
02905 else
02906 {
02907 printf(
02908 "-E- unexpected status (%d) received from server\n",
02909 iStatus);
02910 }
02911 }
02912 else
02913 {
02914 printf(
02915 "-E- unexpected header (%d) received from server\n",
02916 iIdent);
02917 }
02918
02919 return -1;
02920
02921 }
02922
02923
02924 iBuf = iAttrLen;
02925 pcc += HEAD_LEN;
02926 while(iBuf > 0)
02927 {
02928 if ( (iRC = recv( iSocket, pcc, (unsigned) iBuf, 0 )) <= 0)
02929 {
02930 if (iRC < 0) printf(
02931 "-E- %s: receiving work space info (%d byte)\n",
02932 cModule, iAttrLen);
02933 else
02934 {
02935 ii = iAttrLen - iBuf;
02936 printf("-E- %s: connection to sender broken, %d byte of work space info (%d byte) received\n",
02937 cModule, ii, iAttrLen);
02938 }
02939 if (errno)
02940 printf(" %s\n", strerror(errno));
02941 perror("-E- receiving work space info");
02942
02943 return -1;
02944 }
02945
02946 iBuf -= iRC;
02947 pcc += iRC;
02948
02949 }
02950
02951 if (iDebug)
02952 printf(" remainder work space buffer received (%d byte)\n",
02953 iAttrLen);
02954
02955 iWorkSizeAll = ntohl(pWorkSpace->iWorkSizeAll);
02956 iWorkFilesAll = ntohl(pWorkSpace->iWorkFilesAll);
02957 iWorkStatus = ntohl(pWorkSpace->iStatus);
02958 iWorkSizeSta = ntohl(pWorkSpace->iWorkSizeSta);
02959 iWorkFilesSta = ntohl(pWorkSpace->iWorkFilesSta);
02960 iWorkSizeStaTemp = ntohl(pWorkSpace->iWorkSizeStaTemp);
02961 iWorkFilesStaTemp = ntohl(pWorkSpace->iWorkFilesStaTemp);
02962 iWorkSizeEst = ntohl(pWorkSpace->iWorkSizeEst);
02963 iWorkFilesEst = ntohl(pWorkSpace->iWorkFilesEst);
02964
02965 iWorkSizeStaRand = iWorkSizeSta - iWorkSizeStaTemp;
02966 iWorkFilesStaRand = iWorkFilesSta - iWorkFilesStaTemp;
02967
02968
02969 if (iPoolInfo || (iAction == QUERY_WORKSPACE) || (iDebug) )
02970 {
02971 if (iDebug)
02972 {
02973 printf(" %d files, overall size %d MByte",
02974 iWorkFilesAll, iWorkSizeAll);
02975 if (iWorkFilesEst)
02976 printf(", size estimated for %d files (%d MByte)\n",
02977 iWorkFilesEst, iWorkSizeEst);
02978 }
02979
02980 if (iWorkSizeSta == iWorkSizeAll)
02981 {
02982 if (iDebug)
02983 {
02984 printf(
02985 "\n all files already available on central disk\n");
02986 if ( (iPoolId == 2) &&
02987 iWorkSizeStaRand &&
02988 (iAction == QUERY_WORKSPACE) )
02989 printf(
02990 " to get a guaranteed availability of %d days on disk pool use 'gstore stage'\n",
02991 iPoolTempAvail);
02992 }
02993 }
02994 else if (iWorkSizeSta)
02995 {
02996 if (iDebug)
02997 {
02998 printf(
02999 "\n %d files already available on central disk (%d MByte)\n",
03000 iWorkFilesSta, iWorkSizeSta);
03001 if (iWorkFilesStaTemp)
03002 printf(
03003 " %d files already in %s (%d MByte)\n",
03004 iWorkFilesStaTemp, cPoolNameTemp, iWorkSizeStaTemp);
03005 printf(
03006 " %d files still to be staged or currently being staged (%d MByte)\n",
03007 iWorkFilesAll-iWorkFilesSta,
03008 iWorkSizeAll - iWorkSizeSta);
03009 }
03010 }
03011 else if (iDebug)
03012 printf(", all to be staged\n");
03013
03014
03015
03016
03017
03018
03019
03020
03021
03022
03023
03024
03025 if ( (iWorkStatus < 9) && (iWorkStatus != 0) )
03026 {
03027 if ( (iAction == QUERY_WORKSPACE) ||
03028 (iWorkStatus == 2) )
03029 {
03030 strcpy(cMsgPref, "-W-");
03031 printf("%s staging requested workspace '%s' completely may fail\n",
03032 cMsgPref, pcGenFile);
03033 }
03034 else
03035 {
03036 strcpy(cMsgPref, "-E-");
03037 printf("%s requested workspace '%s' cannot be staged:\n",
03038 cMsgPref, pcGenFile);
03039 }
03040
03041 if (iWorkStatus < 0)
03042 printf("%s staging disk pool currently unavailable\n",
03043 cMsgPref);
03044 else if (iWorkStatus == 1)
03045 {
03046 printf(" currently free in %s: %d MByte\n",
03047 cPoolNameTemp, iPoolTempFree);
03048 printf(
03049 " still needed: %d MByte (%d files)\n",
03050 iWorkSizeAll-iWorkSizeSta,
03051 iWorkFilesAll-iWorkFilesSta);
03052 if (iAction == QUERY_WORKSPACE)
03053 printf( "-I- Check later again!\n");
03054 else printf(
03055 "-I- Query work space status before retrying later!\n");
03056 }
03057 else if ( (iWorkStatus == 2) || (iWorkStatus == 3) )
03058 {
03059 if (iWorkStatus == 2) printf(
03060 "%s max work space allowed in '%s' is currently limited to %d MByte\n",
03061 cMsgPref, cPoolNameTemp, iPoolTempMaxWS);
03062 else printf(
03063 "%s overall size of %s is limited to %d MByte\n",
03064 cMsgPref, cPoolNameTemp, iPoolTempMax);
03065
03066 if (iWorkStatus == 3) printf(
03067 "-I- Please reduce your work space requirements\n");
03068 }
03069 else if (iWorkStatus < 9)
03070 printf(
03071 "-E- unexpected workspace status received from server (%d)\n",
03072 iWorkStatus);
03073
03074 if (iDebug)
03075 printf("-D- end %s\n\n", cModule);
03076 return -1;
03077
03078 }
03079
03080 if ( (iDebug) && (iWorkSizeSta != iWorkSizeAll) )
03081 {
03082 if (iAction == QUERY_WORKSPACE)
03083 {
03084 iWorkSizeNew = iWorkSizeAll - iWorkSizeSta;
03085 if (iRandomExcess)
03086 {
03087 if (iWorkSizeNew > iHardwareFree)
03088 {
03089 printf("-D- currently unused in %s: %d MByte\n",
03090 cPoolNameTemp, iPoolTempFree);
03091 printf(" currently free in %s: %d MByte, remainder temporarily used by other pools\n",
03092 cPoolNameTemp, iHardwareFree);
03093 }
03094 else
03095 printf("-D- currently free in %s: %d MByte\n",
03096 cPoolNameTemp, iHardwareFree);
03097 }
03098 else
03099 printf("-D- currently free in %s: %d MByte\n",
03100 cPoolNameTemp, iPoolTempFree);
03101 printf(
03102 " to get all files on disk pool with a guaranteed availability of %d days:\n",
03103 iPoolTempAvail);
03104 printf(" -> use 'gstore stage'\n");
03105
03106 }
03107
03108
03109
03110
03111 }
03112
03113
03114 if (iWorkStatus >= 9)
03115 {
03116 if (iDebug)
03117 {
03118
03119
03120
03121 ii = ntohl(pPoolInfoData0->iFreeSize);
03122
03123 printf("-D- currently free (HW): %d MByte\n",
03124 iHardwareFree);
03125 printf(
03126 " currently %d MByte unused in %s are allocated by other pools\n",
03127 ii*(-1), cPoolNameTemp);
03128 }
03129
03130 if (iAction == QUERY_WORKSPACE)
03131 strcpy(cMisc, "must be initiated (gstore stage)");
03132 else
03133 strcpy(cMisc, "is initiated");
03134 printf(
03135 "-I- a clean job %s to provide the requested space\n",
03136 cMisc);
03137
03138 if (iWorkStatus > 9)
03139 {
03140
03141 iSleepClean = iWorkStatus;
03142
03143
03144
03145
03146 }
03147
03148 }
03149
03150 }
03151 }
03152
03153 if (iDebug)
03154 printf("-D- end %s\n\n", cModule);
03155
03156 return 0;
03157
03158 }
03159
03160
03161
03162
03163
03164
03165
03166
03167
03168 char *rawGetFullFile(char *pcFile, char *pcNamell)
03169 {
03170
03171 char cModule[32] = "rawGetFullFile";
03172 int iDebug = 0;
03173
03174 char cname1[MAX_FULL_FILE] = "";
03175 int ilen;
03176 int iRC;
03177
03178 char *pdelim=NULL, *pdelim2=NULL;
03179 char *pc, *pcll;
03180
03181 if (iDebug)
03182 fprintf(fLogFile, "\n-D- begin %s\n", cModule);
03183
03184 strcpy(cPath, pcFile);
03185 pdelim = strrchr(cPath, *pcFileDelim);
03186 if (pdelim != NULL)
03187 {
03188 strncpy(pdelim, "\0", 1);
03189 strcpy(cname1, ++pdelim);
03190 }
03191 else
03192 {
03193 #ifdef VMS
03194 pdelim2 = strrchr(cPath, *pcFileDelim2);
03195 if (pdelim2 != NULL)
03196 {
03197 strncpy(pdelim2, "\0", 1);
03198 strcpy(cname1, ++pdelim2);
03199 }
03200 else
03201 {
03202 #endif
03203 strncpy(cPath, "\0", 1);
03204 strcpy(cname1, pcFile);
03205 #ifdef VMS
03206 }
03207 #endif
03208 }
03209
03210 ilen = strlen(cname1);
03211 if (iDebug)
03212 {
03213 #ifdef VMS
03214 if (pdelim != NULL)
03215 fprintf(fLogFile, "-D- %s: path %s], name1: %s (len %d)\n",
03216 cModule, cPath, cname1, ilen);
03217
03218 else
03219 {
03220 if (pdelim2 != NULL)
03221 fprintf(fLogFile, "-D- %s: device %s, name1: %s (len %d)\n",
03222 cModule, cPath, cname1, ilen);
03223 else
03224 fprintf(fLogFile, "-D- %s: no prefix, name1: %s (len %d)\n",
03225 cModule, cname1, ilen);
03226 }
03227 #else
03228 fprintf(fLogFile,
03229 " path: %s, name1: %s (len %d)\n", cPath, cname1, ilen);
03230 #endif
03231 }
03232
03233 pc = &cname1[0];
03234 pcll = pcNamell;
03235 iRC = strncmp(pcll, pcObjDelim, 1);
03236 if (iRC == 0) pcll++;
03237 else
03238 {
03239 iRC = strncmp(pcll, pcObjDelimAlt, 1);
03240 if (iRC == 0) pcll++;
03241 }
03242
03243 if (strlen(cPath) > 0)
03244 {
03245 #ifdef VMS
03246 if (pdelim2 != NULL)
03247 strcat(cPath, pcFileDelim2);
03248 else
03249 #endif
03250 strcat(cPath, pcFileDelim);
03251 }
03252 strcat(cPath, pcll);
03253 if (iDebug) fprintf(fLogFile,
03254 "-D- end %s: full file name found: %s\n\n", cModule, cPath);
03255
03256 return( (char *) cPath);
03257
03258 }
03259
03260
03261
03262
03263
03264
03265
03266 void rawQueryPrint(
03267 srawObjAttr *pQAttr,
03268 int ipMode)
03269
03270
03271
03272
03273 {
03274 char cModule[32]="rawQueryPrint";
03275 char ctype[8] = "";
03276 char cMClass[12] = "";
03277 char cPath[MAX_OBJ_HL];
03278 char cStatus[16] = "";
03279
03280 int ii;
03281 int iStage = 0;
03282 int iCache = 0;
03283 int iATLServer = 0;
03284 int iFileType = -1;
03285 int iMediaClass = 0;
03286
03287 unsigned long *plFileSizeC;
03288 unsigned long lFileSize;
03289 int iVersionObjAttr = 0;
03290
03291
03292
03293
03294
03295 iVersionObjAttr = ntohl(pQAttr->iVersion);
03296 if ( (ipMode == 1) || (ipMode == 11) ) fprintf(fLogFile,
03297 "\n-D- begin %s: objAttr V%d\n", cModule, iVersionObjAttr);
03298
03299 if ( (iVersionObjAttr != VERSION_SRAWOBJATTR) &&
03300 (iVersionObjAttr != VERSION_SRAWOBJATTR-1) )
03301 {
03302 fprintf(fLogFile,
03303 "-E- %s: invalid cacheDB entry version %d\n",
03304 cModule, iVersionObjAttr);
03305
03306 return;
03307 }
03308
03309 iFileType = ntohl(pQAttr->iFileType);
03310 iMediaClass = ntohl(pQAttr->iMediaClass);
03311 iATLServer = ntohl(pQAttr->iATLServer);
03312
03313 switch(iFileType)
03314 {
03315 case FIXED_INTS4:
03316 strcpy(ctype, "FB");
03317 break;
03318 case STREAM:
03319 strcpy(ctype, "U ");
03320 break;
03321 default:
03322 fprintf(fLogFile, "-E- Invalid record format %d found\n",
03323 iFileType);
03324 break;
03325 }
03326
03327 switch(iMediaClass)
03328 {
03329 case MEDIA_FIXED:
03330 strcpy(cMClass, "DISK ");
03331 break;
03332 case MEDIA_LIBRARY:
03333 strcpy(cMClass, "TAPE ");
03334 break;
03335 case MEDIA_NETWORK:
03336 strcpy(cMClass, "NETWORK");
03337 break;
03338 case MEDIA_SHELF:
03339 strcpy(cMClass, "SHELF");
03340 break;
03341 case MEDIA_OFFSITE:
03342 strcpy(cMClass, "OFFSITE");
03343 break;
03344 case MEDIA_UNAVAILABLE:
03345 strcpy(cMClass, "UNAVAILABLE");
03346 break;
03347 case GSI_MEDIA_STAGE:
03348 case GSI_MEDIA_LOCKED:
03349 strcpy(cMClass, "STAGE");
03350 strcpy(cStatus, "staged");
03351 iStage = 1;
03352 break;
03353 case GSI_MEDIA_INCOMPLETE:
03354 strcpy(cMClass, "STAGE*");
03355 strcpy(cStatus, "still staging");
03356 iStage = 1;
03357 break;
03358 case GSI_STAGE_INVALID:
03359 strcpy(cMClass, "STAGE*");
03360 strcpy(cStatus, "staging failed");
03361 iStage = 1;
03362 break;
03363 case GSI_MEDIA_CACHE:
03364 case GSI_CACHE_LOCKED:
03365 strcpy(cMClass, "CACHE");
03366 strcpy(cStatus, "cached");
03367 iCache = 1;
03368 break;
03369 case GSI_CACHE_INCOMPLETE:
03370 case GSI_CACHE_COPY:
03371 strcpy(cMClass, "CACHE*");
03372 strcpy(cStatus, "still caching");
03373 iCache = 1;
03374 break;
03375 default:
03376 fprintf(fLogFile, "-E- Invalid media class %d found\n",
03377 iMediaClass);
03378 break;
03379 }
03380
03381 if (iATLServer)
03382 {
03383 if (iATLServer < 0)
03384 iATLServer = -iATLServer;
03385
03386 ii = MAX_ATLSERVER;
03387 if (ii > 1)
03388 sprintf(cMClass, "%s%d", cMClass, iATLServer);
03389 else
03390 sprintf(cMClass, "%s", cMClass);
03391 }
03392
03393 if ( (ipMode == 10) || (ipMode == 11) )
03394 strcat(cMClass, "??");
03395
03396 if (strlen(pQAttr->cDateCreate) == 16)
03397 strcat(pQAttr->cDateCreate, " ");
03398 strcpy(cPath, (char *) rawGetPathName(pQAttr->cNamehl));
03399 fprintf(fLogFile, "%s%s%s %s %s %s",
03400 pQAttr->cNamefs, cPath, pQAttr->cNamell,
03401 pQAttr->cOwner, pQAttr->cDateCreate, cMClass);
03402
03403 pQAttr->iFileSize = ntohl(pQAttr->iFileSize);
03404 pQAttr->iFileSize2 = ntohl(pQAttr->iFileSize2);
03405 plFileSizeC = (unsigned long *) &(pQAttr->iFileSize);
03406 lFileSize = *plFileSizeC;
03407
03408 if (lFileSize)
03409 {
03410 if ( (pQAttr->iFileSize2 == 0) ||
03411 (sizeof(long) == 8) )
03412 fprintf(fLogFile, " %12lu", lFileSize);
03413 else
03414 fprintf(fLogFile, " %s ", cTooBig);
03415 }
03416
03417
03418 pQAttr->iFileSize = htonl(pQAttr->iFileSize);
03419 pQAttr->iFileSize2 = htonl(pQAttr->iFileSize2);
03420
03421 if (iStage)
03422 fprintf(fLogFile, " %s %s", pQAttr->cNode, pQAttr->cStageUser);
03423 if (iCache)
03424 fprintf(fLogFile, " %s", pQAttr->cNode);
03425 fprintf(fLogFile, "\n");
03426
03427 if ( (ipMode == 1) || (ipMode == 11) )
03428 {
03429 if (ntohl(pQAttr->iFS))
03430 fprintf(fLogFile, " %s on data mover %s, FS %d (poolId %d)\n",
03431 cStatus, pQAttr->cNode, ntohl(pQAttr->iFS),
03432 ntohl(pQAttr->iPoolId));
03433 fprintf(fLogFile,
03434 " obj-Id: %u-%u, restore order: %u-%u-%u-%u-%u\n",
03435 ntohl(pQAttr->iObjHigh),
03436 ntohl(pQAttr->iObjLow),
03437 ntohl(pQAttr->iRestoHigh),
03438 ntohl(pQAttr->iRestoHighHigh),
03439 ntohl(pQAttr->iRestoHighLow),
03440 ntohl(pQAttr->iRestoLowHigh),
03441 ntohl(pQAttr->iRestoLow) );
03442 fprintf(fLogFile,
03443 " owner: %s, OS: %.8s, mgmt-class: %s, file set %d\n",
03444 pQAttr->cOwner,
03445 pQAttr->cOS, pQAttr->cMgmtClass, ntohl(pQAttr->iFileSet));
03446 }
03447
03448 if ( (ipMode == 1) || (ipMode == 11) )
03449 fprintf(fLogFile, "-D- end %s\n\n", cModule);
03450
03451 }
03452
03453
03454
03455
03456
03457
03458 int rawQueryString(
03459 srawObjAttr *pQAttr,
03460 int ipMode,
03461
03462
03463
03464 int iOut,
03465 char *pcOut)
03466 {
03467 char cModule[32] = "rawQueryString";
03468 int iDebug = 0;
03469
03470 int iMsg = 0;
03471 char ctype[8] = "";
03472 char cMClass[12] = "";
03473 char cPath[MAX_OBJ_HL];
03474 char cMsg[4096] = "";
03475 char cMsg1[1024] = "";
03476
03477 int ii;
03478 int iStage = 0;
03479 int iCache = 0;
03480 int iATLServer;
03481 int iFileType = -1;
03482 int iMediaClass = 0;
03483
03484 unsigned long *plFileSizeC;
03485 unsigned long lFileSize;
03486 int iVersionObjAttr = 0;
03487
03488
03489
03490
03491
03492 iVersionObjAttr = ntohl(pQAttr->iVersion);
03493 if (iDebug) fprintf(fLogFile,
03494 "\n-D- begin %s: version ObjAttr %d\n", cModule, iVersionObjAttr);
03495
03496 if ( (iVersionObjAttr != VERSION_SRAWOBJATTR) &&
03497 (iVersionObjAttr != VERSION_SRAWOBJATTR-1) )
03498 {
03499 fprintf(fLogFile,
03500 "-E- %s: invalid cacheDB entry version %d\n",
03501 cModule, iVersionObjAttr);
03502
03503 return 0;
03504 }
03505
03506 iFileType = ntohl(pQAttr->iFileType);
03507 iMediaClass = ntohl(pQAttr->iMediaClass);
03508 iATLServer = ntohl(pQAttr->iATLServer);
03509
03510 switch(iFileType)
03511 {
03512 case FIXED_INTS4:
03513 strcpy(ctype, "FB");
03514 break;
03515 case STREAM:
03516 strcpy(ctype, "U ");
03517 break;
03518 default:
03519 fprintf(fLogFile, "-E- Invalid record format %d found\n",
03520 iFileType);
03521 break;
03522 }
03523
03524 switch(iMediaClass)
03525 {
03526 case MEDIA_FIXED:
03527 strcpy(cMClass, "DISK ");
03528 break;
03529 case MEDIA_LIBRARY:
03530 strcpy(cMClass, "TAPE ");
03531 break;
03532 case MEDIA_NETWORK:
03533 strcpy(cMClass, "NETWORK");
03534 break;
03535 case MEDIA_SHELF:
03536 strcpy(cMClass, "SHELF");
03537 break;
03538 case MEDIA_OFFSITE:
03539 strcpy(cMClass, "OFFSITE");
03540 break;
03541 case MEDIA_UNAVAILABLE:
03542 strcpy(cMClass, "UNAVAILABLE");
03543 break;
03544 case GSI_MEDIA_STAGE:
03545 case GSI_MEDIA_LOCKED:
03546 strcpy(cMClass, "STAGE");
03547 iStage = 1;
03548 break;
03549 case GSI_MEDIA_INCOMPLETE:
03550 case GSI_STAGE_INVALID:
03551 strcpy(cMClass, "STAGE*");
03552 break;
03553 case GSI_MEDIA_CACHE:
03554 case GSI_CACHE_LOCKED:
03555 strcpy(cMClass, "CACHE");
03556 iCache = 1;
03557 break;
03558 case GSI_CACHE_INCOMPLETE:
03559 case GSI_CACHE_COPY:
03560 strcpy(cMClass, "CACHE*");
03561 iCache = 1;
03562 break;
03563 default:
03564 fprintf(fLogFile, "-E- Invalid media class %d found\n",
03565 iMediaClass);
03566 break;
03567 }
03568
03569 if (iATLServer)
03570 {
03571 if (iATLServer < 0)
03572 iATLServer = -iATLServer;
03573
03574 ii = MAX_ATLSERVER;
03575 if (ii > 1)
03576 sprintf(cMClass, "%s%d", cMClass, iATLServer);
03577 else
03578 sprintf(cMClass, "%s", cMClass);
03579 }
03580 if ( (ipMode == 10) || (ipMode == 11) )
03581 strcat(cMClass, "??");
03582
03583 if (strlen(pQAttr->cDateCreate) == 16)
03584 strcat(pQAttr->cDateCreate, " ");
03585 strcpy(cPath, (char *) rawGetPathName(pQAttr->cNamehl));
03586
03587 sprintf(cMsg, "%s%s%s %s %s %s",
03588 pQAttr->cNamefs, cPath, pQAttr->cNamell,
03589 pQAttr->cOwner, pQAttr->cDateCreate, cMClass);
03590
03591 pQAttr->iFileSize = ntohl(pQAttr->iFileSize);
03592 pQAttr->iFileSize2 = ntohl(pQAttr->iFileSize2);
03593 plFileSizeC = (unsigned long *) &(pQAttr->iFileSize);
03594 lFileSize = *plFileSizeC;
03595
03596
03597 pQAttr->iFileSize = htonl(pQAttr->iFileSize);
03598 pQAttr->iFileSize2 = htonl(pQAttr->iFileSize2);
03599
03600 if (lFileSize)
03601 {
03602 if ( (pQAttr->iFileSize2 == 0) ||
03603 (sizeof(long) == 8) )
03604 sprintf(cMsg1, " %12lu", lFileSize);
03605 else
03606 sprintf(cMsg1, " %s ", cTooBig);
03607 strcat(cMsg, cMsg1);
03608 }
03609 if (iStage)
03610 {
03611 sprintf(cMsg1, " %s %s", pQAttr->cNode, pQAttr->cStageUser);
03612 strcat(cMsg, cMsg1);
03613 }
03614 if (iCache)
03615 {
03616 sprintf(cMsg1, " %s", pQAttr->cNode);
03617 strcat(cMsg, cMsg1);
03618 }
03619 strcat(cMsg, "\n");
03620
03621 if ( (ipMode == 1) || (ipMode == 11) )
03622 {
03623 if (ntohl(pQAttr->iFS))
03624 {
03625 sprintf(cMsg1,
03626 " staged on data mover %s, FS %d (poolId %d)\n",
03627 pQAttr->cNode, ntohl(pQAttr->iFS),
03628 ntohl(pQAttr->iPoolId));
03629 strcat(cMsg, cMsg1);
03630 }
03631
03632 sprintf(cMsg1,
03633 " obj-Id: %u-%u, restore order: %u-%u-%u-%u-%u\n",
03634 ntohl(pQAttr->iObjHigh),
03635 ntohl(pQAttr->iObjLow),
03636 ntohl(pQAttr->iRestoHigh),
03637 ntohl(pQAttr->iRestoHighHigh),
03638 ntohl(pQAttr->iRestoHighLow),
03639 ntohl(pQAttr->iRestoLowHigh),
03640 ntohl(pQAttr->iRestoLow) );
03641 strcat(cMsg, cMsg1);
03642
03643 sprintf(cMsg1,
03644 " version %d, owner: %s, OS: %s, mgmt-class: %s, file set %d\n",
03645 ntohl(pQAttr->iVersion), pQAttr->cOwner,
03646 pQAttr->cOS, pQAttr->cMgmtClass, ntohl(pQAttr->iFileSet));
03647 strcat(cMsg, cMsg1);
03648 }
03649
03650 iMsg = strlen(cMsg);
03651
03652 if (iOut < iMsg)
03653 {
03654 fprintf(fLogFile,
03655 "-W- %s: output string provided too short (%d byte), %d byte needed\n",
03656 cModule, iOut, iMsg);
03657 strncpy(pcOut, cMsg, (unsigned) iOut-1);
03658 strcat(pcOut, "\0");
03659
03660 fprintf(fLogFile,
03661 "-W- %s: query information incomplete:\n%s\n", cModule, pcOut);
03662
03663 iMsg = iOut;
03664 }
03665 else
03666 {
03667 if (iDebug) fprintf(fLogFile,
03668 " %s: length query info %d byte, length of string provided %d byte, msg:\n",
03669 cModule, iMsg, iOut);
03670 strcpy(pcOut, cMsg);
03671 }
03672
03673 if (iDebug)
03674 fprintf(fLogFile, "-D- end %s\n\n", cModule);
03675
03676 return iMsg;
03677
03678 }
03679
03680
03681
03682
03683
03684
03685
03686
03687 int rawScanObjbuf(char *pcPath, char *pcFile,
03688 int iObjnoAll, int *piObjBuf0)
03689 {
03690 char cModule[32] = "rawScanObjbuf";
03691 int iDebug = 0;
03692
03693 int ii;
03694 int iFound = 0;
03695 int iObjnoBuf;
03696 int iObjnoCur = 0;
03697 int iBufno = 0;
03698 int *piObjBuf;
03699 int **ppiNextBuf;
03700
03701 srawRetrList *psRetrList;
03702
03703 if (iDebug)
03704 printf("\n-D- begin %s: check %d objs for %s%s\n",
03705 cModule, iObjnoAll, pcPath, pcFile);
03706
03707 piObjBuf = piObjBuf0;
03708
03709
03710 for (;;)
03711 {
03712 iObjnoBuf = *piObjBuf;
03713 psRetrList = (srawRetrList *) &(piObjBuf[1]);
03714 iBufno++;
03715 if (iDebug == 2)
03716 {
03717 printf("DDD buffer %d: piObjBuf %p, value %d, psRetrList %p\n",
03718 iBufno, piObjBuf, *piObjBuf, psRetrList);
03719 fflush(stdout);
03720 }
03721
03722
03723 for (ii=1; ii<=iObjnoBuf; ii++)
03724 {
03725 iObjnoCur++;
03726 if (iDebug == 2)
03727 {
03728 printf(" %d: %s%s, addr %p\n",
03729 iObjnoCur, psRetrList->cNamehl, psRetrList->cNamell,
03730 psRetrList);
03731 fflush(stdout);
03732 }
03733
03734 if ( (strcmp(pcFile, psRetrList->cNamell) == 0) &&
03735 (strcmp(pcPath, psRetrList->cNamehl) == 0) )
03736 {
03737 if (iDebug) printf(
03738 " file %s%s already available in list\n",
03739 pcPath, pcFile);
03740 iFound = 1;
03741 goto gEndScan;
03742 }
03743
03744 psRetrList++;
03745
03746 }
03747
03748 if (iObjnoCur == iObjnoAll)
03749 {
03750 if (iDebug) printf(
03751 " all %d files scanned\n", iObjnoAll);
03752 break;
03753 }
03754
03755 if (psRetrList)
03756 {
03757 ppiNextBuf = (int **) psRetrList;
03758 piObjBuf = *ppiNextBuf;
03759 psRetrList = (srawRetrList *) &(piObjBuf[1]);
03760 if (iDebug == 2)
03761 {
03762 printf("DDD next piObjBuf %p, value %d, psRetrList %p\n",
03763 piObjBuf, *piObjBuf, psRetrList);
03764 fflush(stdout);
03765 }
03766 }
03767 else
03768 break;
03769
03770 }
03771
03772 gEndScan:
03773 if (iDebug)
03774 printf("-D- end %s: %d buffers scanned\n\n", cModule, iBufno);
03775
03776 if (iFound)
03777 return 1;
03778 else
03779 return 0;
03780
03781 }
03782
03783
03784
03785
03786
03787
03788
03789
03790 int rawSortValues(
03791 int *iaValue,
03792 int iAll,
03793 int iFirst,
03794 int iLast,
03795 int *iaIndex,
03796 int *iaIndNew)
03797 {
03798 char cModule[32] = "rawSortValues";
03799 int iDebug = 0;
03800
03801 int ii, ii1, iif, jj;
03802 int iLoop;
03803 int iInd;
03804 int iFound = 0;
03805 int iaValNew[MAX_FILE_NO];
03806
03807 iLoop = iLast - iFirst + 1;
03808
03809 if (iDebug)
03810 printf("\n-D- begin %s\n", cModule);
03811
03812 if (iDebug)
03813 {
03814 printf(" numbers on input:\n value index\n");
03815 for (ii=iFirst; ii<=iLast; ii++)
03816 {
03817 printf(" %6d: %10d %6d\n", ii, iaValue[ii], iaIndex[ii]);
03818 }
03819 }
03820
03821 iFound = iFirst - 1;
03822 for (jj=iFirst; jj<=iLast; jj++)
03823 {
03824 if (iFound >= iFirst)
03825 {
03826 for (iif=iFirst; iif<=iFound; iif++)
03827 {
03828 if ( (iaValue[jj] < iaValNew[iif]) && (iaValNew[iif]) )
03829 {
03830 for (ii1=iFound; ii1>=iif; ii1--)
03831 {
03832 iaValNew[ii1+1] = iaValNew[ii1];
03833 iaIndNew[ii1+1] = iaIndNew[ii1];
03834 }
03835
03836 iaValNew[iif] = iaValue[jj];
03837 iaIndNew[iif] = iaIndex[jj];
03838 iFound++;
03839 if (iDebug == 2) fprintf(fLogFile,
03840 " at pos %d inserted: val %d, ind %d\n",
03841 iif, iaValNew[iif], iaIndNew[iif]);
03842
03843 break;
03844 }
03845 else
03846 {
03847 if (iif == iFound)
03848 {
03849 iFound++;
03850 iaValNew[iFound] = iaValue[jj];
03851 iaIndNew[iFound] = iaIndex[jj];
03852 if (iDebug == 2) fprintf(fLogFile,
03853 " at pos %d appended: val %d, ind %d\n",
03854 iFound, iaValNew[iFound], iaIndNew[iFound]);
03855
03856 break;
03857 }
03858
03859 continue;
03860 }
03861 }
03862 }
03863 else
03864 {
03865 iaValNew[iFirst] = iaValue[jj];
03866 iaIndNew[iFirst] = iaIndex[jj];
03867 iFound = iFirst;
03868
03869 if (iDebug == 2) fprintf(fLogFile,
03870 " start value: val %d, ind %d\n",
03871 iaValNew[iFound], iaIndNew[iFound]);
03872 }
03873 }
03874
03875 memcpy(&iaValue[iFirst], &iaValNew[iFirst], (unsigned) iLoop*iint);
03876
03877 if (iDebug)
03878 {
03879 printf(" numbers on output:\n value index\n");
03880 for (ii=iFirst; ii<=iLast; ii++)
03881 {
03882 printf(" %6d: %10d %6d\n", ii, iaValue[ii], iaIndNew[ii]);
03883 }
03884 }
03885
03886 if (iDebug)
03887 printf("-D- end %s\n\n", cModule);
03888
03889 return 0;
03890
03891 }
03892
03893 #ifdef _AIX
03894
03895
03896
03897
03898
03899
03900
03901
03902
03903
03904
03905
03906
03907
03908
03909
03910
03911
03912 unsigned long ielpst( unsigned long iScale,
03913 unsigned long *iBuf )
03914 {
03915 char cModule[32] = "ielpst";
03916 int iDebug = 0;
03917
03918 struct timestruc_t stv;
03919 unsigned long iTemp[2];
03920
03921 gettimer( TIMEOFDAY, &stv );
03922
03923 if ( iScale <= 0 ) iScale = 1;
03924 iTemp[1] = stv.tv_sec - iBuf[1];
03925 if ( ( iTemp[0] = stv.tv_nsec - iBuf[0] ) & 0x80000000 ) {
03926 iTemp[0] += 1000000000L; iTemp[1] -= 1;
03927 }
03928 iBuf[1] = stv.tv_sec; iBuf[0] = stv.tv_nsec;
03929 return( iTemp[1] * ( 1000000L / iScale ) + ( iTemp[0] / 1000 ) / iScale );
03930
03931 }
03932
03933
03934 unsigned long ielpst_( unsigned long *iScale,
03935 unsigned long *iBuf )
03936 {
03937 return( ielpst( *iScale, iBuf ) );
03938 }
03939 #endif