Fixed compile on c7, use of __func__, output of list
This commit is contained in:
parent
d121df3dc1
commit
e3595df586
@ -2,7 +2,7 @@ TSMAPIDIR=/opt/tivoli/tsm/client/api/bin64/sample
|
|||||||
|
|
||||||
# ** For Digest Calculations, we need to link to openssl libraries, and enable USE_DIGEST in tsmpipe.h **
|
# ** For Digest Calculations, we need to link to openssl libraries, and enable USE_DIGEST in tsmpipe.h **
|
||||||
#TSMLIB=-lApiTSM64
|
#TSMLIB=-lApiTSM64
|
||||||
TSMLIB=-lApiTSM64 -lssl
|
TSMLIB=-lApiTSM64 -lssl -lcrypto
|
||||||
|
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-g -W -Wall -Wextra -O -m64 -I$(TSMAPIDIR)
|
CFLAGS=-g -W -Wall -Wextra -O -m64 -I$(TSMAPIDIR)
|
||||||
|
@ -22,7 +22,7 @@ int tsm_listfile_cb(dsmQueryType qType, DataBlk *qResp, void *userdata) {
|
|||||||
char objInfo[DSM_MAX_OBJINFO_LENGTH];
|
char objInfo[DSM_MAX_OBJINFO_LENGTH];
|
||||||
|
|
||||||
if (userdata != NULL ) {
|
if (userdata != NULL ) {
|
||||||
fprintf(stderr, "tsm_listfile_cb: Internal error: userdata != NULL");
|
debugLog(0,__func__,"ERROR: Internal error: userdata != NULL",0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ int tsm_listfile_cb(dsmQueryType qType, DataBlk *qResp, void *userdata) {
|
|||||||
|
|
||||||
printf("%40s|%2s|%s|%3s|%19s|%19s|%7.3f MB|%u-%8u",dsmObjnameToStr(respBackup.objName),state,stor,ced,dsmDateToStr(respBackup.insDate),respBackup.expDate.year ? dsmDateToStr(respBackup.expDate) : "",dsmSizeToNum(respBackup.sizeEstimate,bTrue),respBackup.objId.hi,respBackup.objId.lo);
|
printf("%40s|%2s|%s|%3s|%19s|%19s|%7.3f MB|%u-%8u",dsmObjnameToStr(respBackup.objName),state,stor,ced,dsmDateToStr(respBackup.insDate),respBackup.expDate.year ? dsmDateToStr(respBackup.expDate) : "",dsmSizeToNum(respBackup.sizeEstimate,bTrue),respBackup.objId.hi,respBackup.objId.lo);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"tsm_listfile_cb: Internal error: Unknown qType %d\n",qType);
|
fprintf(stderr,"%s: UNKNOWN Type %d\n",__func__,qType);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ char *dsmDateToStr(dsmDate date) {
|
|||||||
exit(255);
|
exit(255);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(s,0x00,sizeof(s));
|
memset(s,0x00,(sizeof s));
|
||||||
|
|
||||||
sprintf(s,"%04i-%02i-%02i %02i:%02i:%02i",
|
sprintf(s,"%04i-%02i-%02i %02i:%02i:%02i",
|
||||||
date.year,
|
date.year,
|
||||||
@ -107,7 +107,7 @@ dsmObjName dsmNameToObjname(char *fsname, char *filename) {
|
|||||||
memset(objname,0x00,sizeof(dsmObjName));
|
memset(objname,0x00,sizeof(dsmObjName));
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr,"dsmNameToObjname: FS: %s Filename: %s\n",fsname,filename);
|
fprintf(stderr,"%s: FS: %s Filename: %s\n",__func__,fsname,filename);
|
||||||
|
|
||||||
/* fs == "/filesystem", hl == "/directory/path", ll == "/filename" */
|
/* fs == "/filesystem", hl == "/directory/path", ll == "/filename" */
|
||||||
strcpy(objname->fs,fsname);
|
strcpy(objname->fs,fsname);
|
||||||
@ -145,7 +145,7 @@ char *dsmObjnameToStr(dsmObjName objName) {
|
|||||||
exit(255);
|
exit(255);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(s,0x00,sizeof(s));
|
memset(s,0x00,(sizeof s));
|
||||||
|
|
||||||
sprintf(s,"%s%s%s",objName.fs,objName.hl,objName.ll);
|
sprintf(s,"%s%s%s",objName.fs,objName.hl,objName.ll);
|
||||||
|
|
||||||
@ -154,22 +154,26 @@ char *dsmObjnameToStr(dsmObjName objName) {
|
|||||||
|
|
||||||
double dsmSizeToNum(dsStruct64_t dsStruct64,dsBool_t inMB) {
|
double dsmSizeToNum(dsStruct64_t dsStruct64,dsBool_t inMB) {
|
||||||
unsigned long long filesize;
|
unsigned long long filesize;
|
||||||
|
extern int verbose;
|
||||||
|
|
||||||
filesize = dsStruct64.hi;
|
filesize = dsStruct64.hi;
|
||||||
filesize <<= 32;
|
filesize <<= 32;
|
||||||
filesize |= dsStruct64.lo;
|
filesize |= dsStruct64.lo;
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
fprintf(stderr,"%s: Size: %d\n",__func__,(int)filesize);
|
||||||
|
|
||||||
// Return number in MB
|
// Return number in MB
|
||||||
return inMB ? (float)filesize/1024/1024 : filesize;
|
return inMB ? (double)filesize/1024/1024 : (double)filesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void debugLog(int level, _IO_FILE *output, char *message, int die) {
|
void debugLog(int level, const char *func, char *message, int die) {
|
||||||
extern int verbose;
|
extern int verbose;
|
||||||
|
|
||||||
if (level > verbose)
|
if (level > verbose)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fprintf(output,"%s\n",message);
|
fprintf(stderr,"%s: %s\n",func,message);
|
||||||
|
|
||||||
if (die)
|
if (die)
|
||||||
exit(die);
|
exit(die);
|
||||||
|
@ -33,12 +33,12 @@ int tsm_matchone_cb(dsmQueryType qType, DataBlk *qResp, void *userdata) {
|
|||||||
cbdata->copyGroup = qr->copyGroup;
|
cbdata->copyGroup = qr->copyGroup;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"tsm_matchone_cb: Internal error: Unknown qType %d\n",qType);
|
fprintf(stderr,"%s: UNKNOWN Type %d\n",__func__,qType);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cbdata->numfound > 1) {
|
if (cbdata->numfound > 1) {
|
||||||
fprintf(stderr,"tsm_matchone_cb: FAILED: The file specification matched multiple files.\n");
|
debugLog(0,__func__,"FAILED: The file specification matched multiple files.",0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,10 +48,9 @@ int tsm_matchone_cb(dsmQueryType qType, DataBlk *qResp, void *userdata) {
|
|||||||
/* Read/Write a buffer full of data from file descripter */
|
/* Read/Write a buffer full of data from file descripter */
|
||||||
ssize_t rw_full(int fd, void *buf, size_t count) {
|
ssize_t rw_full(int fd, void *buf, size_t count) {
|
||||||
ssize_t done=0;
|
ssize_t done=0;
|
||||||
|
ssize_t len=0;
|
||||||
|
|
||||||
while (count) {
|
while (count) {
|
||||||
ssize_t len;
|
|
||||||
|
|
||||||
if (fd == STDIN_FILENO) {
|
if (fd == STDIN_FILENO) {
|
||||||
len = read(fd,buf+done,count);
|
len = read(fd,buf+done,count);
|
||||||
|
|
||||||
@ -59,8 +58,7 @@ ssize_t rw_full(int fd, void *buf, size_t count) {
|
|||||||
len = write(fd,buf+done,count);
|
len = write(fd,buf+done,count);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"rw_full: rw_full: Unknown FD\n");
|
debugLog(0,__func__,"ERROR: Unknown FD",4);
|
||||||
exit(4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
@ -82,7 +80,7 @@ ssize_t rw_full(int fd, void *buf, size_t count) {
|
|||||||
done += len;
|
done += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(done);
|
return done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register a filespace in TSM */
|
/* Register a filespace in TSM */
|
||||||
@ -98,7 +96,7 @@ int tsm_regfs(dsUint32_t dsmHandle, char *fsname) {
|
|||||||
rc = dsmRegisterFS(dsmHandle,®FS);
|
rc = dsmRegisterFS(dsmHandle,®FS);
|
||||||
|
|
||||||
if (rc != DSM_RC_OK && rc != DSM_RC_FS_ALREADY_REGED) {
|
if (rc != DSM_RC_OK && rc != DSM_RC_FS_ALREADY_REGED) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_regfs: dsmRegisterFS failed");
|
printf("%s: dsmRegisterFS() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +141,7 @@ double tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long lon
|
|||||||
md = EVP_get_digestbyname(digest);
|
md = EVP_get_digestbyname(digest);
|
||||||
|
|
||||||
if (! md) {
|
if (! md) {
|
||||||
printf("tsm_sendfile: Unknown message digest %s\n", digest);
|
printf("%s: Unknown message digest %s\n",__func__,digest);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,7 +154,7 @@ double tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long lon
|
|||||||
|
|
||||||
// Warn if we wont do compression
|
// Warn if we wont do compression
|
||||||
if (verbose && compressEnabled && length <= DSM_MIN_COMPRESS_SIZE)
|
if (verbose && compressEnabled && length <= DSM_MIN_COMPRESS_SIZE)
|
||||||
fprintf(stderr,"tsm_sendfile: WARNING: Size (%i) too small for compression/de-duplication, even though it is enabled",(int)length);
|
fprintf(stderr,"%s: WARNING: Size (%i) too small for compression/de-duplication, even though it is enabled",__func__,(int)length);
|
||||||
|
|
||||||
// Log start backup
|
// Log start backup
|
||||||
if (startstop)
|
if (startstop)
|
||||||
@ -165,7 +163,7 @@ double tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long lon
|
|||||||
// Start a Transaction
|
// Start a Transaction
|
||||||
rc = dsmBeginTxn(dsmHandle);
|
rc = dsmBeginTxn(dsmHandle);
|
||||||
if (rc != DSM_RC_OK) {
|
if (rc != DSM_RC_OK) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_sendfile: dsmBeginTxn failed");
|
printf("%s: dsmBeginTxn() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,20 +171,20 @@ double tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long lon
|
|||||||
objName = dsmNameToObjname(fsname,filename);
|
objName = dsmNameToObjname(fsname,filename);
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr,"tsm_sendfile: Starting to send stdin as %s\n",dsmObjnameToStr(objName));
|
fprintf(stderr,"%s: Starting to send stdin as %s\n",__func__,dsmObjnameToStr(objName));
|
||||||
|
|
||||||
memset(&mcBindKey,0x00,sizeof(mcBindKey));
|
memset(&mcBindKey,0x00,sizeof(mcBindKey));
|
||||||
mcBindKey.stVersion = mcBindKeyVersion;
|
mcBindKey.stVersion = mcBindKeyVersion;
|
||||||
rc = dsmBindMC(dsmHandle,&objName,sendtype,&mcBindKey);
|
rc = dsmBindMC(dsmHandle,&objName,sendtype,&mcBindKey);
|
||||||
if (rc != DSM_RC_OK) {
|
if (rc != DSM_RC_OK) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_sendfile: dsmBindMC failed");
|
printf("%s: dsmBindMC() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose > 1) {
|
if (verbose > 1) {
|
||||||
char *cgdest=NULL;
|
char *cgdest=NULL;
|
||||||
|
|
||||||
fprintf(stderr,"tsm_sendfile: Bound to Management Class: %s\n",mcBindKey.mcName);
|
fprintf(stderr,"%s: Bound to Management Class: %s\n",__func__,mcBindKey.mcName);
|
||||||
|
|
||||||
if ((sendtype == stArchiveMountWait || sendtype == stArchive) && mcBindKey.archive_cg_exists) {
|
if ((sendtype == stArchiveMountWait || sendtype == stArchive) && mcBindKey.archive_cg_exists) {
|
||||||
cgdest = mcBindKey.archive_copy_dest;
|
cgdest = mcBindKey.archive_copy_dest;
|
||||||
@ -195,12 +193,12 @@ double tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long lon
|
|||||||
cgdest = mcBindKey.backup_copy_dest;
|
cgdest = mcBindKey.backup_copy_dest;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"tsm_sendfile: Internal error: Unknown qType %d\n",sendtype);
|
fprintf(stderr,"%s: UNKNOWN Type %d\n",__func__,sendtype);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cgdest)
|
if (cgdest)
|
||||||
fprintf(stderr,"tsm_sendfile: Destination Copy Group: %s\n",cgdest);
|
fprintf(stderr,"%s: Destination Copy Group: %s\n",__func__,cgdest);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&objAttr,0x00,sizeof(ObjAttr));
|
memset(&objAttr,0x00,sizeof(ObjAttr));
|
||||||
@ -222,7 +220,7 @@ double tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long lon
|
|||||||
|
|
||||||
rc = dsmSendObj(dsmHandle,sendtype,archDataP,&objName,&objAttr,NULL);
|
rc = dsmSendObj(dsmHandle,sendtype,archDataP,&objName,&objAttr,NULL);
|
||||||
if (rc != DSM_RC_OK) {
|
if (rc != DSM_RC_OK) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_sendfile: dsmSendObj failed");
|
printf("%s: dsmSendObj() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +257,7 @@ double tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long lon
|
|||||||
rc = dsmSendData(dsmHandle,&dataBlk);
|
rc = dsmSendData(dsmHandle,&dataBlk);
|
||||||
|
|
||||||
if (rc != DSM_RC_OK && rc != DSM_RC_COMPRESS_GREW) {
|
if (rc != DSM_RC_OK && rc != DSM_RC_COMPRESS_GREW) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_sendfile: dsmSendData failed");
|
printf("%s: dsmSendData() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -272,17 +270,17 @@ double tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long lon
|
|||||||
dsmEndSendObjExOut.stVersion = dsmEndSendObjExOutVersion;
|
dsmEndSendObjExOut.stVersion = dsmEndSendObjExOutVersion;
|
||||||
|
|
||||||
if ((rc = dsmEndSendObjEx(&dsmEndSendObjExIn,&dsmEndSendObjExOut)) != DSM_RC_OK) {
|
if ((rc = dsmEndSendObjEx(&dsmEndSendObjExIn,&dsmEndSendObjExOut)) != DSM_RC_OK) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_sendfile: dsmEndSendObjEx failed");
|
printf("%s: dsmEndSendObjEx() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = dsmEndTxn(dsmHandle,DSM_VOTE_COMMIT,&reason);
|
rc = dsmEndTxn(dsmHandle,DSM_VOTE_COMMIT,&reason);
|
||||||
if (rc == DSM_RC_CHECK_REASON_CODE || (rc == DSM_RC_OK && reason != DSM_RC_OK)) {
|
if (rc == DSM_RC_CHECK_REASON_CODE || (rc == DSM_RC_OK && reason != DSM_RC_OK)) {
|
||||||
tsm_printerr(dsmHandle,reason,"tsm_sendfile: dsmEndTxn failed, reason");
|
printf("%s: dsmEndTxn() failed %s\n",__func__,tsm_printerr(dsmHandle,reason));
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
} else if(rc != DSM_RC_OK) {
|
} else if(rc != DSM_RC_OK) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_sendfile: dsmEndTxn failed");
|
printf("%s: dsmEndTxn() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,7 +294,7 @@ double tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long lon
|
|||||||
|
|
||||||
digest_str[strlen(digest_str)+1] = '\0';
|
digest_str[strlen(digest_str)+1] = '\0';
|
||||||
|
|
||||||
fprintf(stdout,"%s %s (%s)",digest_str,dsmObjnameToStr(objName),digest);
|
printf("%s %s (%s)",digest_str,dsmObjnameToStr(objName),digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
objAttr.objInfo=digest_str;
|
objAttr.objInfo=digest_str;
|
||||||
@ -316,9 +314,9 @@ double tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long lon
|
|||||||
|
|
||||||
if (summary) {
|
if (summary) {
|
||||||
if (! digest)
|
if (! digest)
|
||||||
fprintf(stdout,"%s",dsmObjnameToStr(objName));
|
printf("%s",dsmObjnameToStr(objName));
|
||||||
|
|
||||||
fprintf(stdout," [%5.3f/%5.3f/%5.3f/%5.3f] (%s/%s)",
|
printf(" [%5.3f/%5.3f/%5.3f/%5.3f] (%s/%s)",
|
||||||
dsmSizeToNum(dsmEndSendObjExOut.totalBytesSent,bTrue),
|
dsmSizeToNum(dsmEndSendObjExOut.totalBytesSent,bTrue),
|
||||||
dsmEndSendObjExOut.objDeduplicated ? dsmSizeToNum(dsmEndSendObjExOut.totalDedupSize,bTrue) : 0.0,
|
dsmEndSendObjExOut.objDeduplicated ? dsmSizeToNum(dsmEndSendObjExOut.totalDedupSize,bTrue) : 0.0,
|
||||||
dsmEndSendObjExOut.objCompressed ? dsmSizeToNum(dsmEndSendObjExOut.totalCompressSize,bTrue) : 0.0,
|
dsmEndSendObjExOut.objCompressed ? dsmSizeToNum(dsmEndSendObjExOut.totalCompressSize,bTrue) : 0.0,
|
||||||
@ -328,7 +326,7 @@ double tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long lon
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (digest || summary)
|
if (digest || summary)
|
||||||
fprintf(stdout,"\n");
|
printf("\n");
|
||||||
|
|
||||||
return dsmSizeToNum(dsmEndSendObjExOut.totalBytesSent,bFalse);
|
return dsmSizeToNum(dsmEndSendObjExOut.totalBytesSent,bFalse);
|
||||||
}
|
}
|
||||||
@ -347,20 +345,20 @@ int tsm_restorefile(dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaD
|
|||||||
|
|
||||||
if (qType == qtArchive) {
|
if (qType == qtArchive) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr,"tsm_restorefile: Starting to receive %s via stdin\n",dsmObjnameToStr(*qaData.objName));
|
fprintf(stderr,"%s: Starting to receive %s via stdin\n",__func__,dsmObjnameToStr(*qaData.objName));
|
||||||
|
|
||||||
gType = gtArchive;
|
gType = gtArchive;
|
||||||
rc = tsm_queryfile(dsmHandle,qType,tsm_matchone_cb,&cbdata,qaData,qbData);
|
rc = tsm_queryfile(dsmHandle,qType,tsm_matchone_cb,&cbdata,qaData,qbData);
|
||||||
|
|
||||||
} else if (qType == qtBackup) {
|
} else if (qType == qtBackup) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr,"tsm_restorefile: Starting to receive %s via stdin\n",dsmObjnameToStr(*qbData.objName));
|
fprintf(stderr,"%s: Starting to receive %s via stdin\n",__func__,dsmObjnameToStr(*qbData.objName));
|
||||||
|
|
||||||
gType = gtBackup;
|
gType = gtBackup;
|
||||||
rc = tsm_queryfile(dsmHandle,qType,tsm_matchone_cb,&cbdata,qaData,qbData);
|
rc = tsm_queryfile(dsmHandle,qType,tsm_matchone_cb,&cbdata,qaData,qbData);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"tsm_restorefile: Internal error: Unknown qType %d\n",qType);
|
fprintf(stderr,"%s: UNKNOWN Type %d\n",__func__,qType);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,7 +366,7 @@ int tsm_restorefile(dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaD
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (cbdata.numfound == 0) {
|
if (cbdata.numfound == 0) {
|
||||||
fprintf(stderr,"tsm_restorefile: FAILED: The file specification did not match any file.\n");
|
debugLog(0,__func__,"FAILED: The file specification did not match any file.",0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,7 +378,7 @@ int tsm_restorefile(dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaD
|
|||||||
|
|
||||||
rc = dsmBeginGetData(dsmHandle,bTrue,gType,&getList);
|
rc = dsmBeginGetData(dsmHandle,bTrue,gType,&getList);
|
||||||
if (rc != DSM_RC_OK) {
|
if (rc != DSM_RC_OK) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_restorefile: dsmBeginGetData failed");
|
printf("%s: dsmBeginGetData() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,7 +406,7 @@ int tsm_restorefile(dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaD
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rc != DSM_RC_FINISHED) {
|
if (rc != DSM_RC_FINISHED) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_restorefile: dsmGetObj/dsmGetData failed");
|
printf("%s: dsmGetObj()/dsmGetData() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,13 +417,13 @@ int tsm_restorefile(dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaD
|
|||||||
|
|
||||||
rc = dsmEndGetObj(dsmHandle);
|
rc = dsmEndGetObj(dsmHandle);
|
||||||
if (rc != DSM_RC_OK) {
|
if (rc != DSM_RC_OK) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_restorefile: dsmEndGetObj failed");
|
printf("%s: dsmEndGetObj() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = dsmEndGetData(dsmHandle);
|
rc = dsmEndGetData(dsmHandle);
|
||||||
if (rc != DSM_RC_OK) {
|
if (rc != DSM_RC_OK) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_restorefile: dsmEndGetData failed");
|
printf("%s: dsmEndGetData() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,13 +447,13 @@ int tsm_deletefile(dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaDa
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cbdata.numfound == 0) {
|
if (cbdata.numfound == 0) {
|
||||||
fprintf(stderr,"tsm_deletefile: FAILED: The file specification did not match any file.\n");
|
debugLog(0,__func__,"FAILED: The file specification did not match any file.",0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qType == qtArchive) {
|
if (qType == qtArchive) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr,"tsm_deletefile: Deleting archive file %s\n",dsmObjnameToStr(*qaData.objName));
|
fprintf(stderr,"%s: Deleting archive file %s\n",__func__,dsmObjnameToStr(*qaData.objName));
|
||||||
|
|
||||||
dType = dtArchive;
|
dType = dtArchive;
|
||||||
|
|
||||||
@ -467,7 +465,7 @@ int tsm_deletefile(dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaDa
|
|||||||
|
|
||||||
} else if (qType == qtBackup) {
|
} else if (qType == qtBackup) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr,"tsm_deletefile: Deleting backup file %s\n",dsmObjnameToStr(*qbData.objName));
|
fprintf(stderr,"%s: Deleting backup file %s\n",__func__,dsmObjnameToStr(*qbData.objName));
|
||||||
|
|
||||||
dType = dtBackup;
|
dType = dtBackup;
|
||||||
|
|
||||||
@ -479,29 +477,29 @@ int tsm_deletefile(dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaDa
|
|||||||
dInfoP = (dsmDelInfo *) &dbInfo;
|
dInfoP = (dsmDelInfo *) &dbInfo;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"tsm_matchone_cb: Internal error: Unknown qType %d\n",qType);
|
fprintf(stderr,"%s: UNKNOWN Type %d\n",__func__,qType);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = dsmBeginTxn(dsmHandle);
|
rc = dsmBeginTxn(dsmHandle);
|
||||||
if (rc != DSM_RC_OK) {
|
if (rc != DSM_RC_OK) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_deletefile: dsmBeginTxn failed");
|
printf("%s: dsmBeginTxn() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = dsmDeleteObj(dsmHandle,dType,*dInfoP);
|
rc = dsmDeleteObj(dsmHandle,dType,*dInfoP);
|
||||||
if (rc != DSM_RC_OK) {
|
if (rc != DSM_RC_OK) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_deletefile: dsmDeleteObj failed");
|
printf("%s: dsmDeleteObj() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = dsmEndTxn(dsmHandle,DSM_VOTE_COMMIT,&reason);
|
rc = dsmEndTxn(dsmHandle,DSM_VOTE_COMMIT,&reason);
|
||||||
if (rc == DSM_RC_CHECK_REASON_CODE || (rc == DSM_RC_OK && reason != DSM_RC_OK)) {
|
if (rc == DSM_RC_CHECK_REASON_CODE || (rc == DSM_RC_OK && reason != DSM_RC_OK)) {
|
||||||
tsm_printerr(dsmHandle,reason,"tsm_deletefile: dsmEndTxn failed, reason");
|
printf("%s: dsmEndTxn() failed %s\n",__func__,tsm_printerr(dsmHandle,reason));
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
} else if (rc != DSM_RC_OK) {
|
} else if (rc != DSM_RC_OK) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_deletefile: dsmEndTxn failed");
|
printf("%s: dsmEndTxn() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,7 +519,7 @@ int tsm_updatefs(dsUint32_t dsmHandle, char *fsname, long long size) {
|
|||||||
rc = dsmUpdateFS(dsmHandle,fsname,&fsUpdateP,DSM_FSUPD_OCCUPANCY | DSM_FSUPD_CAPACITY);
|
rc = dsmUpdateFS(dsmHandle,fsname,&fsUpdateP,DSM_FSUPD_OCCUPANCY | DSM_FSUPD_CAPACITY);
|
||||||
|
|
||||||
if (rc != DSM_RC_OK) {
|
if (rc != DSM_RC_OK) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_updatefs: dsmUpdateFS failed");
|
printf("%s: dsmUpdateFS() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,7 +534,7 @@ int tsm_datefs(dsUint32_t dsmHandle, char *fsname, int startstop) {
|
|||||||
rc = dsmUpdateFS(dsmHandle,fsname,&fsUpdateP,startstop);
|
rc = dsmUpdateFS(dsmHandle,fsname,&fsUpdateP,startstop);
|
||||||
|
|
||||||
if (rc != DSM_RC_OK) {
|
if (rc != DSM_RC_OK) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_datefs: dsmUpdateFS failed");
|
printf("%s: dsmUpdateFS() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,8 +16,11 @@
|
|||||||
dsBool_t compressEnabled=bFalse; // Is compression enabled
|
dsBool_t compressEnabled=bFalse; // Is compression enabled
|
||||||
|
|
||||||
/* Print out TSM Error Code */
|
/* Print out TSM Error Code */
|
||||||
void tsm_printerr(dsUint32_t dsmHandle, dsInt16_t rc, char *str) {
|
char *tsm_printerr(dsUint32_t dsmHandle, dsInt16_t rc) {
|
||||||
char rcStr[DSM_MAX_RC_MSG_LENGTH];
|
char rcStr[DSM_MAX_RC_MSG_LENGTH];
|
||||||
|
char *s;
|
||||||
|
|
||||||
|
s = malloc(sizeof(rcStr));
|
||||||
|
|
||||||
if (rc == DSM_RC_WILL_ABORT) {
|
if (rc == DSM_RC_WILL_ABORT) {
|
||||||
dsUint16_t reason;
|
dsUint16_t reason;
|
||||||
@ -30,7 +33,11 @@ void tsm_printerr(dsUint32_t dsmHandle, dsInt16_t rc, char *str) {
|
|||||||
|
|
||||||
dsmRCMsg(dsmHandle,rc,rcStr);
|
dsmRCMsg(dsmHandle,rc,rcStr);
|
||||||
|
|
||||||
fprintf(stderr, "tsmpipe: %s\n (rc=%s)\n",str,rcStr);
|
strtok(rcStr, "\n");
|
||||||
|
|
||||||
|
sprintf(s,"[rc=%s]",rcStr);
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check the TSM API Version */
|
/* Check the TSM API Version */
|
||||||
@ -111,13 +118,13 @@ dsUint32_t tsm_initsess(char *options) {
|
|||||||
rc = dsmChangePW(dsmHandle,NULL,NULL);
|
rc = dsmChangePW(dsmHandle,NULL,NULL);
|
||||||
|
|
||||||
if (rc != DSM_RC_OK) {
|
if (rc != DSM_RC_OK) {
|
||||||
tsm_printerr(dsmHandle,rc,"dsmChangePW failed");
|
printf("%s: dsmChangePW() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (rc != DSM_RC_OK) {
|
} else if (rc != DSM_RC_OK) {
|
||||||
tsm_printerr(dsmHandle, rc, "dsmInitEx failed");
|
printf("%s: dsmInitEx() failed %s\n",__func__,tsm_printerr(dsmHandle, rc));
|
||||||
dsmTerminate(dsmHandle);
|
dsmTerminate(dsmHandle);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -140,9 +147,7 @@ dsUint32_t tsm_initsess(char *options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!rc || (compressEnabled && ! dsmOpt.compressalways)) {
|
if (!rc || (compressEnabled && ! dsmOpt.compressalways)) {
|
||||||
fprintf(stderr,!rc ? "Error Querying Session Capabilities" : "Error, COMPRESSion is ENABLED, but not COMPRESSAlways Yes\n");
|
debugLog(0,__func__,!rc ? "ERROR: Error Querying Session Capabilities" : "ERROR: COMPRESSion is ENABLED, but not COMPRESSAlways Yes",1);
|
||||||
fprintf(stderr,"\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return dsmHandle;
|
return dsmHandle;
|
||||||
@ -150,6 +155,7 @@ dsUint32_t tsm_initsess(char *options) {
|
|||||||
|
|
||||||
/* List objects that are in TSM */
|
/* List objects that are in TSM */
|
||||||
int tsm_sessioninfo(dsUint32_t dsmHandle) {
|
int tsm_sessioninfo(dsUint32_t dsmHandle) {
|
||||||
|
extern int verbose;
|
||||||
dsInt16_t rc=0;
|
dsInt16_t rc=0;
|
||||||
optStruct dsmOpt;
|
optStruct dsmOpt;
|
||||||
ApiSessInfo dsmSessInfo;
|
ApiSessInfo dsmSessInfo;
|
||||||
@ -180,7 +186,7 @@ int tsm_sessioninfo(dsUint32_t dsmHandle) {
|
|||||||
rc = dsmQuerySessOptions(dsmHandle, &dsmOpt);
|
rc = dsmQuerySessOptions(dsmHandle, &dsmOpt);
|
||||||
|
|
||||||
if (rc)
|
if (rc)
|
||||||
printf("dsmQuerySessOptions error on issueing Query Session Options. Rc = %d\n",rc);
|
printf("%s: ERROR dsmQuerySessOptions() unable to query Session Options. RC = %d\n",__func__,rc);
|
||||||
else {
|
else {
|
||||||
printf("dsmQuerySessOptions:\n");
|
printf("dsmQuerySessOptions:\n");
|
||||||
printf(" DSMI_DIR: %s\n",dsmOpt.dsmiDir);
|
printf(" DSMI_DIR: %s\n",dsmOpt.dsmiDir);
|
||||||
@ -191,11 +197,17 @@ int tsm_sessioninfo(dsUint32_t dsmHandle) {
|
|||||||
case DSM_COMM_TCP : strcpy(t,"TCP/IP"); break;
|
case DSM_COMM_TCP : strcpy(t,"TCP/IP"); break;
|
||||||
case DSM_COMM_NAMEDPIPE : strcpy(t,"NAMED PIPE"); break;
|
case DSM_COMM_NAMEDPIPE : strcpy(t,"NAMED PIPE"); break;
|
||||||
case DSM_COMM_SHM : strcpy(t,"SHARED MEMORY"); break;
|
case DSM_COMM_SHM : strcpy(t,"SHARED MEMORY"); break;
|
||||||
|
case 6 : strcpy(t,"TCP/IP v6"); break; // There is no DSM_COMM_ const for TCPIPv6
|
||||||
default: strcpy(t,"UNKNOWN");
|
default: strcpy(t,"UNKNOWN");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(" COMMmethod: %s\n",t);
|
printf(" COMMmethod: %s\n",t);
|
||||||
|
if (verbose)
|
||||||
|
fprintf(stderr,"%s: commMethod: [%d]\n",__func__,dsmOpt.commMethod);
|
||||||
|
|
||||||
printf(" TCPServerAddress: %s\n",dsmOpt.serverAddress);
|
printf(" TCPServerAddress: %s\n",dsmOpt.serverAddress);
|
||||||
|
if (verbose)
|
||||||
|
fprintf(stderr,"%s: serverAddress: [%s]\n",__func__,dsmOpt.serverAddress);
|
||||||
printf(" NODEName: %s\n",dsmOpt.nodeName);
|
printf(" NODEName: %s\n",dsmOpt.nodeName);
|
||||||
printf(" COMPRESSIon: %s\n",dsmOpt.compression ? "YES" : "NO");
|
printf(" COMPRESSIon: %s\n",dsmOpt.compression ? "YES" : "NO");
|
||||||
printf(" COMPRESSAlways: %s\n",dsmOpt.compressalways ? "YES" : "NO");
|
printf(" COMPRESSAlways: %s\n",dsmOpt.compressalways ? "YES" : "NO");
|
||||||
@ -207,7 +219,7 @@ int tsm_sessioninfo(dsUint32_t dsmHandle) {
|
|||||||
rc = dsmQuerySessInfo(dsmHandle, &dsmSessInfo);
|
rc = dsmQuerySessInfo(dsmHandle, &dsmSessInfo);
|
||||||
|
|
||||||
if (rc)
|
if (rc)
|
||||||
printf("dsmQuerySessOptions error on issueing Query Session Options. Rc = %d\n",rc);
|
printf("%s: ERROR dsmQuerySessInfo() unable to query Session Info. RC = %d\n",__func__,rc);
|
||||||
else {
|
else {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("dsmQuerySessInfo:\n");
|
printf("dsmQuerySessInfo:\n");
|
||||||
@ -295,7 +307,7 @@ dsInt16_t tsm_queryfile(dsUint32_t dsmHandle, dsmQueryType qType, tsm_query_call
|
|||||||
qDataP = &qaData;
|
qDataP = &qaData;
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr,"tsm_queryfile: Query filespace %s\n",dsmObjnameToStr(*qaData.objName));
|
fprintf(stderr,"%s: Query filespace %s\n",__func__,dsmObjnameToStr(*qaData.objName));
|
||||||
|
|
||||||
qryRespArchiveData qaResp;
|
qryRespArchiveData qaResp;
|
||||||
qaResp.stVersion = qryRespArchiveDataVersion;
|
qaResp.stVersion = qryRespArchiveDataVersion;
|
||||||
@ -308,10 +320,10 @@ dsInt16_t tsm_queryfile(dsUint32_t dsmHandle, dsmQueryType qType, tsm_query_call
|
|||||||
qDataP = &qbData;
|
qDataP = &qbData;
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr,"tsm_queryfile: Query filespace %s\n",dsmObjnameToStr(*qbData.objName));
|
fprintf(stderr,"%s: Query filespace %s\n",__func__,dsmObjnameToStr(*qbData.objName));
|
||||||
if (verbose > 1) {
|
if (verbose > 1) {
|
||||||
fprintf(stderr,"tsm_queryfile: PIT Date: %s\n",dsmDateToStr(qbData.pitDate));
|
fprintf(stderr,"%s: PIT Date: %s\n",__func__,dsmDateToStr(qbData.pitDate));
|
||||||
fprintf(stderr,"tsm_queryfile: OBJSTATE : %s\n",qbData.objState==DSM_ACTIVE ? "DSM_ACTIVE" : "DSM_ANY_MATCH");
|
fprintf(stderr,"%s: OBJSTATE : %s\n",__func__,qbData.objState==DSM_ACTIVE ? "DSM_ACTIVE" : "DSM_ANY_MATCH");
|
||||||
}
|
}
|
||||||
|
|
||||||
qryRespBackupData qbResp;
|
qryRespBackupData qbResp;
|
||||||
@ -322,13 +334,13 @@ dsInt16_t tsm_queryfile(dsUint32_t dsmHandle, dsmQueryType qType, tsm_query_call
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"tsm_queryfile: ERROR: Unknown qType: %d?\n",qType);
|
fprintf(stderr,"%s: UNKNOWN Type %d\n",__func__,qType);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = dsmBeginQuery(dsmHandle, qType, qDataP);
|
rc = dsmBeginQuery(dsmHandle, qType, qDataP);
|
||||||
if (rc != DSM_RC_OK) {
|
if (rc != DSM_RC_OK) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_queryfile: dsmBeginQuery failed");
|
printf("%s: dsmBeginQuery() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,12 +360,12 @@ dsInt16_t tsm_queryfile(dsUint32_t dsmHandle, dsmQueryType qType, tsm_query_call
|
|||||||
rObjName = &(qr->objName);
|
rObjName = &(qr->objName);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"tsm_queryfile: Internal error: Unknown qType %d\n",qType);
|
fprintf(stderr,"%s: UNKNOWN Type %d\n",__func__,qType);
|
||||||
|
|
||||||
return DSM_RC_UNKNOWN_ERROR;
|
return DSM_RC_UNKNOWN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr,"tsm_queryfile: Match file %s\n",dsmObjnameToStr(*rObjName));
|
fprintf(stderr,"%s: Match file %s\n",__func__,dsmObjnameToStr(*rObjName));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usercb == NULL)
|
if (usercb == NULL)
|
||||||
@ -369,13 +381,13 @@ dsInt16_t tsm_queryfile(dsUint32_t dsmHandle, dsmQueryType qType, tsm_query_call
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rc != DSM_RC_FINISHED && rc != DSM_RC_MORE_DATA) {
|
if (rc != DSM_RC_FINISHED && rc != DSM_RC_MORE_DATA) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_queryfile: dsmGetNextObj failed");
|
printf("%s: dsmGetNextObj() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = dsmEndQuery(dsmHandle);
|
rc = dsmEndQuery(dsmHandle);
|
||||||
if (rc != DSM_RC_OK) {
|
if (rc != DSM_RC_OK) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_queryfile: dsmEndQuery failed");
|
printf("%s: dsmEndQuery() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
67
tsmpipe.c
67
tsmpipe.c
@ -50,7 +50,7 @@ int copy_env(const char *from, const char *to) {
|
|||||||
|
|
||||||
e = getenv(from);
|
e = getenv(from);
|
||||||
if (!e) {
|
if (!e) {
|
||||||
fprintf(stderr,"tsmpipe: Environment variable %s not set\n",from);
|
fprintf(stderr,"%s: Environment variable %s not set\n",__func__,from);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,8 +105,7 @@ void usage(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void usage_action(void) {
|
void usage_action(void) {
|
||||||
fprintf(stderr, "tsmpipe: ERROR: Must give one of -i, -c, -x, -d, -t\n");
|
debugLog(0,__func__,"ERROR: Must give one of -i, -c, -x, -d, -t",1);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -162,54 +161,46 @@ int main(int argc, char *argv[]) {
|
|||||||
case 'N': insdate_high = optarg; break;
|
case 'N': insdate_high = optarg; break;
|
||||||
|
|
||||||
case ':':
|
case ':':
|
||||||
fprintf(stderr, "tsmpipe: Option -%c requires an operand\n", optopt);
|
fprintf(stderr,"%s: Option -%c requires an operand\n",__func__,optopt);
|
||||||
exit(1);
|
exit(1);
|
||||||
case '?':
|
case '?':
|
||||||
fprintf(stderr, "tsmpipe: Unrecognized option: -%c\n", optopt);
|
fprintf(stderr,"%s: Unrecognized option: -%c\n",__func__,optopt);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arguement Validation
|
// Arguement Validation
|
||||||
if (action == 0) {
|
if (action == 0) {
|
||||||
fprintf(stderr, "tsmpipe: ERROR: Must give one of -i, -c, -x, -d, -t\n");
|
debugLog(0,__func__,"ERROR: Must give one of -i, -c, -x, -d, -t",1);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pitdate && qType != qtBackup) {
|
if (pitdate && qType != qtBackup) {
|
||||||
fprintf(stderr, "tsmpipe: ERROR: -P can only be used with -B\n");
|
debugLog(0,__func__,"ERROR: -P can only be used with -B",1);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((insdate_low|| insdate_high || expdate_low || expdate_high) && qType != qtArchive) {
|
if ((insdate_low|| insdate_high || expdate_low || expdate_high) && qType != qtArchive) {
|
||||||
fprintf(stderr, "tsmpipe: ERROR: -e, -E, -n, -N can only be used with -A\n");
|
debugLog(0,__func__,"ERROR: -e, -E, -n, -N can only be used with -A",1);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action != ACTION_INFO) {
|
if (action != ACTION_INFO) {
|
||||||
if (! space) {
|
if (! space) {
|
||||||
fprintf(stderr, "tsmpipe: ERROR: Must give -s filespacename\n");
|
debugLog(0,__func__,"ERROR: Must give -s filespacename",1);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! filename && action != ACTION_UPDATE) {
|
if (! filename && action != ACTION_UPDATE) {
|
||||||
fprintf(stderr, "tsmpipe: ERROR: Must give -f filename\n");
|
debugLog(0,__func__,"ERROR: Must give -f filename",1);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((action == ACTION_CREATE || action == ACTION_CREATE_UPDATE || action == ACTION_UPDATE) && ! lenstr) {
|
if ((action == ACTION_CREATE || action == ACTION_CREATE_UPDATE || action == ACTION_UPDATE) && ! lenstr) {
|
||||||
fprintf(stderr, "tsmpipe: ERROR: Must give -l|-L length with -c | -u\n");
|
debugLog(0,__func__,"ERROR: Must give -l|-L length with -c | -u",1);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((action != ACTION_CREATE && action != ACTION_CREATE_UPDATE && action != ACTION_UPDATE) && lenstr) {
|
if ((action != ACTION_CREATE && action != ACTION_CREATE_UPDATE && action != ACTION_UPDATE) && lenstr) {
|
||||||
fprintf(stderr, "tsmpipe: ERROR: -l|-L length useless without -c | -u\n");
|
debugLog(0,__func__,"ERROR: -l|-L length useless without -c | -u",1);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desc && qType != qtArchive) {
|
if (desc && qType != qtArchive) {
|
||||||
fprintf(stderr, "tsmpipe: ERROR: -D desc useless without -A\n");
|
debugLog(0,__func__,"ERROR: -D desc useless without -A",1);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,18 +213,18 @@ int main(int argc, char *argv[]) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
// OK, we are ready to talk to TSM
|
// OK, we are ready to talk to TSM
|
||||||
debugLog(1,stderr,"tsmpipe: Create TSM session",0);
|
debugLog(1,__func__,"Create TSM session",0);
|
||||||
|
|
||||||
dsmHandle = tsm_initsess(options);
|
dsmHandle = tsm_initsess(options);
|
||||||
if (! dsmHandle)
|
if (! dsmHandle)
|
||||||
debugLog(0,stderr,"tsmpipe: Unable to create TSM session?",2);
|
debugLog(0,__func__,"ERROR: Unable to create TSM session?",2);
|
||||||
|
|
||||||
debugLog(2,stderr,"tsmpipe: Session Initiated",0);
|
debugLog(2,__func__,"Session Initiated",0);
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
// Show our session information
|
// Show our session information
|
||||||
case ACTION_INFO:
|
case ACTION_INFO:
|
||||||
debugLog(2,stderr,"tsmpipe: INFO Operation",0);
|
debugLog(2,__func__,"INFO Operation",0);
|
||||||
|
|
||||||
rc = tsm_sessioninfo(dsmHandle);
|
rc = tsm_sessioninfo(dsmHandle);
|
||||||
break;
|
break;
|
||||||
@ -241,11 +232,11 @@ int main(int argc, char *argv[]) {
|
|||||||
// If we are backing up or archiving
|
// If we are backing up or archiving
|
||||||
case ACTION_CREATE:
|
case ACTION_CREATE:
|
||||||
case ACTION_CREATE_UPDATE:
|
case ACTION_CREATE_UPDATE:
|
||||||
debugLog(2,stderr,"tsmpipe: CREATE Operation",0);
|
debugLog(2,__func__,"CREATE Operation",0);
|
||||||
|
|
||||||
length = atof(lenstr);
|
length = atof(lenstr);
|
||||||
if (length <= 0)
|
if (length <= 0)
|
||||||
debugLog(0,stderr,"tsmpipe: ERROR: Provide positive length, overestimate if guessing",1);
|
debugLog(0,__func__,"ERROR: Provide positive length, overestimate if guessing",1);
|
||||||
|
|
||||||
#ifdef USE_DIGEST
|
#ifdef USE_DIGEST
|
||||||
stored = tsm_sendfile(dsmHandle,space,filename,length,desc,((qType == qtArchive) ? stArchiveMountWait : stBackupMountWait),((action == ACTION_CREATE_UPDATE && qType==qtBackup) ? bTrue : bFalse),summary,digest);
|
stored = tsm_sendfile(dsmHandle,space,filename,length,desc,((qType == qtArchive) ? stArchiveMountWait : stBackupMountWait),((action == ACTION_CREATE_UPDATE && qType==qtBackup) ? bTrue : bFalse),summary,digest);
|
||||||
@ -255,7 +246,7 @@ int main(int argc, char *argv[]) {
|
|||||||
rc = stored ? 1 : 0;
|
rc = stored ? 1 : 0;
|
||||||
|
|
||||||
if (rc && action == ACTION_CREATE_UPDATE && qType==qtBackup) {
|
if (rc && action == ACTION_CREATE_UPDATE && qType==qtBackup) {
|
||||||
debugLog(2,stderr,"tsmpipe: UPDATE FS Operation",0);
|
debugLog(2,__func__,"UPDATE FS Operation",0);
|
||||||
rc = tsm_updatefs(dsmHandle,space,stored);
|
rc = tsm_updatefs(dsmHandle,space,stored);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,28 +313,28 @@ int main(int argc, char *argv[]) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"tsmpipe: UNKNOWN Type %d",qType);
|
fprintf(stderr,"%s: UNKNOWN Type %d\n",__func__,qType);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case ACTION_DELETE:
|
case ACTION_DELETE:
|
||||||
debugLog(2,stderr,"tsmpipe: DELETE Operation",0);
|
debugLog(2,__func__,"DELETE Operation",0);
|
||||||
rc = tsm_deletefile(dsmHandle,qType,qaData,qbData);
|
rc = tsm_deletefile(dsmHandle,qType,qaData,qbData);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTION_EXTRACT:
|
case ACTION_EXTRACT:
|
||||||
debugLog(2,stderr,"tsmpipe: EXTRACT Operation",0);
|
debugLog(2,__func__,"EXTRACT Operation",0);
|
||||||
rc = tsm_restorefile(dsmHandle,qType,qaData,qbData);
|
rc = tsm_restorefile(dsmHandle,qType,qaData,qbData);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTION_LIST:
|
case ACTION_LIST:
|
||||||
debugLog(2,stderr,"tsmpipe: LIST Operation",0);
|
debugLog(2,__func__,"LIST Operation",0);
|
||||||
rc = tsm_listfile(dsmHandle,qType,qaData,qbData);
|
rc = tsm_listfile(dsmHandle,qType,qaData,qbData);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"tsmpipe: Action not yet programmed for%d",action);
|
fprintf(stderr,"%s: Action not yet programmed for %d\n",__func__,action);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -351,24 +342,24 @@ int main(int argc, char *argv[]) {
|
|||||||
case ACTION_UPDATE:
|
case ACTION_UPDATE:
|
||||||
length = atof(lenstr);
|
length = atof(lenstr);
|
||||||
if (length <= 0)
|
if (length <= 0)
|
||||||
debugLog(0,stderr,"tsmpipe: ERROR: Provide positive length",1);
|
debugLog(0,__func__,"ERROR: Provide positive length",1);
|
||||||
|
|
||||||
rc = tsm_updatefs(dsmHandle,space,length);
|
rc = tsm_updatefs(dsmHandle,space,length);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"tsmpipe: UNKNOWN Operation %d",action);
|
fprintf(stderr,"%s: UNKNOWN Operation %d",__func__,action);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
debugLog(1,stderr,"tsmpipe: Terminate TSM session",0);
|
debugLog(1,__func__,"Terminate TSM session",0);
|
||||||
|
|
||||||
dsmTerminate(dsmHandle);
|
dsmTerminate(dsmHandle);
|
||||||
|
|
||||||
if (! rc)
|
if (! rc)
|
||||||
debugLog(0,stderr,"tsmpipe: Operation Failed",3);
|
debugLog(0,__func__,"ERROR: Operation Failed",3);
|
||||||
else
|
else
|
||||||
debugLog(1,stderr,"tsmpipe: Operation Success",0);
|
debugLog(1,__func__,"Operation Success",0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@ typedef int (*tsm_query_callback)(dsmQueryType, DataBlk *, void *);
|
|||||||
|
|
||||||
struct matchone_cb_data { int numfound; dsStruct64_t objId; dsUint32_t copyGroup; };
|
struct matchone_cb_data { int numfound; dsStruct64_t objId; dsUint32_t copyGroup; };
|
||||||
|
|
||||||
extern void tsm_printerr (dsUint32_t dsmHandle, dsInt16_t rc, char *str);
|
extern char *tsm_printerr (dsUint32_t dsmHandle, dsInt16_t rc);
|
||||||
extern void debugLog(int level, _IO_FILE *output, char *message, int die);
|
extern void debugLog (int level, const char *func, char *message, int die);
|
||||||
|
|
||||||
extern dsmDate dsmStrToDate(char *s);
|
extern dsmDate dsmStrToDate(char *s);
|
||||||
extern dsmObjName dsmNameToObjname(char *fsname, char *filename);
|
extern dsmObjName dsmNameToObjname(char *fsname, char *filename);
|
||||||
|
Reference in New Issue
Block a user