154 #include <netinet/in.h>
155 #include <sys/stat.h>
160 #define MAX_LOG_FILE 64
166 #include "error_mac.h"
169 #include "f_ut_printm.h"
171 #define fprintf fprintm
199 #define MAX_BUFSIZE 32768
224 {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
226 #ifdef __USE_LARGEFILE64
235 int rfio_open64(
const char *pcFile,
239 char cModule[32] =
"rfio_open64";
245 "\n-D- begin %s: file %s, flags %d, mode %d\n",
246 cModule, pcFile, iFlags, iMode);
252 "-E- 32 bit client: %s not supported\n", cModule);
257 iFileId =
rfio_open(pcFile, iFlags, iMode);
260 "-D- end %s: iFileId(rfio_open) = %d\n\n", cModule, iFileId);
279 char cModule[32] =
"rfio_open";
283 char *pcCopyPath = NULL;
284 int iCopyFraction = 0;
286 int iPathConvention = 0;
289 printf(
"\n-D- begin %s: calling rfio_open_gsidaq\n", cModule);
299 "-D- end %s, iFileId(rfio_open_gsidaq) = %d\n\n",
359 char cModule[32] =
"rfio_open_gsidaq";
373 unsigned long *plFileSizeC;
386 int iDataMoverSelect = 0;
400 char cServer[24] =
"";
401 int iSockMaster = -1;
422 char cAccess[16] =
"";
450 pDataMoverSelect = &(sDataMoverSelect.sDataMoverAttr);
455 if (iFlags == O_RDONLY)
458 strcpy(cAccess,
"read");
463 strcpy(cAccess,
"write");
469 else if (ii != 4) printf(
470 "-W- unexpected size of long integer: %d byte\n", ii);
475 printf(
"\n-D- begin %s (%d bit OS)", cModule, ii);
477 printf(
", %d remote files currently open",
iFileCount);
487 pCommAPI = &(
pAPIFile[ii]->sCommAPI);
488 strcpy(cObject, pCommAPI->
cNamefs);
489 strcat(cObject, pCommAPI->
cNamehl);
490 strcat(cObject, pCommAPI->
cNamell);
493 printf(
" %d: %s already open\n", ii, cObject);
495 pcc = strstr(pcFile, cObject);
500 printf(
" %d: %s maps\n", ii, cObject);
505 printf(
" %d: no (more) open file found\n", ii);
513 "-E- %s: requested file %s is already open\n",
523 "-E- %s: max %d remote files may be open simultaneously\n",
534 "-E- %s: allocating file control block no. %d (%d byte)\n",
545 " file control block no. %d allocated (%d byte)\n",
556 printf(
" query only, iOpenMode %d reset to 0\n", iOpenMode);
561 pcurAPIFile->
iFileId = iFileId;
562 pcurAPIFile->
iFlags = iFlags;
563 pcurAPIFile->
iMode = iOpenMode;
567 pcurAPIFile->
iOffset = iOffset;
571 pcurAPIFile->
iAction = iAction;
573 pCommAPI = &(pcurAPIFile->
sCommAPI);
587 if ( (strchr(pcFile, *
pcStar) != NULL) ||
588 (strchr(pcFile, *
pcQM) != NULL) ||
589 (strchr(pcFile, *
pcPerc) != NULL) )
592 "-E- %s: files with wildcard characters ('%s') not allowed using RFIO\n",
604 "-E- %s(1): invalid remote file name '%s': node name missing\n",
612 strcpy(cTemp, pcFile);
615 strncpy(pcc,
"\0", 1);
618 while (*pcc1 !=
'\0')
620 *pcc1 = tolower(*pcc1);
626 printf(
" URL in small letters: '%s'\n", cTemp);
629 pcc = strstr(cTemp,
".gsi.de");
632 strncpy(pcc++,
":", 1);
633 strncpy(pcc,
"\0", 1);
635 printf(
" remove trailing '.gsi.de': %s\n", cTemp);
639 if (strncmp(cTemp,
"rfio", 4) == 0)
647 "-E- %s(2): invalid prefix '%s' of remote file name: node name missing\n",
653 strncpy(pcc1,
"\0", 1);
656 if (strlen(pcc) == 0)
659 "-E- %s(3): invalid remote file name '%s': node name missing\n",
668 printf(
" node name after prefix 'rfio': '%s'\n",
cNodePrefix);
670 if (strncmp(cTemp,
"rfiodaq:", 8) == 0)
674 fprintf(
fLogClient,
"-E- %s: reading from DaqPool not allowed\n",
676 fprintf(
fLogClient,
" correct object specification:\n");
677 fprintf(
fLogClient,
" [rfio:]node:/archive/path/file\n");
684 strcpy(cServer,
"gStore entry server");
687 else if (strncmp(cTemp,
"rfio:", 5) == 0)
690 strcpy(cServer,
"gStore entry server");
696 else if (iAction == 2)
699 else if (strncmp(cTemp,
"rfiocopy:", 9) == 0)
702 strcpy(cServer,
"RFIO server");
710 "-E- %s: invalid remote file name '%s': unknown prefix\n",
725 "-E- %s: invalid remote file name '%s': invalid prefix\n",
732 if (strlen(pcc) == 0)
735 "-E- %s(4): invalid remote file name '%s': node name missing\n",
743 strcpy(cServer,
"gStore entry server");
749 else if (iAction == 2)
752 strncpy(pcc,
"\0", 1);
761 fprintf(
fLogClient,
"-E- %s: gStore server %s no longer supported\n",
771 if ( (iAction == 2) ||
773 printf(
" %s, request poolId %d\n", cServer, iPoolId);
775 printf(
" %s\n", cServer);
783 if ( (strlen(pcc) == 0) || (strcmp(pcc,
" ") == 0) )
788 "-E- %s: missing remote object for read access\n", cModule);
800 printf(
" remote object will be initialized later\n");
802 printf(
" remote file will be initialized later\n");
807 strcpy(pcNamefs,
"");
808 strcpy(pcNamehl,
"");
809 strcpy(pcNamell,
"");
818 pcc = (
char *) strchr(cTemp, *pcObjDelim);
822 "-E- %s: invalid remote file name %s\n", cModule, cTemp);
829 pcc1 = (
char *) strchr(pcc, *pcObjDelim);
834 printf(
" remote object %s\n", cTemp);
836 if ( (pcc == NULL) || (pcc1 == NULL) )
839 "-E- %s: invalid remote object name '%s': archive name missing\n",
847 strncpy(pcc1,
"\0", 1);
851 fprintf(
fLogClient,
"-E- %s: archive name '%s' too long (max %d)\n",
858 if (strlen(cTemp) < 2)
860 fprintf(
fLogClient,
"-E- %s: invalid archive name '%s'\n",
867 strcpy(pcNamefs, cTemp);
869 printf(
" archive name %s\n", pcNamefs);
871 strncpy(pcc, pcObjDelim, 1);
873 pcc1 = (
char *) strrchr(pcc, *pcObjDelim);
877 "-E- %s: invalid remote object name '%s': path name missing\n",
887 fprintf(
fLogClient,
"-E- %s: file name '%s' too long (max %d)\n",
894 if (strlen(pcc1) < 2)
896 fprintf(
fLogClient,
"-E- %s: invalid file name '%s'\n", cModule, pcc1);
902 strcpy(pcNamell, pcc1);
904 printf(
" file name %s\n", pcNamell);
907 strncpy(pcc1,
"\0", 1);
911 fprintf(
fLogClient,
"-E- %s: path name '%s' too long (max %d)\n",
920 fprintf(
fLogClient,
"-E- %s: invalid path name '%s'\n", cModule, pcc);
926 strcpy(pcNamehl, pcc);
928 printf(
" path name %s\n", pcNamehl);
934 fprintf(
fLogClient,
"-E- %s: invalid gStore file name: %s\n",
942 if (strcmp(pcNamehl, pCommAPI->
cNamehl))
944 strcpy(pcNamehl, pCommAPI->
cNamehl);
945 printf(
" gStore path name corrected to %s\n", pcNamehl);
947 strcpy((
char *) pcFile,
cPrefix);
948 strcat((
char *) pcFile, pCommAPI->
cNamefs);
949 strcat((
char *) pcFile, pCommAPI->
cNamehl);
950 strcat((
char *) pcFile, pCommAPI->
cNamell);
952 " new full file name: %s\n", pcFile);
958 printf(
" remote file %s\n", cTemp);
960 strcpy(pcNamefs,
"");
963 pcc1 = (
char *) strrchr(cTemp, *pcObjDelim);
966 fprintf(
fLogClient,
"-E- %s: invalid remote file name '%s'\n",
976 fprintf(
fLogClient,
"-E- %s: file name '%s' too long (max %d)\n",
983 if (strlen(pcc1) < 2)
985 fprintf(
fLogClient,
"-E- %s: invalid file name '%s'\n", cModule, pcc1);
991 strcpy(pcNamell, pcc1);
993 printf(
" file name %s\n", pcNamell);
995 strncpy(pcc1,
"\0", 1);
999 fprintf(
fLogClient,
"-E- %s: path name '%s' too long (max %d)\n",
1000 cModule, cTemp, ii);
1006 if (strlen(cTemp) < 2)
1008 fprintf(
fLogClient,
"-E- %s: invalid path name '%s'\n",
1015 strcpy(pcNamehl, cTemp);
1017 printf(
" path name %s\n", pcNamehl);
1019 strcpy(pCommAPI->
cNamefs,
"\0");
1020 strcpy(pCommAPI->
cNamehl, pcNamehl);
1021 strcpy(pCommAPI->
cNamell, pcNamell);
1033 "-E- copy from write cache only for write actions\n");
1042 "-E- copy from write cache to lustre only when writing to DAQPool\n");
1051 "-E- copy from write cache only supported with rfio_[f]newfile\n");
1057 if ( (iCopyMode < 0) || (iCopyMode > 2) )
1059 fprintf(
fLogClient,
"-E- invalid copy mode: %d\n", iCopyMode);
1065 if ( (strlen(pcCopyPath) == 0) || (pcCopyPath == NULL) )
1067 fprintf(
fLogClient,
"-E- copy path missing\n");
1073 if (iCopyFraction < 0)
1076 "-E- invalid fraction of files to copied: %d (must be > 0)\n",
1083 if (iCopyFraction == 0)
1086 "-W- fraction of files to copied: 0 specified, assume 1 (copy all)\n");
1091 strcpy(cTemp, pcCopyPath);
1095 while (*pcc !=
'\0')
1097 *pcc = tolower(*pcc);
1100 if (strcmp(cTemp,
"rc") == 0)
1103 "-E- copy to read cache not yet implemented\n");
1109 strcpy(cTemp, pcCopyPath);
1117 pcc1 = strrchr(cTemp,
'/');
1118 ii = pcc1 - pcc + 1;
1119 if (ii == strlen(pcc))
1122 strncpy(pcc1,
"\0", 1);
1130 strcpy(pcCopyPath, cTemp);
1132 " %d trailing '/' ignored, use copy destination '%s'\n",
1141 "-E- invalid copy destination %s\n", pcCopyPath);
1150 "-E- invalid max file no. for copy destination: %d\n",
1157 if ( (iPathConvention < 0) || (iPathConvention > 1) )
1160 "-E- invalid convention no. for creation of new copy destination path: %d\n",
1170 "-I- copy each file to %s", pcCopyPath);
1172 "-I- copy each %d. file to %s", iCopyFraction, pcCopyPath);
1173 if (iPathConvention == 1)
1175 fprintf(
fLogClient,
" before tape migration\n");
1176 fprintf(
fLogClient,
" check success as asynchroneous copy process\n");
1181 "-I- write data buffers of each file to gStore write cache and to %s",
1184 "-I- for each %d. file write data buffers additionally to %s",
1185 iCopyFraction, pcCopyPath);
1186 if (iPathConvention == 1)
1191 if ( (iMaxFile) && (strcmp(
"rc", pcCopyPath)) ) fprintf(
fLogClient,
1192 " if %d files are written, create new directory (convention no. %d)\n",
1193 iMaxFile, iPathConvention);
1197 pCopyCacheServ->
iCopyMode = htonl(iCopyMode);
1198 pCopyCacheServ->
iCopyLen = htonl(0);
1200 strcpy(pCopyCacheServ->
cCopyPath, pcCopyPath);
1202 pCopyCacheServ->
iMaxFile = htonl(iMaxFile);
1206 " parameters for write cache copy stored\n");
1219 if (strcmp(pcc,
"_d") == 0)
1221 strncpy(pcc,
"\0", 1);
1223 printf(
" switch to test system\n");
1239 " gStore entry server %s (node in URL %s)\n",
1272 if (iObjInit) printf(
1273 " %s node %s:%d, file %s%s",
1280 if (iObjInit) printf(
1281 " %s %s:%d, TSM object %s%s%s",
1283 pcNamefs, pcNamehl, pcNamell);
1290 printf(
", request StagePool\n");
1291 else if (iPoolId == 3)
1292 printf(
", request ArchivePool\n");
1293 else if (iPoolId == 4)
1294 printf(
", request DaqPool\n");
1299 if (iObjInit) printf(
1300 " FS name '%s', HL name '%s', LL name '%s', action %d\n",
1304 " action %d, object follows later\n", pCommAPI->
iAction);
1311 iRC = gethostname(cliNode,
MAX_NODE);
1314 fprintf(
fLogClient,
"-E- %s: getting client host name: %s\n",
1315 cModule, strerror(iRC));
1322 " user %s on node %s, platform %s\n",
1323 cOwner, cliNode, cOS);
1334 sprintf(cstr,
".t%d", (
int) tstr);
1337 sprintf(cstr,
".p%d", pstr);
1344 printf(
"-E- %s: log file name %s too long (%d, max %d)\n",
1350 printf(
"-W- can not open log file %s, write to stdout\n",
1357 fprintf(
fLogClient,
"*** log file: %s, client node: %s\n",
1362 ptloc = localtime_r(&tcur, &buf_time);
1364 ptloc->tm_year += 1900;
1367 " current date %d/%.2d/%.2d, time %.2d:%.2d:%.2d\n",
1380 strcpy(pCommAPI->
cOwner, cOwner);
1381 strcpy(pCommAPI->
cliNode, cliNode);
1382 strcpy(pCommAPI->
cOS, cOS);
1383 strcpy(pCommAPI->
cDataFS,
"");
1390 strcpy(pCommAPI->
cNodeRC,
"");
1408 printf(
" request WC poolId %d, device %d\n",
1411 printf(
" request RC poolId %d, device %d\n",
1426 strcpy(pCommServ->
cOS, pCommAPI->
cOS);
1443 " connecting to %s %s:%d\n",
1449 fprintf(
fLogClient,
"-E- %s: cannot connect to %s %s:%d\n",
1461 printf(
"-I- successfully connected to %s %s:%d",
1464 printf(
" after %ds", iMaxConnect);
1465 printf(
" (socket %d)\n", iSockMaster);
1486 iSockMover = iSockMaster;
1510 pBufQuery = &sQuery;
1515 printf(
" query file %s in gStore\n", pcFile);
1521 iRC =
rawQueryFile(iSockMaster, ii, pCommServ, &pBufQuery);
1535 "-E- no %s access to archive %s in all ATL servers\n",
1538 "-E- no %s access to archive %s in ATL server %d\n",
1542 "-E- no archive %s in ATL server %d found\n",
1545 "-E- file %s: query in ATL server %d failed, rc = %d\n",
1560 " file %s not available in gStore\n", pcFile);
1563 "-E- %s: file %s not available in gStore\n",
1573 " file %s not yet available in gStore\n", pcFile);
1577 if ( (iAction == 1) &&
1583 "-E- filesize of %s >= 4 GB, cannot be read with 32 bit client\n",
1592 else if (iAction == 2)
1595 "-E- file %s already available in gStore\n", pcFile);
1603 memcpy(pQueryAPI, pQAttr, (
unsigned)
iObjAttr);
1607 printf(
" file %s available in gStore (ATL server %d)\n",
1610 if (iRC > 1) printf(
1611 "-W- %d versions of file %s exist\n", iRC, pcFile);
1619 printf(
" %s", cMsg);
1621 iStage = ntohl(pQAttr->
iFS);
1635 printf(
" file %s staged in FS %d of DM %s (poolId %d)",
1638 printf(
", still incomplete)\n");
1640 printf(
", already locked)\n");
1651 strcpy(sFileSystemServ.
cOS,
"Windows");
1652 strcpy(sFileSystemServ.
cNode, pQAttr->
cNode);
1669 printf(
" file %s cached in FS %d of DM %s (poolId %d)",
1672 printf(
", still incomplete)\n");
1674 printf(
", already locked)\n");
1682 printf(
" file %s not yet staged\n", pcFile);
1694 " send command buffer to %s: id: %d, action %d (ATL server %d), len %d\n",
1695 cServer, ntohl(pCommServ->
iIdent),
1706 " keep entry server session for next query\n");
1709 pcc = (
char *) pCommServ;
1710 iRC = send(iSockMaster, pcc, (
unsigned)
irawComm, 0);
1714 "-E- %s: sending command buffer (action %d) to %s\n",
1715 cModule, ntohl(pCommServ->
iAction), cServer);
1723 if (irawComm != iRC)
1726 "-E- %s: incomplete command buffer sent to %s (%d of %d bytes)\n",
1727 cModule, cServer, iRC, irawComm);
1735 " command buffer (action %d) sent to %s (%d byte)\n",
1736 ntohl(pCommServ->
iAction), cServer, irawComm);
1745 if ( ( (iAction == 1) && ((iStage == 0) || (iCache == 1)) ) ||
1749 " receiving attributes of data mover selected by master\n");
1751 iDataMoverSelect = 0;
1753 while (iDataMoverSelect == 0)
1755 pcc = (
char *) &sDataMoverSelect;
1760 iIdent = ntohl(sDataMoverSelect.iIdent);
1761 iStatus = ntohl(sDataMoverSelect.iStatus);
1762 iStatusLen = ntohl(sDataMoverSelect.iStatusLen);
1765 " ident %d, status %d, len %d\n",
1766 iIdent, iStatus, iStatusLen);
1771 "-E- %s: receiving data mover attr header\n%s",
1780 "-W- %s: write cache currently full (select) ... sleep %d s (%d of %d)\n",
1786 "-W- %s: write cache currently full, archive to tape\n",
1790 " received DM name: %s\n", cMsg);
1791 iDataMoverSelect = 1;
1793 strcpy(pDataMoverSelect->
cNode, cMsg);
1810 " send command buffer to %s: id: %d, action %d, len %d\n",
1811 cServer, pCommAPI->
iIdent,
1815 pcc = (
char *) pCommServ;
1816 iRC = send(iSockMaster, pcc, (
unsigned)
irawComm, 0);
1817 if (iRC != irawComm)
1822 "-E- %s: sending command buffer (action %d) to %s\n",
1823 cModule, ntohl(pCommServ->
iAction), cServer);
1827 "-E- %s: incomplete command buffer sent to %s (%d of %d bytes)\n",
1828 cModule, cServer, iRC, irawComm);
1836 " command buffer (action %d) sent to %s (%d byte)\n",
1837 ntohl(pCommServ->
iAction), cServer, irawComm);
1843 fprintf(
fLogClient,
"-E- %s: received error status from %s",
1846 printf(
"\n%s" , cMsg);
1857 " header of data mover attr received (%d bytes)\n",
1861 pcc = (
char *) &(sDataMoverSelect.sDataMoverAttr);
1866 if ( (iRC = recv( iSockMaster, pcc, (
unsigned) iBuf, 0 )) < 0 )
1869 "-E- %s: receiving data part of data mover info\n",
1871 perror(
"-E- receiving data part of data mover info");
1882 "-E- %s: connection to sender broken, %d byte of data part of data mover info (%d byte) received\n",
1883 cModule, ii, iBufl);
1893 pDataMoverSelect = &(sDataMoverSelect.sDataMoverAttr);
1902 "-E- %s: invalid ATL server no. %d received\n",
1905 "-W- %s: unexpected ATL server of selected DM: %d, expected %d\n",
1916 printf(
" data part of data mover info received (%d byte)\n",
1918 printf(
" %d data mover selected: %s for ATL server %d\n",
1921 else if (iAction == 1) printf(
1922 "-I- staging file to data mover %s (ATL server %d) ...\n",
1927 if (iDataMoverSelect != 1)
1930 "-W- expected 1 selected data mover, ignore remaining %d\n",
1931 --iDataMoverSelect);
1932 iDataMoverSelect = 1;
1951 pCommServ->
iFSidWC = htonl(0);
1952 if (iDebug) printf(
" iMediaClass %d, disk FS %d\n",
1973 pCommServ->
iObjLow = htonl(0);
1975 pCommServ->
iFSidWC = htonl(0);
2008 " connecting to data mover %s:%d\n",
2012 &iMaxConnect, &iSockMover);
2016 "-E- %s: cannot connect to data mover %s:%d (ATL server %d)\n",
2024 "-I- successfully connected to data mover %s:%d (ATL server %d)",
2029 fprintf(
fLogClient,
" after %ds", iMaxConnect);
2030 fprintf(
fLogClient,
" (socket %d)\n", iSockMover);
2037 strcpy(cServer,
"data mover");
2050 if ( (iSockMaster >= 0) && (iAction == 1) )
2053 printf(
"-D- close connection %d to master\n", iSockMaster);
2054 iRC = shutdown(iSockMaster, 2);
2056 printf(
" rc shutdown = %d\n", iRC);
2057 iRC = close(iSockMaster);
2059 printf(
" rc close = %d\n", iRC);
2104 " send command buffer to %s: id: %d, action %d, data len %d\n",
2105 cServer, pCommAPI->
iIdent,
2112 plFileSizeC = (
unsigned long *) &(pCommServ->
iFileSize);
2114 printf(
" filesize %lu bytes, record size %d",
2116 if (iAction == 1) printf(
2117 ", poolIdRC %d, poolIdWC %d, obj id %d-%d\n",
2121 printf(
", poolId %d\n", ntohl(pCommServ->
iPoolIdWC));
2129 pcc = (
char *) pCommServ;
2130 if ( (iRC = send(iSockMover, pcc, (
unsigned)
irawComm, 0 )) < 0 )
2132 fprintf(
fLogClient,
"-E- %s: sending command buffer to %s (rc = %d)\n",
2133 cModule, cServer, iRC);
2141 if (irawComm != iRC)
2144 "-E- %s: incomplete command buffer sent to %s (%d of %d bytes)\n",
2145 cModule, cServer, iRC, irawComm);
2153 " command buffer sent to %s (%d byte)\n", cServer, irawComm);
2158 pcc = (
char *) &sFileSystemServ;
2160 if (irawFileSystem != iRC)
2165 "-E- %s: sending filesystem buffer to data mover %s failed\n",
2170 "-E- %s: incomplete filesystem buffer sent to data mover %s\n",
2179 " write cache info (%d bytes) sent to data mover %s\n",
2186 pcc = (
char *) &sStatus;
2189 while (iStatusOkay == 0)
2196 if (iRC != HEAD_LEN)
2200 fprintf(
fLogClient,
"-E- %s: receiving status buffer from %s",
2215 "-W- %s: write cache currently full (create) ... sleep %d s (%d of %d)\n",
2223 "-W- %s: write cache currently full: archive to tape\n",
2239 "-W- write cache on DM %s full, switch to %s\n",
2243 " close connection %d to data mover %s\n",
2245 iRC = shutdown(iSockMover, 2);
2247 printf(
" rc shutdown = %d\n", iRC);
2248 iRC = close(iSockMover);
2250 printf(
" rc close = %d\n", iRC);
2255 " connecting to data mover %s:%d\n",
2259 &iMaxConnect, &iSockMover);
2263 "-E- %s: cannot connect to new data mover %s:%d (ATL server %d)\n",
2269 "-I- successfully connected to new data mover %s:%d (ATL server %d)",
2272 fprintf(
fLogClient,
" after %ds", iMaxConnect);
2274 printf(
" (socket %d)\n", iSockMover);
2286 fprintf(
fLogClient,
"-E- %s: message received from %s:\n",
2303 printf(
" status (%d) received from %s (%d bytes",
2304 iStatus, cServer, iRC);
2305 if (iStatusLoop > 1)
2306 printf(
", iter %d)\n", iStatusLoop);
2315 if ( (iSockMaster >= 0) &&
2316 ((iAction == 1) || (iError)) )
2324 "-E- %s: sending status buffer to entry server (EOS)\n", cModule);
2325 else if (iDebug) printf(
2326 " status buffer (EOS) sent to entry server (%d bytes)\n", iRC);
2330 printf(
" close connection %d to entry server\n", iSockMaster);
2331 iRC = shutdown(iSockMaster, 2);
2333 printf(
" irc shutdown = %d\n", iRC);
2334 iRC = close(iSockMaster);
2336 printf(
" irc close = %d\n", iRC);
2343 if (iSockMover >= 0)
2351 "-E- %s: sending status buffer (EOS) to %s\n", cModule, cServer);
2352 else if (iDebug) printf(
2353 " status buffer (EOS) sent to %s (%d bytes)\n",
2358 " close connection %d to %s\n", iSockMover, cServer);
2359 iRC = shutdown(iSockMover, 2);
2361 printf(
" rc shutdown = %d\n", iRC);
2362 iRC = close(iSockMover);
2364 printf(
" rc close = %d\n", iRC);
2377 printf(
"-D- end %s\n\n", cModule);
2397 char cModule[32] =
"rfio_endfile";
2404 char cServer[16] =
"data mover";
2415 "\n-D- begin %s: close remote file %d\n", cModule, iFileId);
2421 "-E- %s: no remote file available for close\n", cModule);
2429 if (
pAPIFile[ii]->iFileId == iFileId)
2437 fprintf(
fLogClient,
"-E- %s: remote file %d cannot be closed: not found\n",
2443 pCommAPI = &(pcurAPIFile->
sCommAPI);
2449 if (iSockMover >= 0)
2455 fprintf(
fLogClient,
"-E- %s: sending status buffer (EOF) to %s\n",
2457 else if (iDebug) printf(
2458 " status buffer (EOF) sent to %s (%d bytes)\n",
2462 pcc = (
char *) &sStatus;
2466 fprintf(
fLogClient,
"-E- %s: receiving status buffer\n", cModule);
2473 " status buffer (%d) received (%d byte)\n",
2483 "-W- %s: message received from server:\n", cModule);
2496 if ( (pcurAPIFile->
iOpMode != 2) &&
2499 "-I- gStore file %s%s%s closed\n",
2503 "-I- remote output file %s%s%s closed\n",
2511 " remote file control block %d still active (overall %d)\n",
2513 printf(
"-D- end %s\n\n", cModule);
2534 char cModule[32] =
"rfio_read";
2559 printf(
"\n-D- begin %s: fileId %d\n", cModule, iFileId);
2563 fprintf(
fLogClient,
"-E- %s: no remote file open for read\n", cModule);
2571 if (
pAPIFile[ii]->iFileId == iFileId)
2579 fprintf(
fLogClient,
"-E- %s: remote file %d cannot be read: not opened\n",
2585 printf(
" open buffer %d, fileId %d\n", ii, iFileId);
2588 pCommAPI = &(pcurAPIFile->
sCommAPI);
2597 printf(
" remote file control block %d selected\n", ii);
2598 printf(
" file %d, buffer %d: read %d bytes\n",
2599 iFileId, iBufnoServ, iItems);
2605 if (iBufsizeRead != iItems)
2606 printf(
" new buffer size %d\n", iItems);
2607 printf(
" send request for new buffer\n");
2612 iOffset = pcurAPIFile->
iOffset;
2613 iRC =
rawSendRequest(iSockMover, iSeekMode, iOffset, (
signed) iItems);
2616 fprintf(
fLogClient,
"-E- %s: sending request for next data buffer\n",
2622 if (iSeekMode != -1)
2633 pcc = (
char *) &iBufsizeRecv;
2638 if ( (iRC = recv( iSockMover, pcc, (
unsigned) iBuf, 0 )) < 0 )
2641 "-E- %s: receiving data length from server (buffer %d)",
2642 cModule, iBufnoServ);
2651 "-E- %s: connection to sender broken, %d byte of data length (%d byte) received (buffer %d)\n",
2652 cModule, ii,
iint, iBufnoServ);
2667 iBufsizeRecv = ntohl(iBufsizeRecv);
2669 printf(
"%d_", iBufsizeRecv);
2671 if (iBufsizeRecv < 0)
2675 fprintf(
fLogClient,
"-E- %s: invalid status header received (%d)\n",
2676 cModule, iBufsizeRecv);
2680 printf(
"-D- status header found\n");
2688 if ( (iRC = recv( iSockMover, pcc, (
unsigned) iBuf, 0 )) < 0 )
2691 "-E- %s: receiving remainder of status header from server (buffer %d)",
2692 cModule, iBufnoServ);
2702 "-W- %s: connection to sender broken, %d byte of remainder of status header (%d byte) received (buffer %d)\n",
2703 cModule, ii, iBufl, iBufnoServ);
2715 pint = (
int *) pcBuffer;
2716 iStatus = ntohl(*pint);
2722 fprintf(
fLogClient,
"-E- %s: unexpected status from server: %d\n",
2730 if (iDebug) printf(
" EOF on input\n");
2734 fprintf(
fLogClient,
"-E- %s: %s%s%s empty\n",
2744 iStatusLen = ntohl(*pint);
2751 "-E- %s: receiving status message from server, rc = %d\n",
2760 "-E- %s: received error status from server:\n",
2767 printf(
"%s\n", pcc);
2773 else if (iBufsizeRecv != iItems)
2777 if (iBufsizeRecv) printf(
2778 "-W- requested %d bytes, received buffer length %d bytes\n",
2779 iItems, iBufsizeRecv);
2780 else printf(
"-W- EOF reached\n");
2782 iItems = (size_t) iBufsizeRecv;
2786 iBuf = iBufsizeRecv;
2791 if ( (iRC = recv( iSockMover, pcc, (
unsigned) iBuf, 0 )) < 0 )
2794 "-E- %s: receiving data from server (buffer %d)\n",
2795 cModule, iBufnoServ);
2802 ii = iBufsizeRecv - iBuf;
2804 "-W- %s: connection to sender broken, %d byte of data buffer (%d byte) received (buffer %d)\n",
2805 cModule, ii, iBufsizeRecv, iBufnoServ);
2826 printf(
" buffer %d received\n", pcurAPIFile->
iBufnoServ);
2830 printf(
"-D- end %s\n\n", cModule);
2832 return iBufsizeRecv;
2844 const char *pcBuffer,
2847 char cModule[32] =
"rfio_write";
2866 printf(
"\n-D- begin %s\n", cModule);
2873 "-W- invalid no. of bytes to write: %d\n", iItems);
2879 fprintf(
fLogClient,
"-E- %s: no remote file open for write\n", cModule);
2888 if (
pAPIFile[ii]->iFileId == iFileId)
2897 "-E- %s: remote file %d cannot be written: not opened\n",
2904 pCommAPI = &(pcurAPIFile->
sCommAPI);
2911 printf(
" remote file control block %d selected\n", ii);
2912 printf(
" file %d, buffer %d: write %d bytes\n",
2913 iFileId, iBufnoServ, iItems);
2925 printf(
" new buffer size %d\n", iItems);
2926 printf(
" send new buffer\n");
2934 iBufsizeWrite = htonl( (
int) iItems);
2936 pcc = (
char *) &iBufsizeWrite;
2939 iRC = send( iSockMover, pcc, (
unsigned) iBuf, 0 );
2943 "-E- %s: sending data length to server broken\n", cModule);
2947 "-E- %s: sending data length to server (buffer %d)",
2948 cModule, iBufnoServ);
2959 printf(
"%d(%d)_", iRC, iItems);
2965 iBuf = (int) iItems;
2966 pcc = (
char *) pcBuffer;
2969 iRC = send( iSockMover, pcc, (
unsigned) iBuf, 0 );
2973 "-E- %s: sending data to server broken\n", cModule);
2977 "-E- %s: sending data to server (buffer %d, %d bytes)",
2978 cModule, iBufnoServ, iBuf);
3000 printf(
" buffer %d sent\n", pcurAPIFile->
iBufnoServ);
3004 printf(
"-D- end %s\n", cModule);
3006 return (ssize_t) iItems;
3020 char cModule[32] =
"rfio_newfile";
3029 int iCopyBuffer = 0;
3034 int iMaxConnect = 0;
3040 int iStatusOkay = 0;
3041 int iStatusLoop = 0;
3043 char *pcc, *pcc1, *pcc2;
3066 printf(
"\n-D- begin %s\n", cModule);
3071 "-E- %s: no open connection to server existing\n", cModule);
3081 if (
pAPIFile[ii]->iFileId == iFileId)
3089 fprintf(
fLogClient,
"-E- %s: no open connection to server\n", cModule);
3095 printf(
" requested API control block %d\n", iFileId);
3098 pCommAPI = &(pcurAPIFile->
sCommAPI);
3102 if ( (pcurAPIFile->
iAction == 1) ||
3106 fprintf(
fLogClient,
"-E- %s for read not supported\n", cModule);
3110 else if (pcurAPIFile->
iAction == 2)
3113 printf(
" connection is open for write\n");
3117 fprintf(
fLogClient,
"-E- %s: connection is open for unexpected action %d\n",
3118 cModule, pcurAPIFile->
iAction);
3124 printf(
" check name parts in %s\n", pcFile);
3126 pcc1 = (
char *) strrchr(pcFile, *
pcDevDelim);
3130 "-E- %s: invalid remote file name %s: node name missing\n",
3136 strcpy(cTemp, pcFile);
3137 pcc = (
char *) strchr(pcFile, *pcObjDelim);
3140 fprintf(
fLogClient,
"-E- %s: invalid remote file name %s\n",
3152 "-E- %s: invalid remote file name %s - possibly leading '/' in archive name missing\n",
3158 if (strncmp(cTemp,
"rfiocopy:", 9) == 0)
3162 printf(
" copy via RFIO server\n");
3164 else if (strncmp(cTemp,
"rfiodaq:", 8) == 0)
3168 printf(
" copy to mass storage (DAQPool)\n");
3170 else if (strncmp(cTemp,
"rfio:", 5) == 0)
3174 printf(
" copy to mass storage (ArchivePool)\n");
3180 printf(
" copy to mass storage (ArchivePool)\n");
3183 if (pcurAPIFile->
iMassSto != iMassSto)
3186 "-E- %s: remote file %s incompatible with open server connection\n",
3193 " requested server consistent with open connection (%d)\n",
3202 strcpy(pcNamefs, pcc);
3206 pcc1 = (
char *) strchr(pcc, *pcObjDelim);
3211 "-E- archive name starting with %s too long, max allowed %d chars\n",
3214 "-E- %s: archive name starting with %s too long, max allowed %d chars\n",
3215 cModule, pcNamefs, ii);
3220 strncpy(pcc1,
"\0", 1);
3221 if (strlen(pCommServ->
cNamefs))
3223 if (strcmp(pCommServ->
cNamefs, pcNamefs))
3226 "-E- %s: invalid archive name %s, expected %s\n",
3227 cModule, pcNamefs, pCommServ->
cNamefs);
3233 strcpy(pCommServ->
cNamefs, pcNamefs);
3234 iArchLen = strlen(pcNamefs);
3237 " archive name: %s (len %d chars)\n", pcNamefs, iArchLen);
3242 "-E- %s: invalid archive name '%s'\n", cModule, pcNamefs);
3247 pcc = (
char *) strchr(cTemp, *pcObjDelim);
3249 pcc2 = (
char *) strchr(pcc, *pcObjDelim);
3253 "-E- %s: invalid remote file name %s: missing path name\n",
3260 printf(
" path + file name: %s\n", pcc2);
3264 pcc1 = (
char *) strrchr(pcc, *pcObjDelim);
3268 "-E- %s: invalid remote file name %s: missing file name\n",
3275 printf(
" file name: %s\n", pcc1);
3277 iPathLen = pcc2-pcc1;
3279 iPathLen = -iPathLen;
3281 printf(
" length path name: %d\n", iPathLen);
3287 printf(
"-E- path name too long, max allowed %d chars\n", ii);
3289 "-E- %s: remote path name (%d chars) too long, max allowed %d\n",
3290 cModule, iPathLen, ii);
3295 strncpy(pcNamehl, pcc2, (
unsigned) iPathLen);
3297 printf(
" path name: %s\n", pcNamehl);
3300 if (strcmp(pcNamehl, pCommAPI->
cNamehl))
3302 strcpy(pcNamehl, pCommAPI->
cNamehl);
3303 printf(
" gStore path name corrected to %s\n", pcNamehl);
3306 strcat(pcFile, cNamefs);
3307 strcat(pcFile, cNamehl);
3308 strcat(pcFile, pcc1);
3310 " new full file name: %s\n", pcFile);
3313 iFileLen = strlen(pcc1);
3315 printf(
" length file name: %d\n", iFileLen);
3318 if ((
int) strlen(pcc1) > ii)
3321 printf(
"-E- file name too long, max allowed %d chars\n", ii);
3323 "-E- %s: file name %s (%d chars) too long, max allowed %d\n",
3324 cModule, pcc1, iFileLen, ii);
3329 strcpy(pcNamell, pcc1);
3331 printf(
" file name: %s\n", pcNamell);
3336 strcpy(pCommServ->
cNamefs,
"");
3341 pcc1 = (
char *) strrchr(pcc, *pcObjDelim);
3344 fprintf(
fLogClient,
"-E- %s: invalid remote file name %s\n",
3354 "-E- %s: remote file name %s too long (max %d chars)\n",
3360 strcpy(pcNamell, pcc1);
3362 " remote file name on RFIO server: %s\n", pcNamell);
3364 strncpy(pcc1,
"\0", 1);
3369 "-E- %s: remote path name %s too long (max %d chars)\n",
3370 cModule, cTemp, ii);
3375 strcpy(pcNamehl, cTemp);
3377 " remote path name on RFIO server: %s\n", pcNamehl);
3381 if (strlen(pCommServ->
cNamehl))
3383 if (strcmp(pCommServ->
cNamehl, pcNamehl))
3385 fprintf(
fLogClient,
"-W- new path name %s, previous %s\n",
3386 pcNamehl, pCommServ->
cNamehl);
3394 strcpy(pCommServ->
cNamehl, pcNamehl);
3395 strcpy(pCommAPI->
cNamehl, pcNamehl);
3398 if (strlen(pCommAPI->
cNamefs) < 3)
3401 strcpy(pCommAPI->
cNamell, pcNamell);
3402 strcpy(pCommServ->
cNamell, pcNamell);
3405 strcpy(pCommServ->
cNamehl, pcNamehl);
3406 strcpy(pCommAPI->
cNamehl, pcNamehl);
3410 printf(
" file name: %s\n", pcNamell);
3420 " query file %s in ATL server %d\n", pcFile,
iATLServer);
3422 pBufQuery = &sQuery;
3428 pCommServ, &pBufQuery);
3437 "-E- no write access to archive %s in mass storage\n",
3440 "-E- no archive %s in mass storage found\n",
3443 "-E- file %s: query in mass storage failed, rc = %d\n",
3447 "-E- file %s already available in mass storage\n",
3451 if ( (iRC == -1001) || (iRC == -1000) )
3460 " file %s not yet available in mass storage\n", pcFile);
3465 iCopyMode = ntohl(pCopyCacheServ->
iCopyMode);
3468 iCopyLen = ntohl(pCopyCacheServ->
iCopyLen);
3473 pCopyCacheServ->
iCopyLen = htonl(ii);
3475 printf(
" send copy parameters to DM\n");
3478 printf(
" copy parameters already sent to DM\n");
3481 printf(
" data are only written to WC\n");
3485 printf(
" send command buffer to server %s: id: %d, action %d, bufsize %d",
3491 printf(
", data len %d\n",
3494 printf(
", data len %d\n", pCommAPI->
iCommLen);
3498 pcc = (
char *) pCommServ;
3503 if ( (iRC = send(iSockMover, pcc, (
unsigned)
irawComm, 0 )) < 0 )
3506 "-E- %s: sending command buffer to server %s (rc = %d)\n",
3513 if (irawComm != iRC)
3516 "-E- %s: incomplete command buffer sent to server %s (%d of %d bytes)\n",
3517 cModule, pcurAPIFile->
cNodeMover, iRC, irawComm);
3524 " command buffer sent to server %s (%d byte)\n",
3529 pcc = (
char *) pCopyCacheServ;
3530 if ( (iRC = send(iSockMover, pcc, (
unsigned)
irawCopyCache, 0 )) < 0 )
3533 "-E- %s: sending copy buffer to server %s (rc = %d)\n",
3540 if (irawCopyCache != iRC)
3543 "-E- %s: incomplete copy buffer sent to server %s (%d of %d bytes)\n",
3544 cModule, pcurAPIFile->
cNodeMover, iRC, irawCopyCache);
3551 " copy buffer sent to server %s (%d byte)\n",
3560 pcc = (
char *) &sStatus;
3563 while (iStatusOkay == 0)
3571 " status %d received (%d byte)\n", iStatus, iRC);
3575 "-E- %s: receiving status buffer from server\n",
3585 "-W- %s: write cache currently full ... sleep %d s (%d of %d)\n",
3593 "-W- %s: write cache currently full, archive to tape\n",
3604 goto gNextCmdNewFile;
3609 strcpy(cNodeMover, sStatus.
cStatus);
3612 "-W- write cache on DM %s full or too much load, switch to %s\n",
3616 " close connection %d to data mover %s\n",
3618 iRC = shutdown(iSockMover, 2);
3620 printf(
" rc shutdown = %d\n", iRC);
3622 iRC = close(iSockMover);
3624 printf(
" rc close = %d\n", iRC);
3627 "-I- connection to data mover %s closed\n",
3633 " connecting to data mover %s:%d\n",
3637 &iMaxConnect, &iSockMover);
3641 "-E- %s: cannot connect to new data mover %s:%d (ATL server %d)\n",
3647 "-I- successfully connected to new data mover %s:%d (ATL server %d)",
3650 fprintf(
fLogClient,
" after %ds", iMaxConnect);
3652 printf(
" (socket %d)\n", iSockMover);
3659 pCopyCacheServ->
iCopyLen = htonl(0);
3661 goto gNextCmdNewFile;
3666 fprintf(
fLogClient,
"-E- message received from server:\n");
3686 printf(
" status (%d) received from server (%d bytes",
3688 if (iStatusLoop > 1)
3689 printf(
", iter %d)\n", iStatusLoop);
3702 printf(
"-D- end %s\n\n", cModule);
3719 char cModule[32] =
"rfio_close";
3733 "\n-D- begin %s: close remote file %d\n", cModule, iFileId);
3738 "-E- %s: no remote file available for close\n", cModule);
3746 if (
pAPIFile[ii]->iFileId == iFileId)
3754 fprintf(
fLogClient,
"-E- %s: remote file %d cannot be closed: not found\n",
3760 pCommAPI = &(pcurAPIFile->
sCommAPI);
3766 fprintf(
fLogClient,
"-I- gStore file %s%s%s closed\n",
3769 if (iSockMaster >= 0)
3774 "-E- %s: sending status buffer (EOS) to master\n", cModule);
3775 else if (iDebug) printf(
3776 " status buffer (EOS) sent to master (%d bytes)\n", iRC);
3779 printf(
" close connection %d to master\n", iSockMaster);
3780 iRC = shutdown(iSockMaster, 2);
3782 printf(
" rc shutdown = %d\n", iRC);
3783 iRC = close(iSockMaster);
3785 printf(
" rc close = %d\n", iRC);
3790 if (iSockMover >= 0)
3795 "-E- %s: sending status buffer (EOS) to data mover\n", cModule);
3796 else if (iDebug) printf(
3797 " status buffer (EOS) sent to data mover (%d bytes)\n", iRC);
3804 memset(&sStatusRecv, 0X00,
sizeof(
srawStatus));
3805 pcc = (
char *) &sStatusRecv;
3809 "-E- %s: receiving confirmation of status buffer (EOS)\n",
3811 else if (iDebug) printf(
3812 " status (%d) confirmed by server (%d bytes)\n",
3817 printf(
" close connection %d to data mover\n", iSockMover);
3818 iRC = shutdown(iSockMover, 2);
3820 printf(
" rc shutdown = %d\n", iRC);
3821 iRC = close(iSockMover);
3823 printf(
" rc close = %d\n", iRC);
3825 "-I- connection to data mover %s closed\n",
3837 " remote file control block %d deleted (%d still active)\n",
3839 printf(
"-D- end %s\n\n", cModule);
3846 #ifdef __USE_LARGEFILE64
3858 const struct iovec64 *piov,
3861 char cModule[32] =
"rfio_preseek64";
3866 "\n-D- begin %s: iFileId %d\n", cModule, iFileId);
3872 "-E- 32 bit client: %s not supported\n", cModule);
3878 "-W- %s not yet implemented for gStore\n", cModule);
3881 fprintf(
fLogClient,
"-D- end %s\n\n", cModule);
3895 int64_t rfio_lseek64(
3897 int64_t i64locOffset,
3900 char cModule[32] =
"rfio_lseek64";
3910 "-E- 32 bit client: %s not supported\n", cModule);
3916 "\n-D- begin %s: iFileId %d, Offset %lld, SeekMode %d\n",
3917 cModule, iFileId, (
unsigned long) i64locOffset, ilocSeekMode);
3919 ilocOffset = (int) i64locOffset;
3921 iRC =
rfio_lseek(iFileId, ilocOffset, ilocSeekMode);
3924 "-D- end %s: rc(rfio_lseek) = %d \n\n", cModule, iRC);
3926 return (int64_t) iRC;
3944 char cModule[32] =
"rfio_lseek";
3955 printf(
"\n-D- begin %s: file %d\n", cModule, iFileId);
3956 if (ilocSeekMode == SEEK_SET)
3957 printf(
" position to %d bytes, \n", ilocOffset);
3958 else if (ilocSeekMode == SEEK_CUR)
3959 printf(
" position to current + %d bytes, \n", ilocOffset);
3960 else if (ilocSeekMode == SEEK_END)
3961 printf(
" position to file size + %d bytes, \n", ilocOffset);
3964 fprintf(
fLogClient,
"-E- %s: unexpected offset (%d)\n",
3965 cModule, ilocSeekMode);
3974 if (iSeekMode != -1)
3977 iOffset = pcurAPIFile->
iOffset;
3981 fprintf(
fLogClient,
"-E- %s: sending request for seek\n", cModule);
3987 pcurAPIFile->
iOffset = ilocOffset;
3990 printf(
"-D- end %s\n\n", cModule);
4006 char cModule[32] =
"rfio_fopen";
4008 RFILE *fRemoteFile = NULL;
4010 char *pcCopyPath = NULL;
4011 int iCopyFraction = 0;
4013 int iPathConvention = 0;
4016 printf(
"\n-D- begin %s: calling rfio_fopen_gsidaq\n", cModule);
4028 printf(
"-D- end %s\n\n", cModule);
4081 int iPathConvention)
4092 char cModule[32] =
"rfio_fopen_gsidaq_dm";
4100 printf(
"\n-D- begin %s: calling rfio_open_gsidaq\n", cModule);
4102 if (*pcOptions ==
'r')
4105 pcFile, O_RDONLY, 0,
4106 iCopyMode, pcCopyPath, iCopyFraction, iMaxFile,
4109 if (*pcOptions ==
'w')
4112 pcFile, O_WRONLY | O_CREAT, 0,
4113 iCopyMode, pcCopyPath, iCopyFraction, iMaxFile,
4122 " connected with data mover %s\n", pcDataMover);
4126 iDataMover = atoi(pcc);
4127 *piDataMover = iDataMover;
4130 " running number data mover: %d\n", iDataMover);
4134 "-D- end %s: iFileId(rfio_open_gsidaq) = %d\n\n",
4188 int iPathConvention)
4199 char cModule[32] =
"rfio_fopen_gsidaq";
4204 printf(
"\n-D- begin %s: calling rfio_open_gsidaq\n", cModule);
4206 if (*pcOptions ==
'r')
4209 pcFile, O_RDONLY, 0,
4210 iCopyMode, pcCopyPath, iCopyFraction, iMaxFile,
4213 if (*pcOptions ==
'w')
4216 pcFile, O_WRONLY | O_CREAT, 0,
4217 iCopyMode, pcCopyPath, iCopyFraction, iMaxFile,
4222 "-D- end %s: iFileId(rfio_open_gsidaq) = %d\n\n",
4242 char cModule[32] =
"rfio_fnewfile";
4250 printf(
"\n-D- begin %s\n", cModule);
4256 fprintf(
fLogClient,
"-E- %s: still no connection to server opened\n",
4261 if (pRemFile == NULL)
4263 fprintf(
fLogClient,
"-E- %s: invalid file ptr (NULL) specified\n", cModule);
4267 if ( (pcFile == NULL) || (strlen(pcFile) < 5) )
4269 fprintf(
fLogClient,
"-E- %s: invalid file '%s' specified\n",
4284 fprintf(
fLogClient,
"-E- %s: invalid file ptr specified\n", cModule);
4288 iFileId = pRemFile->iFileId;
4292 printf(
"-D- end %s\n\n", cModule);
4313 char cModule[32]=
"rfio_fread";
4320 printf(
"\n-D- begin %s\n", cModule);
4322 if (pRemFile == NULL)
4324 fprintf(
fLogClient,
"-E- %s: remote file not open for read\n", cModule);
4328 iFileId = pRemFile->iFileId;
4329 iBytes = iSize*iItems;
4330 iRC = (int)
rfio_read(iFileId, pcBuffer, iBytes);
4333 printf(
"-D- end %s\n", cModule);
4335 return (
unsigned) iRC;
4351 char cModule[32]=
"rfio_fwrite";
4358 printf(
"\n-D- begin %s\n", cModule);
4360 if (pRemFile == NULL)
4362 fprintf(
fLogClient,
"-E- %s: remote file not open for write\n", cModule);
4366 iFileId = pRemFile->iFileId;
4367 iBytes = iSize*iItems;
4368 iRC = (int)
rfio_write(iFileId, pcBuffer, iBytes);
4371 printf(
"-D- end %s\n", cModule);
4373 return (
unsigned) iRC;
4388 char cModule[32] =
"rfio_fendfile";
4394 printf(
"\n-D- begin %s\n", cModule);
4396 iFileId = pRemFile->iFileId;
4400 printf(
"-D- end %s\n", cModule);
4417 char cModule[32] =
"rfio_fclose";
4423 printf(
"\n-D- begin %s\n", cModule);
4425 iFileId = pRemFile->iFileId;
4429 printf(
"-D- end %s\n", cModule);
4446 char cModule[32] =
"rfio_access";
4453 printf(
"\n-D- begin %s\n", cModule);
4459 printf(
" check if executable - not supported\n");
4467 printf(
" check for existence\n");
4469 iFileId =
rfio_open(pcFile, O_RDONLY, -1);
4475 printf(
"-E- closing remote file %s\n", pcFile);
4479 printf(
"-D- remote file %s closed\n", pcFile);
4487 printf(
" file %s must not be overwritten\n",
4491 else if (iMode == R_OK)
4494 printf(
" file %s is readable\n", pcFile);
4500 printf(
" file %s exists\n", pcFile);
4510 printf(
" file %s may be written\n", pcFile);
4516 printf(
" file %s not existing\n", pcFile);
4526 printf(
" file %s is readable\n", pcFile);
4532 printf(
" file %s may be written\n", pcFile);
4538 printf(
"-D- end %s\n", cModule);
4544 #ifdef __USE_LARGEFILE64
4554 int rfio_fstat64(
int iFileId,
4555 struct stat64 *pStatBuf64)
4557 char cModule[32] =
"rfio_fstat64";
4562 unsigned long *plFileSizeC;
4567 fprintf(
fLogClient,
"\n-D- begin %s: file %d\n", cModule, iFileId);
4578 "-E- 32 bit client: %s not supported\n", cModule);
4588 if (
pAPIFile[ii]->iFileId == iFileId)
4597 fprintf(
fLogClient,
"-E- %s: specified remote fileId %d not found\n",
4600 fprintf(
fLogClient,
"-D- end %s\n\n", cModule);
4606 plFileSizeC = (
unsigned long *) &(pComm->
iFileSize);
4610 fprintf(
fLogClient,
" specified remote fileId %d found:\n", iFileId);
4611 fprintf(
fLogClient,
" object %s%s%s, filesize %lu byte\n",
4616 iRC = fstat64(0, pStatBuf64);
4619 fprintf(
fLogClient,
"-E- %s: fstat64() failed, rc = %d\n", cModule, iRC);
4621 printf(
"-D- end %s\n\n", cModule);
4627 pStatBuf64->st_size = *plFileSizeC;
4630 "-D- end %s: irc(fstat64) = %d\n", cModule, iRC);
4647 struct stat *pStatBuf)
4649 char cModule[32] =
"rfio_fstat";
4658 printf(
"\n-D- begin %s", cModule);
4660 printf(
", %d remote files currently open\n",
iFileCount);
4670 if (
pAPIFile[ii]->iFileId == iFileId)
4679 fprintf(
fLogClient,
"-E- %s: specified remote fileId %d not found\n",
4682 printf(
"-D- end %s\n\n", cModule);
4690 printf(
" specified remote fileId %d found:\n", iFileId);
4691 printf(
" object %s%s%s, filesize %u byte\n",
4699 iRC = fstat(0, pStatBuf);
4702 fprintf(
fLogClient,
"-E- %s: fstat() failed, rc = %d\n", cModule, iRC);
4704 printf(
"-D- end %s\n\n", cModule);
4713 printf(
"-D- end %s\n\n", cModule);
4731 char cModule[32] =
"rfio_parse";
4735 printf(
"\n-D- begin %s\n", cModule);
4738 printf(
"-D- end %s\n", cModule);
4754 char cModule[32] =
"rfio_perror";
4758 printf(
"\n-D- begin %s\n", cModule);
4761 fprintf(stderr,
"%s : No error message\n", pUMsg);
4766 printf(
"-D- end %s\n", cModule);
4782 char cModule[32] =
"rfio_serror";
4786 "\n-D- begin %s: error (len %d byte):\n",
4793 printf(
"-D- end %s\n", cModule);
4811 char cModule[32] =
"rfio_unlink";
4815 printf(
"\n-D- begin %s\n", cModule);
4818 "-W- %s not yet implemented for gStore\n", cModule);
4821 printf(
"-D- end %s\n", cModule);
4836 char cModule[32] =
"rfiosetopt";
4840 printf(
"\n-D- begin %s\n", cModule);
4843 printf(
"-D- end %s\n", cModule);
4858 char cModule[32] =
"rfio_mkdir";
4862 printf(
"\n-D- begin %s\n", cModule);
4865 "-W- %s not yet implemented for gStore\n", cModule);
4868 printf(
"-D- end %s\n", cModule);
4883 char cModule[32] =
"rfio_opendir";
4887 printf(
"\n-D- begin %s\n", cModule);
4890 "-W- %s not yet implemented for gStore\n", cModule);
4893 printf(
"-D- end %s\n", cModule);
4908 char cModule[32] =
"rfio_readdir";
4912 printf(
"\n-D- begin %s\n", cModule);
4915 "-W- %s not yet implemented for gStore\n", cModule);
4918 printf(
"-D- end %s\n", cModule);
4933 char cModule[32] =
"rfio_closedir";
4937 printf(
"\n-D- begin %s\n", cModule);
4940 "-W- %s not yet implemented for gStore\n", cModule);
4943 printf(
"-D- end %s\n", cModule);
4949 #ifdef __USE_LARGEFILE64
4959 int rfio_stat64(
const char *pcFile,
struct stat64 *pStatBuf64)
4961 char cModule[32] =
"rfio_stat64";
4973 unsigned long *plFileSizeC;
4976 fprintf(
fLogClient,
"\n-D- begin %s: file %s\n", cModule, pcFile);
4982 "-E- 32 bit client: %s not supported\n", cModule);
4995 strcpy(cObject, pComm->
cNamefs);
4996 strcat(cObject, pComm->
cNamehl);
4997 strcat(cObject, pComm->
cNamell);
5000 " %d: %s already open\n", ii, cObject);
5002 pcc = strstr(pcFile, cObject);
5007 fprintf(
fLogClient,
" %d: %s maps\n", ii, cObject);
5012 " %d: no (more) open file found\n", ii);
5020 " remote file %s not yet open\n", pcFile);
5022 iFileId =
rfio_open( (
char *) pcFile, O_RDONLY, -1);
5024 "-E- %s: open for remote file %s failed\n", cModule, pcFile);
5030 "-E- %s: invalid handle (%d) for remote file %s found\n",
5031 cModule, iFileId, pcFile);
5038 plFileSizeC = (
unsigned long *) &(pComm->
iFileSize);
5042 fprintf(
fLogClient,
" remote fileId %d:\n", iFileId);
5043 fprintf(
fLogClient,
" object %s%s%s, filesize %lu byte\n",
5049 pStatBuf64->st_size = *plFileSizeC;
5058 fprintf(
fLogClient,
"-D- end %s\n\n", cModule);
5076 char cModule[32] =
"rfio_stat";
5089 printf(
"\n-D- begin %s\n", cModule);
5099 strcpy(cObject, pComm->
cNamefs);
5100 strcat(cObject, pComm->
cNamehl);
5101 strcat(cObject, pComm->
cNamell);
5104 printf(
" %d: %s already open\n", ii, cObject);
5106 pcc = strstr(pcFile, cObject);
5111 printf(
" %d: %s maps\n", ii, cObject);
5116 printf(
" %d: no (more) open file found\n", ii);
5124 " remote file %s not yet open\n", pcFile);
5126 iFileId =
rfio_open( (
char *) pcFile, O_RDONLY, -1);
5128 "-E- %s: open for remote file %s failed\n", cModule, pcFile);
5134 "-E- %s: invalid handle (%d) for remote file %s found\n",
5135 cModule, iFileId, pcFile);
5144 printf(
" remote fileId %d:\n", iFileId);
5145 printf(
" object %s%s%s, filesize %ld byte\n",
5159 printf(
"-D- end %s\n\n", cModule);
5185 char cModule[32] =
"rfio_cache_stat";
5200 printf(
"\n-D- begin %s: %d files open\n", cModule,
iFileCount);
5201 printf(
" get cache status of file %s\n", pcFile);
5212 strcpy(cObject, pComm->
cNamefs);
5213 strcat(cObject, pComm->
cNamehl);
5214 strcat(cObject, pComm->
cNamell);
5217 printf(
" %d: %s already open\n", ii, cObject);
5219 pcc = strstr(pcFile, cObject);
5224 printf(
" %d: %s maps\n", ii, cObject);
5229 printf(
" %d: no (more) open file found\n", ii);
5237 " remote file %s not yet open\n", pcFile);
5239 iFileId =
rfio_open( (
char *) pcFile, O_RDONLY, -1);
5243 "-E- remote file %s not in gStore or unavailable\n",
5251 " remote file %s successfully opened for query and closed\n", pcFile);
5259 "-E- %s: invalid handle (%d) for remote file %s found\n",
5260 cModule, iFileId, pcFile);
5280 printf(
" remote fileId %d:\n", iFileId);
5281 printf(
" object %s%s%s, size %ld byte, cache status %d\n",
5285 printf(
" read cache FS %d\n", pComm->
iStageFSid);
5287 printf(
" write cache FS %d\n", pComm->
iFSidWC);
5298 printf(
"-D- end %s\n\n", cModule);
5316 char cModule[32] =
"rfio_gsi_query";
5325 printf(
"\n-D- begin %s\n", cModule);
5329 printf(
"-E- %s: no remote file available\n", cModule);
5338 if (
pAPIFile[ii]->iFileId == iFileId)
5346 printf(
"-E- %s: remote file %d not found\n", cModule, iFileId);
5356 printf(
" %s\n", pInfo);
5357 if (iRC != iOut) printf(
5358 " (used %d byte, avail %d byte)\n", iRC, iOut);
5363 printf(
"-D- end %s\n\n", cModule);
ssize_t rfio_read(int iFileId, char *pcBuffer, size_t iItems)
#define MAXLOOP_CACHE_FULL
int rfio_endfile(int iFileId)
int rfio_open(const char *pcFile, int iFlags, int iOpenMode)
char cApplType[MAX_APPLTYPE]
char cNodeCacheMgr[MAX_NODE]
int rawGetLLName(char *, const char *, char *)
char cDateCreate[MAX_DATE]
int rawSendRequest(int, int, int, int)
int rfio_unlink(const char *pcFile)
static const char * pcStar
static int iSleepCacheFull
int rfio_fstat(int iFileId, struct stat *pStatBuf)
int rfio_parse(char *pcFile, char **pcNode, char **pcPath)
static char rfio_errmsg[STATUS_LEN]
#define DSM_MAX_OWNER_LENGTH
int rfio_mkdir(const char *path, int mode)
void rfio_perror(const char *pUMsg)
int rfio_open_gsidaq(const char *pcFile, int iFlags, int iOpenMode, int iCopyMode, char *pcCopyPath, int iCopyFraction, int iMaxFile, int iPathConvention)
char cNodeMover[MAX_NODE]
int rfio_newfile(int iFileId, char *pcFile)
ssize_t rfio_write(int iFileId, const char *pcBuffer, size_t iItems)
char cCopyPath[MAX_FULL_FILE]
static char cNodeMover[MAX_NODE]
static int iStatusLoopMax
int rfio_cache_stat(const char *pcFile)
static char cPrefix[MAX_FULL_FILE]
RFILE * rfio_fopen(char *pcFile, char *pcOptions)
int rawSendStatus(int, int, char *)
static char cNodeMaster[MAX_NODE]
int rfio_lseek(int iFileId, int ilocOffset, int ilocSeekMode)
int rawQueryString(srawObjAttr *pQAttr, int ipMode, int iOut, char *pcOut)
int rfiosetopt(int iopt, int *pival, int ilen)
size_t rfio_fwrite(const char *pcBuffer, size_t iSize, size_t iItems, RFILE *pRemFile)
srawCopyCache sCopyCacheServ
char * rawGetHLName(char *)
int rawQueryFile(int, int, srawComm *, void **)
int rfio_fendfile(RFILE *pRemFile)
char cDataFS[MAX_FULL_FILE]
static const char * pcPerc
static char cLogClient[MAX_LOG_FILE]
static char cDataFSHigh2[16]
static char cApplType[MAX_APPLTYPE]
static char cNodePrefix[MAX_NODE]
static char cNamefs[MAX_OBJ_FS]
char cNodeMaster[MAX_NODE]
int rconnect(char *, int, int *, int *)
char * rawGetFSpName(char *)
size_t rfio_fread(char *pcBuffer, size_t iSize, size_t iItems, RFILE *pRemFile)
static char cNamehl[MAX_OBJ_HL]
int rawRecvError(int, int, char *)
static char cDataFSHigh1[16]
static char cNodeMaster0[MAX_NODE]
#define ATLSERVER_ARCHIVE
int rfio_access(const char *pcFile, int iMode)
RFILE * rfio_fopen_gsidaq_dm(char *pcFile, char *pcOptions, char *pcDataMover, int *piDataMover, int iCopyMode, char *pcCopyPath, int iCopyFraction, int iMaxFile, int iPathConvention)
char cArchiveDate[MAX_DATE]
void * rfio_readdir(void *dirp)
int rfio_close(int iFileId)
#define GSI_MEDIA_INCOMPLETE
int rfio_stat(const char *pcFile, struct stat *pStatBuf)
int rawRecvStatus(int, char *)
#define PORT_MOVER_DATAFS
static RFILE * pAPIFile[10]
int rfio_closedir(void *dirp)
static int irawFileSystem
char cArchiveUser[MAX_OWNER]
int rfio_gsi_query(int iFileId, int iFull, int iOut, char *pInfo)
void * rfio_opendir(const char *dirpath)
int rawRecvHeadC(int, char *, int, int, char *)
#define GSI_CACHE_INCOMPLETE
static const char * pcDevDelim
int rfio_fclose(RFILE *pRemFile)
RFILE * rfio_fopen_gsidaq(char *pcFile, char *pcOptions, int iCopyMode, char *pcCopyPath, int iCopyFraction, int iMaxFile, int iPathConvention)
int rfio_fnewfile(RFILE *pRemFile, char *pcFile)