extern afs_int32 flushSavedEntries(afs_int32);
extern void waitDbWatcher(void);
extern afs_int32 finishDump(struct budb_dumpEntry *);
+extern afs_int32 threadEntryDir(void *, afs_int32, afs_int32);
/* list.c */
extern afs_int32 allocTaskId(void);
extern void GetNewLabel(struct butm_tapeInfo *, char *, char *,
struct butm_tapeLabel *);
extern void FFlushInput(void);
+extern afs_int32 ReadVolHeader(afs_int32, struct butm_tapeInfo *,
+ struct volumeHeader *);
+extern int FindVolTrailer(char *, afs_int32, afs_int32 *,
+ struct volumeHeader *);
+extern int FindVolTrailer2(char *, afs_int32, afs_int32 *, char *, afs_int32,
+ afs_int32 *, struct volumeHeader *);
+
/* recoverDb.c */
extern afs_int32 Ask(char *);
#include <afs/volser.h>
#include <afs/volint.h>
#include <afs/cellconfig.h>
+#include <afs/bucoord_prototypes.h>
+
+#include "butc_internal.h"
#include "error_macros.h"
int dbWatcherinprogress;
afs_int32
-threadEntryDir(char *anEntry, afs_int32 size, afs_int32 type)
+threadEntryDir(void *anEntry, afs_int32 size, afs_int32 type)
{
dlqlinkP entryPtr;
- char *entry = NULL;
+ void *entry = NULL;
int tried;
for (tried = 0; tried < 5; tried++) {
*/
afs_int32
-threadEntry(char *anEntry, afs_int32 size, afs_int32 type)
+threadEntry(void *anEntry, afs_int32 size, afs_int32 type)
{
dlqlinkP entryPtr;
- char *entry = NULL;
+ void *entry = NULL;
int tried;
for (tried = 0; tried < 5; tried++) {
* Creates a tape entry and puts it onto the savedEntries list.
*/
afs_int32
-useTape(struct budb_tapeEntry *aTapeEntryPtr, afs_int32 dumpID, char *tapename, afs_int32 tapeSeq, afs_int32 useCount, Date written, Date expiration, afs_int32 tapepos)
+useTape(struct budb_tapeEntry *aTapeEntryPtr, afs_int32 dumpID,
+ char *tapename, afs_int32 tapeSeq, afs_int32 useCount,
+ Date written, Date expiration, afs_int32 tapepos)
{
afs_int32 code = 0;
* Creates a volume entry and puts it onto the savedEntries list.
*/
afs_int32
-addVolume(struct budb_volumeEntry *aVolEntryPtr, afs_int32 dumpID, char *tapename, char *volname, afs_int32 volid, Date cloneDate, afs_int32 startPos, afs_int32 volBytes, int fragment, afs_int32 flags)
+addVolume(struct budb_volumeEntry *aVolEntryPtr, afs_int32 dumpID,
+ char *tapename, char *volname, afs_int32 volid,
+ Date cloneDate, afs_int32 startPos, afs_int32 volBytes,
+ int fragment, afs_int32 flags)
{
afs_int32 code = 0;
int allo = 0;
return (code);
}
+static_inline int
+freeEntry(void *e)
+{
+ free(e);
+ return 0;
+}
+
/*
* flushSavedEntries
* Runs through the list of savedEntries and adds the volumes and
* Add dump, tape, and volume entries to the list for the dbWatcher to
* flush. Volume entries are not added if the volume failed to dump.
*/
- while (entryPtr = dlqUnlinkf(&savedEntries)) {
+ while ((entryPtr = dlqUnlinkf(&savedEntries))) {
if ((entryPtr->dlq_type == DLQ_VOLENTRY) && (status != DUMP_SUCCESS)) {
volPtr = (struct budb_volumeEntry *)entryPtr->dlq_structPtr;
if (volPtr)
error_exit:
/* Free anything that remains on dlq */
- dlqTraverseQueue(&savedEntries, free, free);
+ dlqTraverseQueue(&savedEntries, freeEntry, freeEntry);
return (code);
}
void
-waitDbWatcher()
+waitDbWatcher(void)
{
int message = 0;
while (1) {
/*while */
/* Add tape and volume enties to the backup database */
- while (entryPtr = dlqUnlinkf(&entries_to_flush)) {
+ while ((entryPtr = dlqUnlinkf(&entries_to_flush))) {
dbWatcherinprogress = 1;
if (!entryPtr->dlq_structPtr) {
tapePtr =
(struct budb_tapeEntry *)entryPtr->dlq_structPtr;
if (addedDump) {
- code = bcdb_FinishTape(tapePtr, &new);
+ code = bcdb_FinishTape(tapePtr);
if (code) {
ErrorLog(0, 0, code, 0,
"Warning: Can't finish tape %s of DumpID %u in backup database\n",
#include <afs/tcdata.h>
#include <afs/bubasics.h>
#include <afs/budb_client.h>
+#include <afs/butm_prototypes.h>
#include <afs/vldbint.h>
#include <afs/ktime.h>
#include <afs/vlserver.h>
#include <afs/volser.h>
#include <afs/volint.h>
#include <afs/cellconfig.h>
+#include <afs/bucoord_prototypes.h>
+#include "butc_internal.h"
#include "error_macros.h"
#include "butc_xbsa.h"
#include "afs/butx.h"
dlqlinkT savedEntries;
dlqlinkT entries_to_flush;
-afs_int32 flushSavedEntries(), finishDump(), finishTape(), useTape(),
-addVolume();
-
extern struct rx_connection *UV_Bind();
extern afs_int32 groupId;
struct dumpNode *node;
};
+/* Forward declarations */
+
+int makeVolumeHeader(struct volumeHeader *, struct dumpRock *, int);
+int volumeHeader_hton(struct volumeHeader *, struct volumeHeader *);
+char retryPrompt(char *, afs_int32, afs_uint32);
+int getDumpTape(struct dumpRock *, int, afs_int32);
+int getXBSATape(struct dumpRock *);
+afs_int32 createDump(struct dumpRock *);
+
/* configuration variables */
#define HITEOT(code) ((code == BUTM_IO) || (code == BUTM_EOT) || (code == BUTM_IOCTL))
extern int autoQuery;
calcExpirationDate(afs_int32 expType, afs_int32 expDate, afs_int32 createTime)
{
struct ktime_date kd;
- afs_int32 Add_RelDate_to_Time();
switch (expType) {
case BC_REL_EXPDATE:
int action, e;
afs_int32 code = 0, tcode, dvcode;
char ch;
- char retryPrompt();
struct vldbentry vldbEntry;
struct sockaddr_in server;
afs_int32 tapepos;
extern struct deviceSyncNode *deviceLatch;
extern struct tapeConfig globalTapeConfig;
- extern afs_int32 createDump();
taskId = nodePtr->taskID; /* Get task Id */
setStatus(taskId, DRIVE_WAIT);
printf("a - abort, the entire dump\n");
while (1) {
- FFlushInput(stdin);
+ FFlushInput();
putchar(BELLCHAR);
fflush(stdout);
afs_int32 tapepos, lastpos;
extern struct tapeConfig globalTapeConfig;
- extern struct udbHandleS udbHandle;
askForTape = interactiveFlag;
dparamsPtr->wroteLabel = 0;
* allocate a dump (task) id
*/
afs_int32
-allocTaskId()
+allocTaskId(void)
{
return (maxTaskID++);
}
#include <afs/tcdata.h>
#include <afs/bubasics.h>
#include <afs/budb.h>
+#include <afs/budb_client.h>
+#include <afs/budb_prototypes.h>
+#include <afs/butm_prototypes.h>
+#include <afs/bucoord_prototypes.h>
#include "error_macros.h"
#include "butc_internal.h"
extern struct tapeConfig globalTapeConfig;
extern struct deviceSyncNode *deviceLatch;
-static readDump();
+static int readDump(afs_uint32, struct butm_tapeInfo *,
+ struct tapeScanInfo *);
+afs_int32 getScanTape(afs_int32, struct butm_tapeInfo *, char *,
+ afs_int32, int prompt, struct butm_tapeLabel *);
+afs_int32 RcreateDump(struct tapeScanInfo *, struct volumeHeader *);
+void copy_ktcPrincipal_to_budbPrincipal(struct ktc_principal *,
+ struct budb_principal *);
/* PrintDumpLabel
* print out the tape (dump) label.
#define BIGCHUNK 102400
static int
-scanVolData(afs_int32 taskId, struct butm_tapeInfo *curTapePtr, afs_int32 tapeVersion, struct volumeHeader *volumeHeader, struct volumeHeader *volumeTrailer, afs_uint32 *bytesRead)
+scanVolData(afs_int32 taskId, struct butm_tapeInfo *curTapePtr,
+ afs_int32 tapeVersion, struct volumeHeader *volumeHeader,
+ struct volumeHeader *volumeTrailer, afs_uint32 *bytesRead)
{
afs_int32 headBytes, tailBytes;
char *block = NULL;
* -1 don't know if last tape or not.
*/
-afs_int32 RcreateDump();
-
static int
-readDump(afs_uint32 taskId, struct butm_tapeInfo *tapeInfoPtr, struct tapeScanInfo *scanInfoPtr)
+readDump(afs_uint32 taskId, struct butm_tapeInfo *tapeInfoPtr,
+ struct tapeScanInfo *scanInfoPtr)
{
int moreTapes = 1;
afs_int32 nbytes, flags, seq;
* The first tape label is the first dumpLabel.
*/
int
-readDumps(afs_uint32 taskId, struct butm_tapeInfo *tapeInfoPtr, struct tapeScanInfo *scanInfoPtr)
+readDumps(afs_uint32 taskId, struct butm_tapeInfo *tapeInfoPtr,
+ struct tapeScanInfo *scanInfoPtr)
{
afs_int32 code, c;
}
afs_int32
-getScanTape(afs_int32 taskId, struct butm_tapeInfo *tapeInfoPtr, char *tname, afs_int32 tapeId, int prompt, struct butm_tapeLabel *tapeLabelPtr)
+getScanTape(afs_int32 taskId, struct butm_tapeInfo *tapeInfoPtr, char *tname,
+ afs_int32 tapeId, int prompt, struct butm_tapeLabel *tapeLabelPtr)
{
afs_int32 code = 0;
int tapecount = 1;
}
afs_int32
-RcreateDump(struct tapeScanInfo *tapeScanInfoPtr, struct volumeHeader *volHeaderPtr)
+RcreateDump(struct tapeScanInfo *tapeScanInfoPtr,
+ struct volumeHeader *volHeaderPtr)
{
afs_int32 code;
struct butm_tapeLabel *dumpLabelPtr = &tapeScanInfoPtr->dumpLabel;
#include <ctype.h>
#include "error_macros.h"
#include <afs/budb_errs.h>
+#include <afs/budb_client.h>
+#include <afs/bucoord_prototypes.h>
#include "afs/butx.h"
#define XBSA_TCMAIN
#include "butc_xbsa.h"
#define CFG_PREFIX "CFG"
struct ubik_client *cstruct;
-extern void TC_ExecuteRequest();
+extern void TC_ExecuteRequest(struct rx_call *);
FILE *logIO, *ErrorlogIO, *centralLogIO, *lastLogIO;
char lFile[AFSDIR_PATH_MAX];
char logFile[256];
/* dummy routine for the audit work. It should do nothing since audits */
/* occur at the server level and bos is not a server. */
-osi_audit()
+int
+osi_audit(void)
{
return 0;
}
register int tc;
total = 0;
- while (tc = *anum) {
+ while ((tc = *anum)) {
if (tc < '0' || tc > '9')
return -1;
total *= 10;
}
/* replace last two ocurrences of / by _ */
-static
+#if 0
+static int
stringReplace(char *name)
{
char *pos;
strcat(name, buffer);
return 0;
}
+#endif
-static
+static int
stringNowReplace(char *logFile, char *deviceName)
{
char *pos = 0;
deviceName += devPrefLen;
mvFlag++;
}
- while (pos = strchr(deviceName, devPrefix[0])) /* look for / or \ */
+ while ((pos = strchr(deviceName, devPrefix[0]))) /* look for / or \ */
*pos = '_';
strcat(logFile, deviceName);
/* now put back deviceName to the way it was */
afs_int32
STC_DeleteDump(struct rx_call *acid, afs_uint32 dumpID, afs_uint32 *taskId)
{
- struct deleteDumpIf *ptr = 0;
- statusP statusPtr = 0;
afs_int32 code = TC_BADTASK; /* If not compiled -Dxbsa then fail */
#ifdef xbsa
+ struct deleteDumpIf *ptr = 0;
+ statusP statusPtr = 0;
#ifdef AFS_PTHREAD_ENV
pthread_t pid;
pthread_attr_t tattr;
#include <afs/keys.h>
#include <ubik.h>
#include <afs/acl.h>
+#include <afs/volser.h>
+#include <afs/vlserver.h>
#include <afs/tcdata.h>
#include <afs/budb.h>
#include <afs/budb_client.h>
#include <afs/bubasics.h>
+#include <afs/bucoord_prototypes.h>
+#include <afs/butm_prototypes.h>
+#include <afs/budb_prototypes.h>
+#include <afs/afsutil.h>
+#include "butc_internal.h"
#include "error_macros.h"
/* GLOBAL CONFIGURATION PARAMETERS */
extern int dump_namecheck;
extern int autoQuery;
-static void initTapeBuffering();
-static writeDbDump();
-static restoreDbEntries();
+struct rstTapeInfo {
+ afs_int32 taskId;
+ afs_int32 tapeSeq;
+ afs_uint32 dumpid;
+};
+
+static void initTapeBuffering(void);
+static int writeDbDump(struct butm_tapeInfo *, afs_uint32, Date, afs_uint32);
+static int restoreDbEntries(struct butm_tapeInfo *, struct rstTapeInfo *);
+
+int getTapeData(struct butm_tapeInfo *, struct rstTapeInfo *, void *,
+ afs_int32);
+int restoreDbHeader(struct butm_tapeInfo *, struct rstTapeInfo *,
+ struct structDumpHeader *);
+int restoreDbDump(struct butm_tapeInfo *, struct rstTapeInfo *,
+ struct structDumpHeader *);
+int restoreText(struct butm_tapeInfo *, struct rstTapeInfo *,
+ struct structDumpHeader *);
+
+
void * KeepAlive(void *);
/* CreateDBDump
*/
afs_int32
-CreateDBDump(dumpEntryPtr)
- struct budb_dumpEntry *dumpEntryPtr;
+CreateDBDump(struct budb_dumpEntry *dumpEntryPtr)
{
afs_int32 code = 0;
* Leave the tape mounted.
*/
afs_int32
-GetDBTape(taskId, expires, tapeInfoPtr, dumpid, sequence, queryFlag,
- wroteLabel)
- afs_int32 taskId;
- Date expires;
- struct butm_tapeInfo *tapeInfoPtr;
- afs_uint32 dumpid;
- afs_int32 sequence;
- int queryFlag;
- int *wroteLabel;
+GetDBTape(afs_int32 taskId, Date expires, struct butm_tapeInfo *tapeInfoPtr,
+ afs_uint32 dumpid, afs_int32 sequence, int queryFlag,
+ int *wroteLabel)
{
afs_int32 code = 0;
int interactiveFlag;
struct butm_tapeLabel oldTapeLabel, newLabel;
struct tapeEntryList *endList;
- extern struct tapeConfig globalTapeConfig;
/* construct the name of the tape */
sprintf(tapeName, "%s.%-d", DUMP_TAPE_NAME, sequence);
*/
afs_int32
-freeTapeList()
+freeTapeList(void)
{
struct tapeEntryList *next;
*/
afs_int32
-addTapesToDb(taskId)
- afs_int32 taskId;
+addTapesToDb(afs_int32 taskId)
{
afs_int32 code = 0;
afs_int32 i, new;
* the blocksize on writes
*/
-static
-writeDbDump(tapeInfoPtr, taskId, expires, dumpid)
- struct butm_tapeInfo *tapeInfoPtr;
- afs_uint32 taskId;
- Date expires;
- afs_uint32 dumpid;
+static int
+writeDbDump(struct butm_tapeInfo *tapeInfoPtr, afs_uint32 taskId,
+ Date expires, afs_uint32 dumpid)
{
afs_int32 blockSize;
afs_int32 writeBufNbytes = 0;
return (void *)(code);
}
-struct rstTapeInfo {
- afs_int32 taskId;
- afs_int32 tapeSeq;
- afs_uint32 dumpid;
-};
/* makeDbDumpEntry()
* Make a database dump entry given a tape label.
*/
afs_int32
-makeDbDumpEntry(tapeEntPtr, dumpEntryPtr)
- struct budb_tapeEntry *tapeEntPtr;
- struct budb_dumpEntry *dumpEntryPtr;
+makeDbDumpEntry(struct budb_tapeEntry *tapeEntPtr,
+ struct budb_dumpEntry *dumpEntryPtr)
{
memset(dumpEntryPtr, 0, sizeof(struct budb_dumpEntry));
*/
afs_int32
-readDbTape(tapeInfoPtr, rstTapeInfoPtr, query)
- struct butm_tapeInfo *tapeInfoPtr;
- struct rstTapeInfo *rstTapeInfoPtr;
- int query;
+readDbTape(struct butm_tapeInfo *tapeInfoPtr,
+ struct rstTapeInfo *rstTapeInfoPtr, int query)
{
afs_int32 code = 0;
int interactiveFlag;
static afs_int32 nbytes = 0; /* # bytes left in buffer */
static void
-initTapeBuffering()
+initTapeBuffering(void)
{
nbytes = 0;
}
* tape positioned after tape label
*/
-static
-restoreDbEntries(tapeInfoPtr, rstTapeInfoPtr)
- struct butm_tapeInfo *tapeInfoPtr;
- struct rstTapeInfo *rstTapeInfoPtr;
+static int
+restoreDbEntries(struct butm_tapeInfo *tapeInfoPtr,
+ struct rstTapeInfo *rstTapeInfoPtr)
{
struct structDumpHeader netItemHeader, hostItemHeader;
afs_int32 more = 1;
* restore special items in the header
*/
-restoreDbHeader(tapeInfo, rstTapeInfoPtr, nextHeader)
- struct butm_tapeInfo *tapeInfo;
- struct rstTapeInfo *rstTapeInfoPtr;
- struct structDumpHeader *nextHeader;
+int
+restoreDbHeader(struct butm_tapeInfo *tapeInfo,
+ struct rstTapeInfo *rstTapeInfoPtr,
+ struct structDumpHeader *nextHeader)
{
struct structDumpHeader netItemHeader;
struct DbHeader netDbHeader, hostDbHeader;
* a database dump tree exists on the tape
*/
-restoreDbDump(tapeInfo, rstTapeInfoPtr, nextHeader)
- struct butm_tapeInfo *tapeInfo;
- struct rstTapeInfo *rstTapeInfoPtr;
- struct structDumpHeader *nextHeader;
+int
+restoreDbDump(struct butm_tapeInfo *tapeInfo,
+ struct rstTapeInfo *rstTapeInfoPtr,
+ struct structDumpHeader *nextHeader)
{
struct budb_dumpEntry netDumpEntry, hostDumpEntry;
struct budb_tapeEntry netTapeEntry, hostTapeEntry;
*/
afs_int32
-saveTextFile(taskId, textType, fileName)
- afs_int32 taskId;
- afs_int32 textType;
- char *fileName;
+saveTextFile(afs_int32 taskId, afs_int32 textType, char *fileName)
{
udbClientTextP ctPtr = 0;
afs_int32 code = 0;
* nextHeader - struct header for next item on the tape
*/
-restoreText(tapeInfo, rstTapeInfoPtr, nextHeader)
- struct butm_tapeInfo *tapeInfo;
- struct rstTapeInfo *rstTapeInfoPtr;
- struct structDumpHeader *nextHeader;
+int
+restoreText(struct butm_tapeInfo *tapeInfo,
+ struct rstTapeInfo *rstTapeInfoPtr,
+ struct structDumpHeader *nextHeader)
{
char filename[64];
afs_int32 nbytes;
* fn retn - 0, ok, n, error
*/
-getTapeData(tapeInfoPtr, rstTapeInfoPtr, buffer, requestedBytes)
- struct butm_tapeInfo *tapeInfoPtr;
- struct rstTapeInfo *rstTapeInfoPtr;
- char *buffer;
- afs_int32 requestedBytes;
+int
+getTapeData(struct butm_tapeInfo *tapeInfoPtr,
+ struct rstTapeInfo *rstTapeInfoPtr,
+ void *out, afs_int32 requestedBytes)
{
- afs_int32 taskId, transferBytes, new;
+ char *buffer = (char *) out;
+ afs_int32 taskId, transferBytes;
afs_int32 code = 0;
- afs_uint32 dumpid;
taskId = rstTapeInfoPtr->taskId;