/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
#include <afsconfig.h>
#include <afs/param.h>
+#include <afs/procmgmt.h>
+#include <roken.h>
+
#ifdef IGNORE_SOME_GCC_WARNINGS
# pragma GCC diagnostic warning "-Wimplicit-function-declaration"
#endif
-#include <sys/types.h>
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#ifdef AFS_NT40_ENV
-#include <winsock2.h>
-#include <io.h>
-#else
-#include <sys/time.h>
-#include <sys/file.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#endif
-#include <errno.h>
#include <rx/xdr.h>
#include <rx/rx.h>
#include <afs/afsint.h>
-#include <stdio.h>
-#include <string.h>
-#include <afs/procmgmt.h>
-#include <afs/assert.h>
+#include <afs/afs_assert.h>
#include <afs/prs_fs.h>
-#include <fcntl.h>
#include <afs/nfs.h>
#include <lwp.h>
#include <lock.h>
#include <afs/butm_prototypes.h>
#include <afs/budb_prototypes.h>
#include <afs/afsutil.h>
+
#include "butc_internal.h"
#include "error_macros.h"
void * KeepAlive(void *);
/* CreateDBDump
- * create a dump entry for a saved database
+ * create a dump entry for a saved database
*/
afs_int32
char tapeName[BU_MAXTAPELEN];
char strlevel[5];
struct timeval tp;
- struct timezone tzp;
afs_int32 curTime;
int tapecount = 1;
goto getNewTape;
}
- /* On first tape, the savedb has not started yet, so the database is not locked
+ /* On first tape, the savedb has not started yet, so the database is not locked
* and we can therefore, access information from it. This is easier to do because
* database dumps don't have appended dumps (nor appended).
*/
struct budb_dumpEntry de, de2;
/* Verify the tape has not expired
- * Early database dumps don't have a dumpid
+ * Early database dumps don't have a dumpid
*/
if (!tapeExpired(&oldTapeLabel)) {
TLog(taskId, "This tape has not expired\n");
}
/* Otherwise, the savedb is in progress and we can't
- * access the database (it's locked). So we rely on the
+ * access the database (it's locked). So we rely on the
* information available (and not the backup database).
*/
else {
/* Check the tape's expiration date. Use the expiration on the label */
- gettimeofday(&tp, &tzp);
+ gettimeofday(&tp, NULL);
curTime = tp.tv_sec;
if (curTime < oldTapeLabel.expirationDate) {
TLog(taskId, "This tape has not expired\n");
}
/* addTapesToDb
- * With the list of tapes, add them to the database.
+ * With the list of tapes, add them to the database.
* Also delete any olddumpids that are around.
*/
extern struct tapeConfig globalTapeConfig;
extern struct udbHandleS udbHandle;
+ charList.charListT_val = 0;
+ charList.charListT_len = 0;
blockSize = BUTM_BLKSIZE;
writeBlock = (char *)malloc(BUTM_BLOCKSIZE);
if (!writeBlock)
memset(writeBuffer, 0, BUTM_BLKSIZE);
maxReadSize = 1024;
- /*
- * The margin of space to check for end of tape is set to the
- * amount of space used to write an end-of-tape multiplied by 2.
+ /*
+ * The margin of space to check for end of tape is set to the
+ * amount of space used to write an end-of-tape multiplied by 2.
* The amount of space is size of a 16K EODump marker, its EOF
* marker, and up to two EOF markers done on close (1 16K blocks +
- * 3 EOF * markers).
+ * 3 EOF * markers).
*/
tc_EndMargin = (16384 + 3 * globalTapeConfig.fileMarkSize) * 2;
tc_KEndMargin = tc_EndMargin / 1024;
writeBufPtr = &writeBuffer[0];
firstcall = 1;
sequence = 1;
- charList.charListT_val = 0;
- charList.charListT_len = 0;
while (1) { /*w */
/* When no data in buffer, read data from the budb_server */
saveDbToTape(void *param)
{
struct saveDbIf *saveDbIfPtr = (struct saveDbIf *)param;
- afs_int32 code = 0;
+ afs_int32 code;
afs_int32 i;
int wroteLabel;
afs_uint32 taskId;
extern struct deviceSyncNode *deviceLatch;
extern struct tapeConfig globalTapeConfig;
+ afs_pthread_setname_self("Db save");
expires = (saveDbIfPtr->archiveTime ? NEVERDATE : 0);
taskId = saveDbIfPtr->taskId;
+ dumpEntry.id = 0;
setStatus(taskId, DRIVE_WAIT);
EnterDeviceQueue(deviceLatch); /* lock tape device */
&wroteLabel);
/*
- * If did not write the label, remove created dump
+ * If did not write the label, remove created dump
* Else if wrote the label, remove old dump from db so it's not saved.
*/
if (!wroteLabel) {
extern struct tapeConfig globalTapeConfig;
extern struct deviceSyncNode *deviceLatch;
+ afs_pthread_setname_self("Db restore");
setStatus(taskId, DRIVE_WAIT);
EnterDeviceQueue(deviceLatch); /* lock tape device */
clearStatus(taskId, DRIVE_WAIT);
}
/* KeepAlive
- *
- * While dumping the database, keeps the connection alive.
+ *
+ * While dumping the database, keeps the connection alive.
* Every 10 seconds, wake up and ask to read 0 bytes of the database.
- * This resets the database's internal timer so that it does not
+ * This resets the database's internal timer so that it does not
* prematuraly quit (on asking for new tapes and such).
- *
+ *
* Use the same udbHandle as writeDbDump so we go to the same server.
*/
void *
extern struct udbHandleS udbHandle;
+ afs_pthread_setname_self("Keep-alive");
while (1) {
#ifdef AFS_PTHREAD_ENV
sleep(5);
* nextHeader - ptr to structure for return value
* exit:
* nextHeader - next structure header from tape
- * notes:
+ * notes:
* upon entry, the dump structure header has been read confirming that
* a database dump tree exists on the tape
*/
struct budb_tapeEntry netTapeEntry, hostTapeEntry;
struct budb_volumeEntry netVolumeEntry, hostVolumeEntry;
struct structDumpHeader netItemHeader;
- afs_int32 taskId;
int restoreThisDump = 1;
afs_int32 code = 0;
extern struct udbHandleS udbHandle;
- taskId = rstTapeInfoPtr->taskId;
-
/* read dump entry */
memset(&netDumpEntry, 0, sizeof(netDumpEntry));
code =
/* open the text file */
sprintf(filename, "%s/bu_XXXXXX", gettmpdir());
-#if defined (HAVE_MKSTEMP)
fid = mkstemp(filename);
-#else
- fid = open(mktemp(filename), O_RDWR | O_CREAT | O_EXCL, 0600);
-#endif
if (fid < 0) {
ErrorLog(0, rstTapeInfoPtr->taskId, errno, 0,
"Can't open temporary text file: %s\n", filename);
/* getTapeData
* Read information from tape, and place the requested number of bytes
- * in the buffer supplied
+ * in the buffer supplied
* entry:
* tapeInfo
* rstTapeInfoPtr - Info about the dump being restored.