Added version, moved exten to .h, and major internal rework
This commit is contained in:
parent
367f265d52
commit
2fd647af8d
@ -1,19 +1,15 @@
|
|||||||
TSMAPIDIR=/opt/tivoli/tsm/client/api/bin/sample
|
TSMAPIDIR=/opt/tivoli/tsm/client/api/bin/sample
|
||||||
TSMLIB=-lApiDS
|
TSMLIB=-lApiDS
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-g -W -Wall -Wextra -m32 -O -I$(TSMAPIDIR)
|
CFLAGS=-g -W -Wall -Wextra -O -m32 -I$(TSMAPIDIR)
|
||||||
LDFLAGS=
|
LDFLAGS=
|
||||||
|
|
||||||
FILES=tsmpipe.c
|
|
||||||
|
|
||||||
|
|
||||||
all: tsmpipe
|
all: tsmpipe
|
||||||
|
|
||||||
tsmpipe: tsmpipe.o lib/dsmobjects.o lib/dsmsession.o lib/dsmlist.o lib/dsmsendrecv.o
|
tsmpipe: tsmpipe.o lib/dsmobjects.o lib/dsmsession.o lib/dsmlist.o lib/dsmsendrecv.o
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ $(TSMLIB) -lm
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ $(TSMLIB) -lm
|
||||||
|
|
||||||
tsmpipe.c:
|
tsmpipe.c:
|
||||||
echo 'hello'
|
|
||||||
$(CC) $(CFLAGS) -c -o $(@:.c=.o) $@ $(TSMLIB)
|
$(CC) $(CFLAGS) -c -o $(@:.c=.o) $@ $(TSMLIB)
|
||||||
|
|
||||||
lib/dsmlist:
|
lib/dsmlist:
|
||||||
@ -29,4 +25,4 @@ lib/dsmobjects:
|
|||||||
$(CC) $(CFLAGS) -c -o lib/$@.o lib/$@.c $(TSMLIB)
|
$(CC) $(CFLAGS) -c -o lib/$@.o lib/$@.c $(TSMLIB)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm tsmpipe *.o lib/*.o
|
rm -f tsmpipe *.o lib/*.o
|
||||||
|
@ -10,7 +10,6 @@ tsmpipe: tsmpipe.o lib/dsmobjects.o lib/dsmsession.o lib/dsmlist.o lib/dsmsendre
|
|||||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ $(TSMLIB) -lm
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ $(TSMLIB) -lm
|
||||||
|
|
||||||
tsmpipe.c:
|
tsmpipe.c:
|
||||||
echo 'hello'
|
|
||||||
$(CC) $(CFLAGS) -c -o $(@:.c=.o) $@ $(TSMLIB)
|
$(CC) $(CFLAGS) -c -o $(@:.c=.o) $@ $(TSMLIB)
|
||||||
|
|
||||||
lib/dsmlist:
|
lib/dsmlist:
|
||||||
@ -26,4 +25,4 @@ lib/dsmobjects:
|
|||||||
$(CC) $(CFLAGS) -c -o lib/$@.o lib/$@.c $(TSMLIB)
|
$(CC) $(CFLAGS) -c -o lib/$@.o lib/$@.c $(TSMLIB)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm tsmpipe *.o lib/*.o
|
rm -f tsmpipe *.o lib/*.o
|
||||||
|
@ -12,12 +12,6 @@
|
|||||||
|
|
||||||
dsBool_t headerPrinted=bFalse; // Have we rendered the heading row yet
|
dsBool_t headerPrinted=bFalse; // Have we rendered the heading row yet
|
||||||
|
|
||||||
extern char *dsmDateToStr(dsmDate date);
|
|
||||||
extern char *dsmObjnameToStr(dsmObjName objName);
|
|
||||||
extern double dsmSizeToNum(dsStruct64_t dsStruct64);
|
|
||||||
extern dsmObjName dsmNameToObjname(char *fsname, char *filename, int verbose);
|
|
||||||
extern dsInt16_t tsm_queryfile(dsUint32_t sesshandle, dsmObjName *objName, char *description, dsmSendType sendtype, char verbose, tsm_query_callback usercb, void * userdata, char *pitdate, int querytype);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Our Callback to show what is in TSM
|
* Our Callback to show what is in TSM
|
||||||
*/
|
*/
|
||||||
@ -26,9 +20,6 @@ int tsm_listfile_cb(dsmQueryType qType, DataBlk *qResp, void *userdata) {
|
|||||||
char state[3];
|
char state[3];
|
||||||
char ced[4];
|
char ced[4];
|
||||||
|
|
||||||
qryRespBackupData respBackup;
|
|
||||||
qryRespArchiveData respArchive;
|
|
||||||
|
|
||||||
if (userdata != NULL ) {
|
if (userdata != NULL ) {
|
||||||
fprintf(stderr, "tsm_listfile_cb: Internal error: userdate != NULL");
|
fprintf(stderr, "tsm_listfile_cb: Internal error: userdate != NULL");
|
||||||
return -1;
|
return -1;
|
||||||
@ -48,6 +39,7 @@ int tsm_listfile_cb(dsmQueryType qType, DataBlk *qResp, void *userdata) {
|
|||||||
"DESC"
|
"DESC"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
qryRespArchiveData respArchive;
|
||||||
memset(&respArchive,0x00,sizeof(qryRespArchiveData));
|
memset(&respArchive,0x00,sizeof(qryRespArchiveData));
|
||||||
qryRespArchiveData *qr = (void *) qResp->bufferPtr;
|
qryRespArchiveData *qr = (void *) qResp->bufferPtr;
|
||||||
respArchive = *qr;
|
respArchive = *qr;
|
||||||
@ -56,14 +48,14 @@ int tsm_listfile_cb(dsmQueryType qType, DataBlk *qResp, void *userdata) {
|
|||||||
switch (respArchive.objName.objType) {
|
switch (respArchive.objName.objType) {
|
||||||
case (DSM_OBJ_FILE) : strcpy(state,"F"); break;
|
case (DSM_OBJ_FILE) : strcpy(state,"F"); break;
|
||||||
case (DSM_OBJ_DIRECTORY) : strcpy(state,"D"); break;
|
case (DSM_OBJ_DIRECTORY) : strcpy(state,"D"); break;
|
||||||
default : strcpy(state,"?");
|
default: strcpy(state,"?");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Location
|
// Location
|
||||||
switch (respArchive.mediaClass) {
|
switch (respArchive.mediaClass) {
|
||||||
case (MEDIA_FIXED) : strcpy(stor,"D"); break;
|
case (MEDIA_FIXED) : strcpy(stor,"D"); break;
|
||||||
case (MEDIA_LIBRARY) : strcpy(stor,"T"); break;
|
case (MEDIA_LIBRARY) : strcpy(stor,"T"); break;
|
||||||
default : strcpy(stor,"?");
|
default: strcpy(stor,"?");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compression, Encryption, De-Duplication
|
// Compression, Encryption, De-Duplication
|
||||||
@ -78,7 +70,7 @@ int tsm_listfile_cb(dsmQueryType qType, DataBlk *qResp, void *userdata) {
|
|||||||
// The Object Status
|
// The Object Status
|
||||||
printf("%40s|%2s|%s|%3s|%19s|%19s|%7.3f MB|%u-%u|%s\n",dsmObjnameToStr(respArchive.objName),state,stor,ced,dsmDateToStr(respArchive.insDate),respArchive.expDate.year ? dsmDateToStr(respArchive.expDate) : "",dsmSizeToNum(respArchive.sizeEstimate),respArchive.objId.hi,respArchive.objId.lo,respArchive.descr);
|
printf("%40s|%2s|%s|%3s|%19s|%19s|%7.3f MB|%u-%u|%s\n",dsmObjnameToStr(respArchive.objName),state,stor,ced,dsmDateToStr(respArchive.insDate),respArchive.expDate.year ? dsmDateToStr(respArchive.expDate) : "",dsmSizeToNum(respArchive.sizeEstimate),respArchive.objId.hi,respArchive.objId.lo,respArchive.descr);
|
||||||
|
|
||||||
} else if (qType ==qtBackup) {
|
} else if (qType == qtBackup) {
|
||||||
if (! headerPrinted++)
|
if (! headerPrinted++)
|
||||||
printf("%40s %2s %s %3s %19s %19s %10s %s\n",
|
printf("%40s %2s %s %3s %19s %19s %10s %s\n",
|
||||||
"NAME",
|
"NAME",
|
||||||
@ -91,6 +83,7 @@ int tsm_listfile_cb(dsmQueryType qType, DataBlk *qResp, void *userdata) {
|
|||||||
"ID"
|
"ID"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
qryRespBackupData respBackup;
|
||||||
memset(&respBackup,0x00,sizeof(qryRespBackupData));
|
memset(&respBackup,0x00,sizeof(qryRespBackupData));
|
||||||
qryRespBackupData *qr = (void *) qResp->bufferPtr;
|
qryRespBackupData *qr = (void *) qResp->bufferPtr;
|
||||||
respBackup = *qr;
|
respBackup = *qr;
|
||||||
@ -99,20 +92,20 @@ int tsm_listfile_cb(dsmQueryType qType, DataBlk *qResp, void *userdata) {
|
|||||||
switch (respBackup.objName.objType) {
|
switch (respBackup.objName.objType) {
|
||||||
case (DSM_OBJ_FILE) : strcpy(state,"F"); break;
|
case (DSM_OBJ_FILE) : strcpy(state,"F"); break;
|
||||||
case (DSM_OBJ_DIRECTORY) : strcpy(state,"D"); break;
|
case (DSM_OBJ_DIRECTORY) : strcpy(state,"D"); break;
|
||||||
default : strcpy(state,"?");
|
default: strcpy(state,"?");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (respBackup.objState) {
|
switch (respBackup.objState) {
|
||||||
case (DSM_ACTIVE) : strcat(state,"A"); break;
|
case (DSM_ACTIVE) : strcat(state,"A"); break;
|
||||||
case (DSM_INACTIVE) : strcat(state,"I"); break;
|
case (DSM_INACTIVE) : strcat(state,"I"); break;
|
||||||
default : strcat(state,"?");
|
default: strcat(state,"?");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Location
|
// Location
|
||||||
switch (respBackup.mediaClass) {
|
switch (respBackup.mediaClass) {
|
||||||
case (MEDIA_FIXED) : strcpy(stor,"D"); break;
|
case (MEDIA_FIXED) : strcpy(stor,"D"); break;
|
||||||
case (MEDIA_LIBRARY) : strcpy(stor,"T"); break;
|
case (MEDIA_LIBRARY) : strcpy(stor,"T"); break;
|
||||||
default : strcpy(stor,"?");
|
default: strcpy(stor,"?");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compression, Encryption, De-Duplication
|
// Compression, Encryption, De-Duplication
|
||||||
@ -128,7 +121,6 @@ int tsm_listfile_cb(dsmQueryType qType, DataBlk *qResp, void *userdata) {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"tsm_listfile_cb: Internal error: Unknown qType %d\n",qType);
|
fprintf(stderr,"tsm_listfile_cb: Internal error: Unknown qType %d\n",qType);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,13 +130,10 @@ int tsm_listfile_cb(dsmQueryType qType, DataBlk *qResp, void *userdata) {
|
|||||||
/*
|
/*
|
||||||
* List objects that are in TSM
|
* List objects that are in TSM
|
||||||
*/
|
*/
|
||||||
int tsm_listfile(dsUint32_t sesshandle, char *fsname, char *filename, char *description, dsmSendType sendtype, char verbose, char *pitdate) {
|
int tsm_listfile(dsUint32_t sesshandle, dsmQueryType qType, qryArchiveData qaData, qryBackupData qbData, int verbose) {
|
||||||
dsInt16_t rc=0;
|
dsInt16_t rc=0;
|
||||||
dsmObjName objName;
|
|
||||||
|
|
||||||
objName = dsmNameToObjname(fsname,filename,verbose);
|
rc = tsm_queryfile(sesshandle,qType,tsm_listfile_cb,NULL,qaData,qbData,verbose);
|
||||||
|
|
||||||
rc = tsm_queryfile(sesshandle, &objName, description, sendtype, verbose, tsm_listfile_cb, NULL, pitdate, DSM_ANY_MATCH);
|
|
||||||
|
|
||||||
if (rc != DSM_RC_OK && rc != DSM_RC_ABORT_NO_MATCH)
|
if (rc != DSM_RC_OK && rc != DSM_RC_ABORT_NO_MATCH)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -28,15 +28,7 @@
|
|||||||
|
|
||||||
#include "../tsmpipe.h"
|
#include "../tsmpipe.h"
|
||||||
|
|
||||||
extern dsBool_t compressEnabled;
|
int tsm_matchone_cb(dsmQueryType qType, DataBlk *qResp, void *userdata) {
|
||||||
|
|
||||||
extern void tsm_printerr(dsUint32_t dsmHandle, dsInt16_t rc, char *str);
|
|
||||||
extern char *dsmObjnameToStr(dsmObjName objName);
|
|
||||||
extern double dsmSizeToNum(dsStruct64_t dsStruct64);
|
|
||||||
extern dsmObjName dsmNameToObjname(char *fsname, char *filename, int verbose);
|
|
||||||
extern dsInt16_t tsm_queryfile(dsUint32_t dsmHandle, dsmObjName *objName, char *description, dsmSendType sendtype, char verbose, tsm_query_callback usercb, void * userdata, char *pitdate, int querytype);
|
|
||||||
|
|
||||||
int tsm_matchone_cb(dsmQueryType qType, DataBlk *qResp, void * userdata) {
|
|
||||||
struct matchone_cb_data *cbdata = userdata;
|
struct matchone_cb_data *cbdata = userdata;
|
||||||
|
|
||||||
cbdata->numfound++;
|
cbdata->numfound++;
|
||||||
@ -58,8 +50,7 @@ int tsm_matchone_cb(dsmQueryType qType, DataBlk *qResp, void * userdata) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cbdata->numfound > 1) {
|
if (cbdata->numfound > 1) {
|
||||||
fprintf(stderr,"tsmpipe: FAILED: The file specification matched multiple files.\n");
|
fprintf(stderr,"tsm_matchone_cb: FAILED: The file specification matched multiple files.\n");
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +118,7 @@ int tsm_regfs(dsUint32_t dsmHandle, char *fsname) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send data to TSM for storage */
|
/* Send data to TSM for storage */
|
||||||
int tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long long length, char *description, dsmSendType sendtype, char verbose) {
|
int tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long long length, char *description, dsmSendType sendtype, int verbose) {
|
||||||
char *buffer;
|
char *buffer;
|
||||||
dsInt16_t rc=0;
|
dsInt16_t rc=0;
|
||||||
dsmObjName objName;
|
dsmObjName objName;
|
||||||
@ -183,8 +174,12 @@ int tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long long l
|
|||||||
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;
|
||||||
|
|
||||||
} else if(mcBindKey.backup_cg_exists) {
|
} else if ((sendtype == stBackupMountWait || sendtype == stBackup) && mcBindKey.backup_cg_exists) {
|
||||||
cgdest = mcBindKey.backup_copy_dest;
|
cgdest = mcBindKey.backup_copy_dest;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fprintf(stderr,"tsm_sendfile: Internal error: Unknown qType %d\n",sendtype);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cgdest)
|
if (cgdest)
|
||||||
@ -221,8 +216,9 @@ int tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long long l
|
|||||||
nbytes = rw_full(STDIN_FILENO,buffer,BUFLEN);
|
nbytes = rw_full(STDIN_FILENO,buffer,BUFLEN);
|
||||||
|
|
||||||
if (nbytes < 0) {
|
if (nbytes < 0) {
|
||||||
perror("tsmpipe: read");
|
perror("tsm_sendmail: read");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
} else if (nbytes == 0) {
|
} else if (nbytes == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -234,7 +230,7 @@ int tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long long l
|
|||||||
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_senfile: dsmSendData failed");
|
tsm_printerr(dsmHandle,rc,"tsm_sendfile: dsmSendData failed");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -281,27 +277,34 @@ int tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long long l
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get data from TSM for restore */
|
/* Get data from TSM for restore */
|
||||||
int tsm_restorefile(dsUint32_t dsmHandle, char *fsname, char *filename, char *description, dsmSendType sendtype, char verbose, char *pitdate) {
|
int tsm_restorefile(dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaData, qryBackupData qbData, int verbose) {
|
||||||
dsInt16_t rc=0;
|
dsInt16_t rc=0;
|
||||||
struct matchone_cb_data cbdata;
|
struct matchone_cb_data cbdata;
|
||||||
dsmObjName objName;
|
|
||||||
dsmGetList getList;
|
dsmGetList getList;
|
||||||
dsmGetType getType;
|
|
||||||
DataBlk dataBlk;
|
DataBlk dataBlk;
|
||||||
|
dsmGetType gType;
|
||||||
objName = dsmNameToObjname(fsname,filename,verbose);
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
fprintf(stderr,"tsm_restorefile: Starting to receive %s via stdin\n",dsmObjnameToStr(objName));
|
|
||||||
|
|
||||||
memset(&cbdata,0x00,sizeof(cbdata));
|
memset(&cbdata,0x00,sizeof(cbdata));
|
||||||
cbdata.numfound = 0;
|
cbdata.numfound = 0;
|
||||||
|
|
||||||
// Retrieve a list based on the PITDATE or if no PITDATE, the last ACTIVE
|
if (qType == qtArchive) {
|
||||||
if (sendtype == stBackupMountWait)
|
if (verbose)
|
||||||
rc = tsm_queryfile(dsmHandle,&objName,description,sendtype,verbose,tsm_matchone_cb,&cbdata,pitdate,pitdate ? DSM_ANY_MATCH : DSM_ACTIVE);
|
fprintf(stderr,"tsm_restorefile: Starting to receive %s via stdin\n",dsmObjnameToStr(*qaData.objName));
|
||||||
else
|
|
||||||
rc = tsm_queryfile(dsmHandle,&objName,description,sendtype,verbose,tsm_matchone_cb,&cbdata,NULL,0);
|
gType = gtArchive;
|
||||||
|
rc = tsm_queryfile(dsmHandle,qType,tsm_matchone_cb,&cbdata,qaData,qbData,verbose);
|
||||||
|
|
||||||
|
} else if (qType == qtBackup) {
|
||||||
|
if (verbose)
|
||||||
|
fprintf(stderr,"tsm_restorefile: Starting to receive %s via stdin\n",dsmObjnameToStr(*qbData.objName));
|
||||||
|
|
||||||
|
gType = gtBackup;
|
||||||
|
rc = tsm_queryfile(dsmHandle,qType,tsm_matchone_cb,&cbdata,qaData,qbData,verbose);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fprintf(stderr,"tsm_restorefile: Internal error: Unknown qType %d\n",qType);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (rc != DSM_RC_OK)
|
if (rc != DSM_RC_OK)
|
||||||
return 0;
|
return 0;
|
||||||
@ -317,13 +320,7 @@ int tsm_restorefile(dsUint32_t dsmHandle, char *fsname, char *filename, char *de
|
|||||||
getList.objId = &cbdata.objId;
|
getList.objId = &cbdata.objId;
|
||||||
getList.partialObjData = NULL;
|
getList.partialObjData = NULL;
|
||||||
|
|
||||||
if (sendtype == stArchiveMountWait || sendtype == stArchive) {
|
rc = dsmBeginGetData(dsmHandle,bTrue,gType,&getList);
|
||||||
getType = gtArchive;
|
|
||||||
} else {
|
|
||||||
getType = gtBackup;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = dsmBeginGetData(dsmHandle,bTrue,getType,&getList);
|
|
||||||
if (rc != DSM_RC_OK) {
|
if (rc != DSM_RC_OK) {
|
||||||
tsm_printerr(dsmHandle,rc,"tsm_restorefile: dsmBeginGetData failed");
|
tsm_printerr(dsmHandle,rc,"tsm_restorefile: dsmBeginGetData failed");
|
||||||
return 0;
|
return 0;
|
||||||
@ -378,24 +375,16 @@ int tsm_restorefile(dsUint32_t dsmHandle, char *fsname, char *filename, char *de
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Delete data in TSM */
|
/* Delete data in TSM */
|
||||||
int tsm_deletefile(dsUint32_t dsmHandle, char *fsname, char *filename, char *description, dsmSendType sendtype, char verbose) {
|
int tsm_deletefile(dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaData, qryBackupData qbData, int verbose) {
|
||||||
dsInt16_t rc=0;
|
dsInt16_t rc=0;
|
||||||
dsUint16_t reason=0;
|
dsUint16_t reason=0;
|
||||||
dsmDelInfo *dInfoP;
|
dsmDelInfo *dInfoP;
|
||||||
dsmDelType dType;
|
dsmDelType dType;
|
||||||
struct matchone_cb_data cbdata;
|
struct matchone_cb_data cbdata;
|
||||||
delArch daInfo;
|
|
||||||
delBack dbInfo;
|
|
||||||
dsmObjName objName;
|
|
||||||
|
|
||||||
objName = dsmNameToObjname(fsname,filename,verbose);
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
fprintf(stderr,"tsm_deletefile: Deleting file %s\n",dsmObjnameToStr(objName));
|
|
||||||
|
|
||||||
cbdata.numfound = 0;
|
cbdata.numfound = 0;
|
||||||
|
|
||||||
rc = tsm_queryfile(dsmHandle,&objName,description,sendtype,verbose,tsm_matchone_cb,&cbdata,NULL,DSM_ACTIVE);
|
rc = tsm_queryfile(dsmHandle,qType,tsm_matchone_cb,&cbdata,qaData,qbData,verbose);
|
||||||
if (rc != DSM_RC_OK) {
|
if (rc != DSM_RC_OK) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -405,21 +394,34 @@ int tsm_deletefile(dsUint32_t dsmHandle, char *fsname, char *filename, char *des
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sendtype == stArchiveMountWait || sendtype == stArchive) {
|
if (qType == qtArchive) {
|
||||||
|
if (verbose)
|
||||||
|
fprintf(stderr,"tsm_deletefile: Deleting archive file %s\n",dsmObjnameToStr(*qaData.objName));
|
||||||
|
|
||||||
dType = dtArchive;
|
dType = dtArchive;
|
||||||
|
|
||||||
|
delArch daInfo;
|
||||||
daInfo.stVersion = delArchVersion;
|
daInfo.stVersion = delArchVersion;
|
||||||
daInfo.objId = cbdata.objId;
|
daInfo.objId = cbdata.objId;
|
||||||
|
|
||||||
dInfoP = (dsmDelInfo *) &daInfo;
|
dInfoP = (dsmDelInfo *) &daInfo;
|
||||||
} else {
|
|
||||||
|
} else if (qType == qtBackup) {
|
||||||
|
if (verbose)
|
||||||
|
fprintf(stderr,"tsm_deletefile: Deleting backup file %s\n",dsmObjnameToStr(*qbData.objName));
|
||||||
|
|
||||||
dType = dtBackup;
|
dType = dtBackup;
|
||||||
|
|
||||||
|
delBack dbInfo;
|
||||||
dbInfo.stVersion = delBackVersion;
|
dbInfo.stVersion = delBackVersion;
|
||||||
dbInfo.objNameP = &objName;
|
dbInfo.objNameP = qbData.objName;
|
||||||
dbInfo.copyGroup = cbdata.copyGroup;
|
dbInfo.copyGroup = cbdata.copyGroup;
|
||||||
|
|
||||||
dInfoP = (dsmDelInfo *) &dbInfo;
|
dInfoP = (dsmDelInfo *) &dbInfo;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fprintf(stderr,"tsm_matchone_cb: Internal error: Unknown qType %d\n",qType);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = dsmBeginTxn(dsmHandle);
|
rc = dsmBeginTxn(dsmHandle);
|
||||||
|
119
lib/dsmsession.c
119
lib/dsmsession.c
@ -15,10 +15,6 @@
|
|||||||
|
|
||||||
dsBool_t compressEnabled=bFalse; // Is compression enabled
|
dsBool_t compressEnabled=bFalse; // Is compression enabled
|
||||||
|
|
||||||
extern char *dsmDateToStr(dsmDate date);
|
|
||||||
extern dsmDate dsmStrToDate(char *s,int verbose);
|
|
||||||
extern char *dsmObjnameToStr(dsmObjName objName);
|
|
||||||
|
|
||||||
/* Print out TSM Error Code */
|
/* Print out TSM Error Code */
|
||||||
void tsm_printerr(dsUint32_t dsmHandle, dsInt16_t rc, char *str) {
|
void tsm_printerr(dsUint32_t dsmHandle, dsInt16_t rc, char *str) {
|
||||||
char rcStr[DSM_MAX_RC_MSG_LENGTH];
|
char rcStr[DSM_MAX_RC_MSG_LENGTH];
|
||||||
@ -140,7 +136,7 @@ dsUint32_t tsm_initsess(char *options) {
|
|||||||
case COMPRESS_YES : compressEnabled = bTrue; break;
|
case COMPRESS_YES : compressEnabled = bTrue; break;
|
||||||
case COMPRESS_NO : compressEnabled = bFalse; break;
|
case COMPRESS_NO : compressEnabled = bFalse; break;
|
||||||
case COMPRESS_CD : compressEnabled = dsmOpt.compression; break;
|
case COMPRESS_CD : compressEnabled = dsmOpt.compression; break;
|
||||||
default : rc=0;
|
default: rc=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rc || (compressEnabled && ! dsmOpt.compressalways)) {
|
if (!rc || (compressEnabled && ! dsmOpt.compressalways)) {
|
||||||
@ -165,6 +161,8 @@ void tsm_sessioninfo(dsUint32_t dsmHandle) {
|
|||||||
dsmQueryApiVersionEx(&apiLibVer);
|
dsmQueryApiVersionEx(&apiLibVer);
|
||||||
|
|
||||||
printf("Application Version:\n");
|
printf("Application Version:\n");
|
||||||
|
printf(" TSMPIPE Version: %s\n",
|
||||||
|
_TSMPIPE_VERSION);
|
||||||
printf(" TSMPIPE API Version: %d.%d.%d.%d\n",
|
printf(" TSMPIPE API Version: %d.%d.%d.%d\n",
|
||||||
DSM_API_VERSION,
|
DSM_API_VERSION,
|
||||||
DSM_API_RELEASE,
|
DSM_API_RELEASE,
|
||||||
@ -188,7 +186,15 @@ void tsm_sessioninfo(dsUint32_t dsmHandle) {
|
|||||||
printf(" DSMI_DIR: %s\n",dsmOpt.dsmiDir);
|
printf(" DSMI_DIR: %s\n",dsmOpt.dsmiDir);
|
||||||
printf(" DSMI_CONFIG: %s\n",dsmOpt.dsmiConfig);
|
printf(" DSMI_CONFIG: %s\n",dsmOpt.dsmiConfig);
|
||||||
printf(" SErvername: %s\n",dsmOpt.serverName);
|
printf(" SErvername: %s\n",dsmOpt.serverName);
|
||||||
printf(" COMMmethod: %d\n",dsmOpt.commMethod);
|
|
||||||
|
switch (dsmOpt.commMethod) {
|
||||||
|
case DSM_COMM_TCP : strcpy(t,"TCP/IP"); break;
|
||||||
|
case DSM_COMM_NAMEDPIPE : strcpy(t,"NAMED PIPE"); break;
|
||||||
|
case DSM_COMM_SHM : strcpy(t,"SHARED MEMORY"); break;
|
||||||
|
default: strcpy(t,"UNKNOWN");
|
||||||
|
}
|
||||||
|
printf(" COMMmethod: %s\n",t);
|
||||||
|
|
||||||
printf(" TCPServerAddress: %s\n",dsmOpt.serverAddress);
|
printf(" TCPServerAddress: %s\n",dsmOpt.serverAddress);
|
||||||
printf(" NODEName: %s\n",dsmOpt.nodeName);
|
printf(" NODEName: %s\n",dsmOpt.nodeName);
|
||||||
printf(" COMPRESSIon: %d\n",dsmOpt.compression);
|
printf(" COMPRESSIon: %d\n",dsmOpt.compression);
|
||||||
@ -228,21 +234,21 @@ void tsm_sessioninfo(dsUint32_t dsmHandle) {
|
|||||||
case COMPRESS_YES : strcpy(t,"ON"); break;
|
case COMPRESS_YES : strcpy(t,"ON"); break;
|
||||||
case COMPRESS_NO : strcpy(t,"OFF"); break;
|
case COMPRESS_NO : strcpy(t,"OFF"); break;
|
||||||
case COMPRESS_CD : strcpy(t,"CLIENT"); break;
|
case COMPRESS_CD : strcpy(t,"CLIENT"); break;
|
||||||
default : strcpy(t,"UNKNOWN");
|
default: strcpy(t,"UNKNOWN");
|
||||||
}
|
}
|
||||||
printf(" Client compression: %s\n",t);
|
printf(" Client compression: %s\n",t);
|
||||||
|
|
||||||
switch (dsmSessInfo.archDel) {
|
switch (dsmSessInfo.archDel) {
|
||||||
case ARCHDEL_YES : strcpy(t,"YES"); break;
|
case ARCHDEL_YES : strcpy(t,"YES"); break;
|
||||||
case ARCHDEL_NO : strcpy(t,"NO"); break;
|
case ARCHDEL_NO : strcpy(t,"NO"); break;
|
||||||
default : strcpy(t,"UNKNOWN");
|
default: strcpy(t,"UNKNOWN");
|
||||||
}
|
}
|
||||||
printf(" ARCHIVE Delete: %s\n",t);
|
printf(" ARCHIVE Delete: %s\n",t);
|
||||||
|
|
||||||
switch (dsmSessInfo.backDel) {
|
switch (dsmSessInfo.backDel) {
|
||||||
case BACKDEL_YES : strcpy(t,"YES"); break;
|
case BACKDEL_YES : strcpy(t,"YES"); break;
|
||||||
case ARCHDEL_NO : strcpy(t,"NO"); break;
|
case ARCHDEL_NO : strcpy(t,"NO"); break;
|
||||||
default : strcpy(t,"UNKNOWN");
|
default: strcpy(t,"UNKNOWN");
|
||||||
}
|
}
|
||||||
printf(" BACKUP delete: %s\n",t);
|
printf(" BACKUP delete: %s\n",t);
|
||||||
|
|
||||||
@ -261,6 +267,7 @@ void tsm_sessioninfo(dsUint32_t dsmHandle) {
|
|||||||
printf(" Default management class: %s\n",dsmSessInfo.dfltMCName);
|
printf(" Default management class: %s\n",dsmSessInfo.dfltMCName);
|
||||||
printf(" BACKUP retention grace: %u days\n",dsmSessInfo.gpBackRetn);
|
printf(" BACKUP retention grace: %u days\n",dsmSessInfo.gpBackRetn);
|
||||||
printf(" ARCHIVE retention grace: %u days\n",dsmSessInfo.gpArchRetn);
|
printf(" ARCHIVE retention grace: %u days\n",dsmSessInfo.gpArchRetn);
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,68 +279,48 @@ void tsm_sessioninfo(dsUint32_t dsmHandle) {
|
|||||||
* 0 if tsm_queryfile() should skip processing the remaining matches.
|
* 0 if tsm_queryfile() should skip processing the remaining matches.
|
||||||
* 1 otherwise.
|
* 1 otherwise.
|
||||||
*/
|
*/
|
||||||
dsInt16_t tsm_queryfile(dsUint32_t dsmHandle, dsmObjName *objName, char *description, dsmSendType sendtype, char verbose, tsm_query_callback usercb, void * userdata, char *pitdate, int querytype) {
|
dsInt16_t tsm_queryfile(dsUint32_t dsmHandle, dsmQueryType qType, tsm_query_callback usercb, void *userdata, qryArchiveData qaData, qryBackupData qbData, int verbose) {
|
||||||
dsInt16_t rc=0;
|
dsInt16_t rc=0;
|
||||||
DataBlk qResp;
|
|
||||||
dsmQueryType qType;
|
|
||||||
qryArchiveData qaData;
|
|
||||||
qryRespArchiveData qaResp;
|
|
||||||
qryBackupData qbData;
|
|
||||||
qryRespBackupData qbResp;
|
|
||||||
dsmQueryBuff *qDataP;
|
dsmQueryBuff *qDataP;
|
||||||
|
|
||||||
if (verbose)
|
DataBlk qResp;
|
||||||
fprintf(stderr,"tsm_queryfile: Query filespace %s\n",dsmObjnameToStr(*objName));
|
|
||||||
|
|
||||||
memset(&qResp,0x00,sizeof(DataBlk));
|
memset(&qResp,0x00,sizeof(DataBlk));
|
||||||
qResp.stVersion = DataBlkVersion;
|
qResp.stVersion = DataBlkVersion;
|
||||||
|
|
||||||
if (sendtype == stArchiveMountWait || sendtype == stArchive) {
|
switch (qType) {
|
||||||
qType = qtArchive;
|
case qtArchive:
|
||||||
|
qDataP = &qaData;
|
||||||
|
|
||||||
memset(&qaData,0x00,sizeof(qryArchiveData));
|
if (verbose)
|
||||||
qaData.stVersion = qryArchiveDataVersion;
|
fprintf(stderr,"tsm_queryfile: Query filespace %s\n",dsmObjnameToStr(*qaData.objName));
|
||||||
qaData.objName = objName;
|
|
||||||
qaData.owner = "";
|
qryRespArchiveData qaResp;
|
||||||
if (pitdate) {
|
qaResp.stVersion = qryRespArchiveDataVersion;
|
||||||
fprintf(stderr,"tsm_queryfile: Archive Date Range Query not yet setup\n");
|
|
||||||
|
qResp.bufferPtr = (char *) &qaResp;
|
||||||
|
qResp.bufferLen = sizeof(qaResp);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case qtBackup:
|
||||||
|
qDataP = &qbData;
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
fprintf(stderr,"tsm_queryfile: Query filespace %s\n",dsmObjnameToStr(*qbData.objName));
|
||||||
|
if (verbose > 1) {
|
||||||
|
fprintf(stderr,"tsm_queryfile: PIT Date: %s\n",dsmDateToStr(qbData.pitDate));
|
||||||
|
fprintf(stderr,"tsm_queryfile: OBJSTATE : %s\n",qbData.objState==DSM_ACTIVE ? "DSM_ACTIVE" : "DSM_ANY_MATCH");
|
||||||
|
}
|
||||||
|
|
||||||
|
qryRespBackupData qbResp;
|
||||||
|
qbResp.stVersion = qryRespBackupDataVersion;
|
||||||
|
|
||||||
|
qResp.bufferPtr = (char *) &qbResp;
|
||||||
|
qResp.bufferLen = sizeof(qbResp);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf(stderr,"tsm_queryfile: ERROR: Unknown qType: %d?\n",qType);
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
|
||||||
qaData.insDateLowerBound.year = DATE_MINUS_INFINITE;
|
|
||||||
qaData.insDateUpperBound.year = DATE_PLUS_INFINITE;
|
|
||||||
qaData.expDateLowerBound.year = DATE_MINUS_INFINITE;
|
|
||||||
qaData.expDateUpperBound.year = DATE_PLUS_INFINITE;
|
|
||||||
}
|
|
||||||
qaData.descr = description ? description : "*";
|
|
||||||
|
|
||||||
qDataP = &qaData;
|
|
||||||
|
|
||||||
qaResp.stVersion = qryRespArchiveDataVersion;
|
|
||||||
|
|
||||||
qResp.bufferPtr = (char *) &qaResp;
|
|
||||||
qResp.bufferLen = sizeof(qaResp);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
qType = qtBackup;
|
|
||||||
|
|
||||||
memset(&qbData,0x00,sizeof(qryBackupData));
|
|
||||||
qbData.stVersion = qryBackupDataVersion;
|
|
||||||
qbData.objName = objName;
|
|
||||||
qbData.owner = "";
|
|
||||||
qbData.objState = querytype;
|
|
||||||
|
|
||||||
if (pitdate) {
|
|
||||||
qbData.pitDate = dsmStrToDate(pitdate,verbose);
|
|
||||||
} else {
|
|
||||||
qbData.pitDate.year = DATE_MINUS_INFINITE;
|
|
||||||
}
|
|
||||||
|
|
||||||
qDataP = &qbData;
|
|
||||||
|
|
||||||
qbResp.stVersion = qryRespBackupDataVersion;
|
|
||||||
|
|
||||||
qResp.bufferPtr = (char *) &qbResp;
|
|
||||||
qResp.bufferLen = sizeof(qbResp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = dsmBeginQuery(dsmHandle, qType, qDataP);
|
rc = dsmBeginQuery(dsmHandle, qType, qDataP);
|
||||||
@ -349,11 +336,11 @@ dsInt16_t tsm_queryfile(dsUint32_t dsmHandle, dsmObjName *objName, char *descrip
|
|||||||
if(verbose > 1) {
|
if(verbose > 1) {
|
||||||
dsmObjName *rObjName;
|
dsmObjName *rObjName;
|
||||||
|
|
||||||
if(qType == qtArchive) {
|
if (qType == qtArchive) {
|
||||||
qryRespArchiveData *qr = (void *) qResp.bufferPtr;
|
qryRespArchiveData *qr = (void *) qResp.bufferPtr;
|
||||||
rObjName = &(qr->objName);
|
rObjName = &(qr->objName);
|
||||||
|
|
||||||
} else if(qType == qtBackup) {
|
} else if (qType == qtBackup) {
|
||||||
qryRespBackupData *qr = (void *) qResp.bufferPtr;
|
qryRespBackupData *qr = (void *) qResp.bufferPtr;
|
||||||
rObjName = &(qr->objName);
|
rObjName = &(qr->objName);
|
||||||
|
|
||||||
@ -379,7 +366,7 @@ dsInt16_t tsm_queryfile(dsUint32_t dsmHandle, dsmObjName *objName, char *descrip
|
|||||||
}
|
}
|
||||||
|
|
||||||
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");
|
tsm_printerr(dsmHandle,rc,"tsm_queryfile: dsmGetNextObj failed");
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
143
tsmpipe.c
143
tsmpipe.c
@ -36,13 +36,7 @@ SOFTWARE.
|
|||||||
#include "dsmrc.h"
|
#include "dsmrc.h"
|
||||||
#include "dsmapitd.h"
|
#include "dsmapitd.h"
|
||||||
#include "dsmapifp.h"
|
#include "dsmapifp.h"
|
||||||
|
#include "tsmpipe.h"
|
||||||
extern dsUint32_t tsm_initsess(char *options);
|
|
||||||
extern void tsm_sessioninfo(dsUint32_t dsmHandle);
|
|
||||||
extern int tsm_listfile(dsUint32_t dsmHandle, char *fsname, char *filename, char *description, dsmSendType sendtype, char verbose, char *pitdate);
|
|
||||||
extern int tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long long length, char *description, dsmSendType sendtype, char verbose);
|
|
||||||
extern int tsm_restorefile(dsUint32_t dsmHandle, char *fsname, char *filename, char *description, dsmSendType sendtype, char verbose, char *pitdate);
|
|
||||||
extern int tsm_deletefile(dsUint32_t dsmHandle, char *fsname, char *filename, char *description, dsmSendType sendtype, char verbose);
|
|
||||||
|
|
||||||
int copy_env(const char *from, const char *to) {
|
int copy_env(const char *from, const char *to) {
|
||||||
char *e;
|
char *e;
|
||||||
@ -67,7 +61,7 @@ int copy_env(const char *from, const char *to) {
|
|||||||
|
|
||||||
void usage(void) {
|
void usage(void) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"tsmpipe $Revision: 1.5-dg $, usage:\n"
|
"tsmpipe %s, usage:\n"
|
||||||
"\n"
|
"\n"
|
||||||
"tsmpipe [-i] [-A|-B] [-c|-x|-d|-t] -s fsname -f filepath [-l len]\n"
|
"tsmpipe [-i] [-A|-B] [-c|-x|-d|-t] -s fsname -f filepath [-l len]\n"
|
||||||
" -i Show session information:\n"
|
" -i Show session information:\n"
|
||||||
@ -88,7 +82,7 @@ void usage(void) {
|
|||||||
" -P pitdate PITDate (mmddYYYY) (BACKUP Objects)\n"
|
" -P pitdate PITDate (mmddYYYY) (BACKUP Objects)\n"
|
||||||
" -O options Extra options to pass to dsmInitEx\n"
|
" -O options Extra options to pass to dsmInitEx\n"
|
||||||
" -v Verbose. More -v's gives more verbosity\n"
|
" -v Verbose. More -v's gives more verbosity\n"
|
||||||
);
|
,_TSMPIPE_VERSION);
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -97,11 +91,12 @@ int main(int argc, char *argv[]) {
|
|||||||
int c;
|
int c;
|
||||||
extern int optopt;
|
extern int optopt;
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
char archive=0, backup=0, create=0, xtract=0, delete=0, verbose=0, info=0, list=0;
|
char archive=0, backup=0, create=0, xtract=0, delete=0, info=0, list=0;
|
||||||
|
int verbose=0;
|
||||||
char *space=NULL, *filename=NULL, *lenstr=NULL, *desc=NULL, *pitdate=NULL, *options=NULL;
|
char *space=NULL, *filename=NULL, *lenstr=NULL, *desc=NULL, *pitdate=NULL, *options=NULL;
|
||||||
off_t length;
|
off_t length;
|
||||||
dsUint32_t dsmHandle;
|
dsUint32_t dsmHandle;
|
||||||
dsmSendType sendtype;
|
dsmQueryType qType;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "hiABcxdtvs:f:l:D:O:P:")) != -1) {
|
while ((c = getopt(argc, argv, "hiABcxdtvs:f:l:D:O:P:")) != -1) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
@ -135,6 +130,7 @@ int main(int argc, char *argv[]) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @todo To change.
|
||||||
if (pitdate && ! backup) {
|
if (pitdate && ! backup) {
|
||||||
fprintf(stderr, "tsmpipe: ERROR: -P can only be used with -A\n");
|
fprintf(stderr, "tsmpipe: ERROR: -P can only be used with -A\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -172,7 +168,7 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sendtype = archive ? stArchiveMountWait : stBackupMountWait;
|
qType = backup ? qtBackup : qtArchive;
|
||||||
|
|
||||||
/* Let the TSM api get the signals */
|
/* Let the TSM api get the signals */
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
@ -184,8 +180,12 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OK, we are ready to talk to TSM
|
// OK, we are ready to talk to TSM
|
||||||
|
if (verbose > 0)
|
||||||
|
fprintf(stderr,"tsmpipe: Create TSM session\n");
|
||||||
dsmHandle = tsm_initsess(options);
|
dsmHandle = tsm_initsess(options);
|
||||||
if (! dsmHandle) {
|
if (! dsmHandle) {
|
||||||
|
fprintf(stderr,"tsmpipe: Unable to create TSM session?\n");
|
||||||
|
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,50 +194,117 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
// Show our session information
|
// Show our session information
|
||||||
if (info) {
|
if (info) {
|
||||||
|
if (verbose > 0)
|
||||||
|
fprintf(stderr,"tsmpipe: INFO operation\n");
|
||||||
|
|
||||||
tsm_sessioninfo(dsmHandle);
|
tsm_sessioninfo(dsmHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are backing up
|
// If we are backing up
|
||||||
if (create) {
|
if (create) {
|
||||||
|
if (verbose > 0)
|
||||||
|
fprintf(stderr,"tsmpipe: BACKUP operation\n");
|
||||||
|
|
||||||
length = atof(lenstr);
|
length = atof(lenstr);
|
||||||
if (length <= 0) {
|
if (length <= 0) {
|
||||||
fprintf(stderr,"tsmpipe: ERROR: Provide positive length, overestimate if guessing");
|
fprintf(stderr,"tsmpipe: ERROR: Provide positive length, overestimate if guessing\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! tsm_sendfile(dsmHandle,space,filename,length,desc,sendtype,verbose)){
|
if (! tsm_sendfile(dsmHandle,space,filename,length,desc,(archive ? stArchiveMountWait : stBackupMountWait),verbose)){
|
||||||
dsmTerminate(dsmHandle);
|
dsmTerminate(dsmHandle);
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete an object from TSM
|
if (! info && ! create) {
|
||||||
if (delete) {
|
qryArchiveData qaData;
|
||||||
// @todo Delete Archives by date range.
|
qryBackupData qbData;
|
||||||
if (! tsm_deletefile(dsmHandle,space,filename,desc,sendtype,verbose)) {
|
dsmObjName objName;
|
||||||
dsmTerminate(dsmHandle);
|
memset(&qaData,0x00,sizeof(qryArchiveData));
|
||||||
exit(3);
|
memset(&qbData,0x00,sizeof(qryBackupData));
|
||||||
}
|
objName = dsmNameToObjname(space,filename,verbose);
|
||||||
}
|
|
||||||
|
// Setup our Query Object
|
||||||
// Restore from TSM
|
if (backup) {
|
||||||
if(xtract) {
|
qbData.stVersion = qryBackupDataVersion;
|
||||||
// @todo Query Archives by date range.
|
qbData.objName = &objName;
|
||||||
if (! tsm_restorefile(dsmHandle,space,filename,desc,sendtype,verbose,(sendtype == stBackupMountWait ? pitdate : NULL))) {
|
qbData.owner = "";
|
||||||
dsmTerminate(dsmHandle);
|
qbData.objState = delete ? DSM_ACTIVE : DSM_ANY_MATCH;
|
||||||
exit(3);
|
|
||||||
}
|
if (delete || ! pitdate) {
|
||||||
}
|
qbData.pitDate.year = DATE_MINUS_INFINITE;
|
||||||
|
} else {
|
||||||
// List objects in TSM
|
// @todo Need to include time
|
||||||
if (list) {
|
qbData.pitDate = dsmStrToDate(pitdate,verbose);
|
||||||
// @todo Query Archives by date range.
|
}
|
||||||
if (! tsm_listfile(dsmHandle,space,filename,desc,sendtype,verbose,(sendtype == stBackupMountWait ? pitdate : NULL))) {
|
|
||||||
dsmTerminate(dsmHandle);
|
// We must be archive then
|
||||||
exit(3);
|
} else {
|
||||||
|
if (archive) {
|
||||||
|
qaData.stVersion = qryArchiveDataVersion;
|
||||||
|
qaData.objName = &objName;
|
||||||
|
qaData.owner = "";
|
||||||
|
|
||||||
|
if (pitdate) {
|
||||||
|
fprintf(stderr,"tsmpipe: Archive Date Range Query not yet setup\n");
|
||||||
|
exit(1);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
qaData.insDateLowerBound.year = DATE_MINUS_INFINITE;
|
||||||
|
qaData.insDateUpperBound.year = DATE_PLUS_INFINITE;
|
||||||
|
qaData.expDateLowerBound.year = DATE_MINUS_INFINITE;
|
||||||
|
qaData.expDateUpperBound.year = DATE_PLUS_INFINITE;
|
||||||
|
}
|
||||||
|
|
||||||
|
qaData.descr = desc ? desc : "*";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fprintf(stderr,"tsmpipe: ERROR: How can we not be a backup or archive?\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete an object from TSM
|
||||||
|
if (delete) {
|
||||||
|
if (verbose > 0)
|
||||||
|
fprintf(stderr,"tsmpipe: DELETE operation\n");
|
||||||
|
|
||||||
|
// @todo Delete Archives by date range.
|
||||||
|
if (! tsm_deletefile(dsmHandle,qType,qaData,qbData,verbose)) {
|
||||||
|
dsmTerminate(dsmHandle);
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore from TSM
|
||||||
|
if(xtract) {
|
||||||
|
if (verbose > 0)
|
||||||
|
fprintf(stderr,"tsmpipe: RESTORE operation\n");
|
||||||
|
|
||||||
|
// @todo Query Archives by date range.
|
||||||
|
if (! tsm_restorefile(dsmHandle,qType,qaData,qbData,verbose)) {
|
||||||
|
dsmTerminate(dsmHandle);
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// List objects in TSM
|
||||||
|
if (list) {
|
||||||
|
if (verbose > 0)
|
||||||
|
fprintf(stderr,"tsmpipe: LIST operation\n");
|
||||||
|
|
||||||
|
// @todo Query Archives by date range.
|
||||||
|
if (! tsm_listfile(dsmHandle,qType,qaData,qbData,verbose)) {
|
||||||
|
dsmTerminate(dsmHandle);
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (verbose > 0)
|
||||||
|
fprintf(stderr,"tsmpipe: Terminate TSM session\n");
|
||||||
dsmTerminate(dsmHandle);
|
dsmTerminate(dsmHandle);
|
||||||
|
|
||||||
if (verbose > 0)
|
if (verbose > 0)
|
||||||
|
21
tsmpipe.h
21
tsmpipe.h
@ -1,3 +1,24 @@
|
|||||||
|
#define _TSMPIPE_VERSION "1.5.1"
|
||||||
|
|
||||||
typedef int (*tsm_query_callback)(dsmQueryType, DataBlk *, void *);
|
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 void tsm_sessioninfo(dsUint32_t dsmHandle);
|
||||||
|
|
||||||
|
extern dsmDate dsmStrToDate(char *s,int verbose);
|
||||||
|
extern dsmObjName dsmNameToObjname(char *fsname, char *filename, int verbose);
|
||||||
|
extern dsInt16_t tsm_queryfile(dsUint32_t sesshandle, dsmQueryType qType, tsm_query_callback usercb, void *userdata, qryArchiveData qaData, qryBackupData qbData, int verbose);
|
||||||
|
extern dsUint32_t tsm_initsess(char *options);
|
||||||
|
extern dsBool_t compressEnabled;
|
||||||
|
|
||||||
|
extern int tsm_deletefile (dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaData, qryBackupData qbData, int verbose);
|
||||||
|
extern int tsm_listfile (dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaData, qryBackupData qbData, int verbose);
|
||||||
|
extern int tsm_restorefile(dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaData, qryBackupData qbData, int verbose);
|
||||||
|
extern int tsm_sendfile (dsUint32_t dsmHandle, char *fsname, char *filename, long long length, char *description, dsmSendType sendtype, int verbose);
|
||||||
|
|
||||||
|
extern char *dsmDateToStr(dsmDate date);
|
||||||
|
extern char *dsmObjnameToStr(dsmObjName objName);
|
||||||
|
|
||||||
|
extern double dsmSizeToNum(dsStruct64_t dsStruct64);
|
||||||
|
Reference in New Issue
Block a user