77 #include <sys/types.h>
78 #include <sys/statfs.h>
91 #define BUFSIZE_SMALL 80
103 char cModule[32]=
"rawGetDirEntries";
110 struct dirent *pEntry;
113 "\n-D- begin %s: FS %s\n", cModule, pcStageFS);
115 pDir = opendir(pcStageFS);
119 "-E- %s: cannot open directory %s\n", cModule, pcStageFS);
122 fprintf(
fLogFile,
" %s\n", strerror(errno));
129 while ( (pEntry = readdir(pDir)) != NULL)
131 if ( (strcmp(pEntry->d_name,
".") == 0) ||
132 (strcmp(pEntry->d_name,
"..") == 0) )
138 fprintf(
fLogFile,
" %d: %s\n", iEntries, pEntry->d_name);
141 iRC = closedir(pDir);
144 fprintf(
fLogFile,
" rc(closedir) = %d\n-D- end %s\n\n", iRC, cModule);
175 char cModule[32] =
"rawGetDirEntryList";
179 int ilen, iloc, ii, jj;
184 char cEntryType[32] =
"";
186 int iEntriesMatch = 0;
188 int iFileEntryMax = 0;
189 int iFileEntryRem = 0;
190 int iFileEntries = 0;
191 int iFileEntriesOld = 0;
192 int iFileEntriesNew = 0;
201 int iDirEntryMax = 0;
202 int iDirEntryRem = 0;
204 int iDirEntriesOld = 0;
205 int iDirEntriesNew = 0;
216 struct dirent *pEntry;
218 struct stat sEntryStatus, *pEntryStatus;
221 fprintf(
fLogFile,
"\n-D- begin %s\n", cModule);
223 pEntryStatus = &sEntryStatus;
225 if (strlen(pcDirName) <= 0)
227 fprintf(
fLogFile,
"-E- %s: empty directory name\n", cModule);
230 goto gEndDirEntryList;
233 if (iEntryType >= 10)
235 if (strlen(pcEntryMask) <= 0)
238 "-E- %s: empty mask for entry name\n", cModule);
241 goto gEndDirEntryList;
246 if (strcmp(pcEntryMask,
"*") != 0)
251 strcpy(cEntryType,
"entries");
252 else if (iEntryType == 1)
253 strcpy(cEntryType,
"files");
254 else if (iEntryType == 2)
255 strcpy(cEntryType,
"subdirs");
259 "-E- %s: invalid EntryType %d (allowed 0-2, 10-12)\n",
260 cModule, iEntryType);
263 goto gEndDirEntryList;
267 if ( (iEntryType == 0) || (iEntryType == 1) )
269 if (ppFileList == NULL)
272 "-E- %s: invalid pointer for entry list\n", cModule);
275 goto gEndDirEntryList;
278 piFileNo = (
int *) *ppFileList;
279 piFileList = piFileNo;
280 iFileEntriesOld = *piFileNo;
286 if (iFileEntriesOld) fprintf(
fLogFile,
287 " %d files already available in list:\n",
290 " still no files in list\n");
292 fprintf(
fLogFile,
" recursive file handling\n");
297 if (iFileEntriesOld) fprintf(
fLogFile,
298 "-W- %s: no entry loop, but %d files already available in list\n",
299 cModule, iFileEntriesOld);
304 psFileList0 = psFileList;
311 for (ii=1; ii<=iFileEntriesOld; ii++)
319 psFileList += iFileEntriesOld;
321 iFileEntries = iFileEntriesOld;
326 if (iFileEntriesOld > iFileEntryMax)
328 ii = iFileEntriesOld / iFileEntryMax;
332 iFileEntryRem = iFileEntryMax - iFileEntriesOld;
335 " space available for %d file entries (max %d)\n",
336 iFileEntryRem, iFileEntryMax);
341 if ( (iEntryType == 0) || (iEntryType == 2) )
343 if (ppDirList == NULL)
346 "-E- %s: invalid pointer for subdir list\n", cModule);
349 goto gEndDirEntryList;
352 piDirNo = (
int *) *ppDirList;
354 iDirEntriesOld = *piDirNo;
360 if (iDirEntriesOld) fprintf(
fLogFile,
361 " %d subdirectories already available in list:\n",
364 " still no subdirectories in list\n");
367 else if (iDirEntriesOld) fprintf(
fLogFile,
368 "-W- %s: no entry loop, but %d subdirectories available in list\n",
369 cModule, iDirEntriesOld);
373 psDirList0 = psDirList;
375 for (ii=1; ii<=iDirEntriesOld; ii++)
380 fprintf(
fLogFile,
"previous subdirs:\n");
387 iDirEntries = iDirEntriesOld;
391 if (iDirEntriesOld > iDirEntryMax)
393 ii = iDirEntriesOld / iDirEntryMax;
397 iDirEntryRem = iDirEntryMax - iDirEntriesOld;
400 " space available for %d subdir entries (max %d)\n",
401 iDirEntryRem, iDirEntryMax);
407 if ( (iEntryType == 0) && (iMatch) )
410 " provide all files matching with %s and all subdirs in directory %s\n",
411 pcEntryMask, pcDirName);
415 fprintf(
fLogFile,
" provide all %s", cEntryType);
417 " matching with %s", pcEntryMask);
418 fprintf(
fLogFile,
" in directory %s\n", pcDirName);
422 pDir = opendir(pcDirName);
426 "-E- %s: cannot open directory %s\n", cModule, pcDirName);
429 fprintf(
fLogFile,
"%s\n", strerror(errno));
434 goto gEndDirEntryList;
437 while ( (pEntry = readdir(pDir)) != NULL)
439 if ( (strcmp(pEntry->d_name,
".") == 0) ||
440 (strcmp(pEntry->d_name,
"..") == 0) )
448 if (pEntry->d_type == DT_UNKNOWN)
450 if ( (iEntries == 1) && (iDebug) ) fprintf(
fLogFile,
451 " %s: of type DT_UNKNOWN (1st entry)\n",
454 strcpy(cTemp, pcDirName);
456 strcat(cTemp, pEntry->d_name);
458 iRC = stat(cTemp, pEntryStatus);
463 fprintf(
fLogFile,
"-E- stat %s: %s\n",
464 cTemp, strerror(errno));
467 if (strcmp(strerror(errno),
468 "Value too large for defined data type") == 0)
471 "-E- %s: filesize of %s > 2 GByte: use 64 bit gStore client\n",
480 "-W- %s: entry %s unavailable\n", cModule, pEntry->d_name);
485 if (S_ISREG(pEntryStatus->st_mode))
487 else if (S_ISDIR(pEntryStatus->st_mode))
492 "-W- %s: entry %s neither file nor directory, ignored\n",
493 cModule, pEntry->d_name);
502 if ( (pEntry->d_type == DT_REG) || (iTypeFound == 1) )
504 if ( (iEntryType == 0) || (iEntryType == 1) )
512 else if ( (pEntry->d_type == DT_DIR) || (iTypeFound == 2) )
514 if ( (iEntryType == 0) || (iEntryType == 2) )
516 if ( (iMatch) && (iEntryType == 2) )
524 " %d: entry %s (check %d, store %d, type %d) \n",
525 iEntries, pEntry->d_name, iCheck, iStore, pEntry->d_type);
531 if (fnmatch(pcEntryMask, pEntry->d_name, 0) == 0)
543 if ( (pEntry->d_type == DT_REG) ||
544 (pEntry->d_type == DT_UNKNOWN) )
548 strcpy(psFileList->
cFile, pcDirName);
549 strcat(psFileList->
cFile,
"/");
550 strcat(psFileList->
cFile, pEntry->d_name);
553 strcpy(psFileList->
cFile, pEntry->d_name);
560 if (iFileEntriesNew == 1)
563 iFileEntriesNew, iFileEntries, psFileList->
cFile);
566 if (iFileEntryRem <= 0)
579 ii =
sizeof(int) + iFileEntryMax*
iFileList;
580 if ((pcFileList2 = (
char *) calloc((
unsigned) ii, 1)) == NULL)
583 "-E- %s: allocating new filelist buffer (%d byte, %d entries)\n",
584 cModule, ii, iFileEntryMax);
587 fprintf(
fLogFile,
" %s\n", strerror(errno));
592 goto gEndDirEntryList;
596 " new filelist buffer allocated (%d byte, %d entries)\n",
599 iFileEntryRem = iFileEntryMax - iFileEntries;
600 piFileList2 = (
int *) pcFileList2;
601 *piFileList2 = iFileEntries;
602 *ppFileList = (
char *) piFileList2;
606 memcpy(piFileList2, piFileList, ii);
609 psFileList0 = psFileList;
612 " %d filelist entries copied, first %s\n",
613 iFileEntries, psFileList->
cFile);
616 psFileList += iFileEntries;
617 piFileList = piFileList2;
619 piFileNo = piFileList2;
630 if (pEntry->d_type == DT_DIR)
632 strcpy(psDirList->
cFile, pEntry->d_name);
639 if (iDirEntriesNew == 1)
640 fprintf(
fLogFile,
"new subdirs:\n");
642 iDirEntriesNew, iDirEntries, psDirList->
cFile);
645 if (iDirEntryRem <= 0)
647 fprintf(
fLogFile,
"DDD2 new space must be allocated\n");
657 iRC = closedir(pDir);
660 fprintf(
fLogFile,
" rc(closedir) = %d\n", iRC);
662 if ( (iDebug) || (iEntryLoop != 2) )
665 " %d entries in directory %s found\n",
666 iEntries, pcDirName);
668 " %d matching with %s\n", iEntriesMatch, pcEntryMask);
674 " thereof %d files (%d new)\n",
675 iFileEntries, iFileEntriesNew);
677 " thereof %d subdirectories (%d new)\n",
678 iDirEntries, iDirEntriesNew);
681 if ( (iEntryType == 0) || (iEntryType == 1) )
682 *piFileNo = iFileEntries;
683 if ( (iEntryType == 0) || (iEntryType == 2) )
684 *piDirNo = iDirEntries;
689 " %d files provided in list, first %s\n",
690 iFileEntries, psFileList0->
cFile);
691 else if ( (iEntryType == 0) || (iEntryType == 1) )
693 fprintf(
fLogFile,
" no files in %s found",
696 " matching with %s\n", pcEntryMask);
702 " %d subdirs provided in list, first %s\n",
703 iDirEntries, psDirList0->
cFile);
704 else if ( (iEntryType == 0) || (iEntryType == 2) )
706 fprintf(
fLogFile,
" no subdirs in %s found",
708 if ( (iMatch) && (iEntryType == 2) ) fprintf(
fLogFile,
709 " matching with %s\n", pcEntryMask);
718 fprintf(
fLogFile,
"\n-D- end %s\n\n", cModule);
724 return iEntriesMatch;
741 char cModule[32]=
"rawGetFSEntries";
748 struct dirent **fEntryList;
751 "\n-D- begin %s: FS %s\n", cModule, pcStageFS);
753 iRC = scandir(pcStageFS, &fEntryList, NULL, NULL);
757 "-E- %s: calling system function scandir, rc=%d\n",
761 fprintf(
fLogFile,
" %s\n", strerror(errno));
769 for (ii=0; ii<iRC; ii++)
772 " %d: %s\n", ii, fEntryList[ii]->d_name);
774 if ( (strcmp(fEntryList[ii]->d_name,
".") == 0) ||
775 (strcmp(fEntryList[ii]->d_name,
"..") == 0) )
782 fprintf(
fLogFile,
"-D- end %s\n\n", cModule);
797 char cModule[32]=
"rawGetFSfree";
801 unsigned int itemsize, itemno;
809 char cCmd[256] =
"/home/rawserv/rawdf.sh ";
816 strcpy(cTempFile, pcStageFS);
820 sprintf(cName,
"/size.t%d.p%d", (
int) tTime, pstr);
821 strcat(cTempFile, pName);
823 strcat(cCmd, pcStageFS);
825 strcat(cCmd, cTempFile);
828 fprintf(
fLogFile,
"\n-D- begin %s: execute\n '%s'\n",
836 fprintf(
fLogFile,
"-W- %s: system() failed, rc = %d\n",
844 " shell command successfully executed\n");
849 fprintf(
fLogFile,
"-W- %s: system() not available\n",
855 fPipe = fopen(cTempFile,
"r");
858 fprintf(
fLogFile,
"-E- %s: opening file %s\n",
862 fprintf(
fLogFile,
" %s\n", strerror(errno));
870 fprintf(
fLogFile,
" file %s opened\n", cTempFile);
872 itemsize =
sizeof(char);
874 iBuf = fread(pBuf, itemsize, itemno, fPipe);
877 fprintf(
fLogFile,
"-E- %s: fread, rc = %d\n", cModule, iBuf);
880 fprintf(
fLogFile,
" %s\n", strerror(errno));
884 fprintf(
fLogFile,
" NO status buffer sent\n");
892 fprintf(
fLogFile,
" %d bytes in file: %s", iBuf, pBuf);
893 fprintf(
fLogFile,
" free kB: %d\n", iFree);
900 fprintf(
fLogFile,
"-E- %s: rc = %d closing file\n",
904 fprintf(
fLogFile,
" %s\n", strerror(errno));
912 fprintf(
fLogFile,
" file %s closed\n", cTempFile);
914 iRC =
remove(cTempFile);
917 fprintf(
fLogFile,
"-E- %s: rc = %d removing file %s\n",
918 cModule, iRC, cTempFile);
921 fprintf(
fLogFile,
" %s\n", strerror(errno));
928 fprintf(
fLogFile,
" file %s removed\n", cTempFile);
931 fprintf(
fLogFile,
"-D- end %s\n\n", cModule);
954 char cModule[32] =
"rawGetFSSpace";
965 struct statfs sFSstatus, *pFSstatus;
968 "\n-D- begin %s: FS %s\n", cModule, pcFileSystem);
970 pFSstatus = &sFSstatus;
972 iRC = statfs(pcFileSystem, pFSstatus);
976 "-E- %s: calling system function statfs, rc=%d\n",
980 fprintf(
fLogFile,
" %s\n", strerror(errno));
987 iBlockSize = (int) pFSstatus->f_bsize;
991 "-W- unexpected blocksize found: 0 byte\n");
997 " blocksize found %d byte\n", iBlockSize);
998 if (iBlockSize >= 1024)
1003 "-W- unexpected blocksize found: %d byte\n", iBlockSize);
1009 iSizeAll = (int) (pFSstatus->f_blocks/1000)*iBlockSize;
1010 iSizeFree = (int) (pFSstatus->f_bfree/1000)*iBlockSize;
1011 iSizeAvail = (int) (pFSstatus->f_bavail/1000)*iBlockSize;
1013 iNodeAll = (int) pFSstatus->f_files;
1014 iNodeAvail = (
int) pFSstatus->f_ffree;
1019 " overall space %d MB, free %d MB, available %d MB\n",
1020 iSizeAll, iSizeFree, iSizeAvail);
1022 " overall file nodes %d, available %d\n",
1023 iNodeAll, iNodeAvail);
1026 *piSizeAll = iSizeAll;
1027 *piSizeAvail = iSizeAvail;
1028 *piNodeAll = iNodeAll;
1029 *piNodeAvail = iNodeAvail;
1032 fprintf(
fLogFile,
"-D- end %s\n\n", cModule);
1047 char cModule[32] =
"rawGetFileAttr";
1052 unsigned long lFileSize;
1060 char cCmd[
CMDLEN] =
"ls -l ";
1062 const char *pType =
"r";
1064 const char *pcDollar =
"$";
1068 const char *pcblank =
" ";
1077 "\n-D- begin %s: file %s\n", cModule, pcFile);
1084 ploc = strchr(pcFile, *pcDollar);
1089 fprintf(
fLogFile,
"-D- $ in file name found: %s\n", pcFile);
1092 ilen = strlen(pcFile);
1094 for (ii = 1; ii <= ilen; ii++)
1096 iloc = strncmp(pcc, pcDollar, 1);
1097 if (iloc == 0) strncat(cCmd,
"\\", 1);
1098 strncat(cCmd, pcc++, 1);
1101 else strcat(cCmd, pcFile);
1105 fprintf(
fLogFile,
"-D- %s: ex '%s'\n", cModule, cCmd);
1110 f_ifile = popen(pCmd, pType);
1111 if (f_ifile == NULL)
1113 fprintf(
fLogFile,
"-E- %s: opening pipe\n", cModule);
1118 fprintf(
fLogFile,
" %s: pipe opened\n", cModule);
1122 if ( !(pBuf0 = (
char *) malloc(
BUFSIZE)) )
1124 fprintf(
fLogFile,
"-E- %s: allocation buffer failed\n", cModule);
1130 fprintf(
fLogFile,
" %s: buffer allocated\n", cModule);
1135 lr = fread(pBuf,
sizeof(
char),
BUFSIZE, f_ifile);
1138 fprintf(
fLogFile,
"-E- %s: reading from pipe failed\n", cModule);
1144 strncpy(pBuf,
"\0", 1);
1148 fprintf(
fLogFile,
" %s: complete string: (%lu bytes): \n%s\n",
1149 cModule, lr, pBuf0);
1154 while ( (pctoken = strtok(pBuf, pcblank)) != NULL)
1159 fprintf(
fLogFile,
" token %d: %s\n", icount, pctoken);
1167 iRC = strcmp(pctoken,
".kshrc");
1170 fprintf(
fLogFile,
" %s: token %d: %s found\n",
1171 cModule, icount, pctoken);
1177 if (icount == ilocSize)
1183 if ( ( iRC = sscanf( pctoken,
"%lu", &lFileSize) ) <= 0 )
1185 fprintf(
fLogFile,
"-E- %s: filesize %lu (%s) invalid\n",
1186 cModule, lFileSize, pctoken);
1189 fprintf(
fLogFile,
" %s\n", strerror(errno));
1198 fprintf(
fLogFile,
" file size %lu\n", lFileSize);
1202 if ( (lFileSize == 0) && (iDebug) )
1203 fprintf(
fLogFile,
" file %s empty\n", pcFile);
1208 "-E- %s: file %s too large (%lu byte), max allowed 2GB -1\n",
1209 cModule, pcFile, lFileSize);
1215 if (icount == ilocFile)
1217 if ( (iRC = strcmp(pctoken, pcFile) ) != 0)
1220 "-E- %s: file name check: %s\n", cModule, pctoken);
1236 *plFileSize = lFileSize;
1239 fprintf(
fLogFile,
"-D- end %s\n\n", cModule);
1259 char cModule[32] =
"rawGetFileList";
1265 int ilen, iloc, ii, jj;
1266 int ird, ipc, ipc1, irem, grem = 0;
1267 int iFileno, iFilenoo;
1271 char *pcc, *pcc0, *ploc;
1276 char cCmd[
CMDLEN] =
"ls -L ";
1282 const char *pcDollar =
"$";
1291 fprintf(
fLogFile,
"\n-D- begin %s\n", cModule);
1293 ploc = strchr(pcFile, *pcDollar);
1297 fprintf(
fLogFile,
" '$' in file name found: %s\n", pcFile);
1298 ilen = strlen(pcFile);
1300 for (ii=1; ii<=ilen; ii++)
1302 iloc = strncmp(pcc, pcDollar, 1);
1303 if (iloc == 0) strncat(cCmd,
"\\", 1);
1304 strncat(cCmd, pcc++, 1);
1307 else strcat(cCmd, pcFile);
1308 strcat(cCmd,
" 2>/dev/null");
1311 fprintf(
fLogFile,
" command: %s\n", cCmd);
1313 piFileList = (
int *) *ppFileList;
1314 piFileno = piFileList++;
1315 iFilenoo = *piFileno;
1317 psFileList0 = psFileList;
1322 " %d old files in list\n", iFilenoo);
1324 for (ii=1; ii<=iFilenoo; ii++)
1327 " %d (old): %s\n", ii, psFileList->
cFile);
1333 f_ifile = popen(pCmd,
"r");
1334 if (f_ifile == NULL)
1336 fprintf(
fLogFile,
"-E- %s: opening pipe\n", cModule);
1339 if (iDebug) fprintf(
fLogFile,
" pipe opened\n");
1341 if ( !(pBuf = (
char *) malloc(
BUFSIZE)) )
1344 "-E- %s: allocation buffer failed\n", cModule);
1349 fprintf(
fLogFile,
" buffer allocated\n");
1358 lr = fread(pBuf,
sizeof(
char),
BUFSIZE, f_ifile);
1366 fprintf(
fLogFile,
"-D- received %d bytes:\n", ird);
1372 ipc = strcspn(pcc0,
"\n");
1373 irem = strlen(pcc0);
1374 pcc = strchr(pcc0,
'\n');
1376 "\n first length %d, total %d, remainder %d\n",
1383 strncat(cBuf, pcc0, (
unsigned) ipc);
1385 " last concatenated: %s\n", cBuf);
1391 if (strncmp(&(cBuf[ii-1]),
":", 1) == 0)
1394 "\n stop checking, ignore subdirectory %s\n",
1400 if ( (strcmp(cBuf,
"./")) &&
1402 (strncmp(&(cBuf[ii-1]),
":", 1)) )
1407 ( (iRC == 1) && (iAccept >= 1) ) )
1411 psFileList0c = psFileList0;
1414 for (jj=1; jj<=iFilenoo; jj++)
1416 iRC = strcmp(cBuf, psFileList0c->
cFile);
1421 " entry %s already available(1)\n",
1431 strcpy(psFileList->
cFile, cBuf);
1434 " %s stored(1), addr %p\n",
1435 psFileList->
cFile, psFileList);
1445 "-E- %s: List of files for archive/retrieve currently limited to %d entries\n",
1446 cModule, --iFileno);
1448 " %s: NOT ALL files handled\n",
1458 "-W- file name %s has uppercase letters - ignored\n",
1465 "-W- directory %s ignored\n", cBuf);
1470 memset(&cBuf,
'\0', strlen(cBuf));
1475 strncpy(cBuf, pcc0, (
unsigned) ipc);
1477 if (irem - ipc == 0)
1479 ipc1 = strlen(cBuf);
1481 " grem set, cBuf: %s (%d byte) \n", cBuf, ipc1);
1489 if (strncmp(&(cBuf[ii-1]),
":", 1) == 0)
1492 "\n stop checking, ignore subdirectory %s\n",
1498 if ( (strcmp(cBuf,
"./")) &&
1500 (strncmp(&(cBuf[ii-1]),
":", 1)) )
1505 ( (iRC == 1) && (iAccept >= 1) ) )
1509 psFileList0c = psFileList0;
1512 for (jj=1; jj<=iFilenoo; jj++)
1514 if (ipc == (
int) strlen(psFileList0c->
cFile))
1517 psFileList0c->
cFile,
1523 " entry %s already available(2)\n",
1534 strncpy(psFileList->
cFile, cBuf, (
unsigned) ipc);
1538 " %s stored(2), addr %p\n",
1539 psFileList->
cFile, psFileList);
1548 "-E- %s: List of files for archive/retrieve currently limited to %d entries\n",
1549 cModule, --iFileno);
1551 " %s: NOT ALL files handled\n",
1561 "-W- file name %s has uppercase letters - ignored\n",
1567 "-W- directory %s ignored\n", cBuf);
1571 memset(&cBuf,
'\0', strlen(cBuf));
1588 fprintf(
fLogFile,
"-I- no (new) files found\n");
1589 else if (iFileno > 1)
1590 fprintf(
fLogFile,
"-I- %d (new) files found\n", iFileno);
1593 if ( (iDebug) && (iFileno) )
1597 for (ii=1; ii<=iFilenoo; ii++)
1600 " %d (old): %s\n", ii, psFileList->
cFile); psFileList++;
1602 for (ii=iFilenoo+1; ii<=iFilenoo+iFileno; ii++)
1605 " %d: %s\n", ii, psFileList->
cFile); psFileList++;
1609 iFileno += iFilenoo;
1610 piFileno[0] = iFileno;
1612 iRC = pclose(f_ifile);
1617 fprintf(
fLogFile,
"-E- %s: iRC = %d closing pipe\n",
1621 fprintf(
fLogFile,
" %s\n", strerror(errno));
1626 fprintf(
fLogFile,
" pipe closed\n");
1628 fprintf(
fLogFile,
"-D- end %s\n\n", cModule);
1649 char cModule[32] =
"rawGetHostConn";
1662 char cToken[16] =
"", *pToken;
1663 char cheadName[16], *pheadName;
1664 char cheadMtu[16] =
"mtu", *pheadMtu;
1665 char cName[16] =
"", *pName;
1666 char cMtu[16] =
"", *pMtu;
1667 char cNameRef1[16] =
"";
1668 char cNameRef2[16] =
"";
1670 char cCmd[
CMDLEN] =
"netstat -i", *pCmd;
1671 char cBuf[1024] =
"", *pBuf;
1677 fprintf(
fLogFile,
"\n-D- in %s\n", cModule);
1680 strcpy(cheadName,
"name");
1682 strcpy(cheadName,
"iface");
1685 iRC = gethostname(cNode,
MAX_NODE);
1689 "-E- %s: getting client host name: %s\n",
1690 cModule, strerror(iRC));
1694 " %s: client host %s\n", cModule, cNode);
1696 if (strncmp(cNode,
"lx", 2) == 0)
1698 if (strncmp(cNode,
"linux", 5) == 0)
1700 if (strncmp(cNode,
"sp2", 3) == 0)
1703 pToken = &cToken[0];
1704 pheadName = &cheadName[0];
1705 pheadMtu = &cheadMtu[0];
1711 f_ifile = popen(pCmd,
"r");
1712 if (f_ifile == NULL)
1714 fprintf(
fLogFile,
"-E- %s: opening pipe\n", cModule);
1718 fprintf(
fLogFile,
" %s: pipe opened\n", cModule);
1720 iBuf = fread(pBuf,
sizeof(
char), 1024, f_ifile);
1723 fprintf(
fLogFile,
"-E- %s: reading from pipe failed\n", cModule);
1728 fprintf(
fLogFile,
" %s command output: \n%s", cModule, cBuf);
1730 pToken = strtok(pBuf,
" \n");
1732 while (*pcc !=
'\0')
1734 *pcc = tolower(*pcc);
1738 if (strcmp(pToken, pheadName))
1740 fprintf(
fLogFile,
"-E- %s: invalid name heading (%s, expected %s)\n",
1741 cModule, pToken, pheadName);
1745 pToken = strtok(NULL,
" \n");
1747 while (*pcc !=
'\0')
1749 *pcc = tolower(*pcc);
1753 if (strcmp(pToken, pheadMtu))
1755 fprintf(
fLogFile,
"-E- %s: invalid mtu heading (%s, expected %s)\n",
1756 cModule, pToken, pheadMtu);
1762 strcpy(cNameRef1,
"en0");
1763 strcpy(cNameRef2,
"fi0");
1767 strcpy(cNameRef1,
"eth0");
1768 strcpy(cNameRef2,
"fdd0");
1771 for (ii=1; ii<=iCol-2; ii++)
1772 { pToken = strtok(NULL,
" \n"); }
1776 pToken = strtok(NULL,
" \n");
1777 if (pToken == NULL)
break;
1779 while (*pcc !=
'\0')
1781 *pcc = tolower(*pcc);
1786 fprintf(
fLogFile,
"DDD %s: %s\n", cModule, pToken);
1788 if (strcmp(pToken, cNameRef1) == 0)
1792 fprintf(
fLogFile,
" %s: ethernet available\n", cModule);
1794 else if (strcmp(pToken, cNameRef2) == 0)
1802 if ( (iType != 3) && (iType != 1) )
1805 "-E- %s: invalid network connection type (%d)\n",
1810 fprintf(
fLogFile,
"-D- end %s: network connection type %d\n\n",
1829 char cModule[32] =
"rawGetUserid";
1835 char cCmd[
CMDLEN] =
"whoami";
1840 f_ifile = popen(pCmd,
"r");
1841 if (f_ifile == NULL)
1843 fprintf(
fLogFile,
"-E- %s: opening pipe\n", cModule);
1847 fprintf(
fLogFile,
" %s: pipe opened\n", cModule);
1849 if ( !(pBuf0 = (
char *) malloc(
BUFSIZE)) )
1851 fprintf(
fLogFile,
"-E- %s: allocation buffer failed\n", cModule);
1856 fprintf(
fLogFile,
" %s: buffer allocated\n", cModule);
1859 lr = fread(pBuf,
sizeof(
char),
BUFSIZE, f_ifile);
1862 fprintf(
fLogFile,
"-E- %s: reading from pipe failed\n", cModule);
1868 strncpy(pBuf,
"\0", 1);
1873 "-D- %s: user name (%lu bytes): %s\n", cModule, lr, pBuf0);
int rawGetDirEntryList(char *pcDirName, char *pcEntryMask, int iEntryType, int iEntryLoop, int iPrefixDir, char **ppFileList, char **ppDirList)
int rawTestFileName(char *)
int rawGetFileAttr(char *pcFile, unsigned long *plFileSize)
int rawGetFileList(char *pcFile, int iAccept, int iEntryLoop, char **ppFileList)
int rawGetFSSpace(char *pcFileSystem, int *piSizeAll, int *piSizeAvail, int *piNodeAll, int *piNodeAvail)
char cFile[MAX_FULL_FILE]
function if(typeof JSROOT!="object")
int rawGetFSEntries(char *pcStageFS)
int rawGetDirEntries(char *pcStageFS)
int rawGetFSfree(char *pcStageFS)