922 lines
41 KiB
C
922 lines
41 KiB
C
|
#ifndef h_backup1
|
||
|
#define h_backup1
|
||
|
/******************************************************************************
|
||
|
*
|
||
|
* Declarations for UVbackup & UVrestore externals
|
||
|
*
|
||
|
* Module %M% Version %I% Date %H%
|
||
|
*
|
||
|
* (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved
|
||
|
* This is unpublished proprietary source code of Ardent Software Inc.
|
||
|
* The copyright notice above does not evidence any actual or intented
|
||
|
* publication of such source code.
|
||
|
*******************************************************************************
|
||
|
*
|
||
|
* Maintenence log - insert most recent change descriptions at top
|
||
|
*
|
||
|
* Date.... GTAR# WHO Description.........................................
|
||
|
* 08/11/99 25046 JBG Fix typo, change user option -rev95C
|
||
|
* 08/10/99 25046 JBG Rev SICA,larger schema-file names
|
||
|
* 06/02/99 24829 GMH Add options, fix errors
|
||
|
* 05/27/99 24829 GMH 64-bit work
|
||
|
* 03/15/99 24690 GMH/KAM change CACHEBLKSIZEMAX for Solaris
|
||
|
* 11/25/98 23023 GMH Fix uvbackup/uvrestore
|
||
|
* 11/17/98 23992 GMH Disable NT shared cache
|
||
|
* 10/14/98 23801 SAP Change copyrights.
|
||
|
* 10/07/98 23672 GMH Fix errors
|
||
|
* 10/06/98 23672 GMH Change DBITEM to DBITEMNEW (64-bit)
|
||
|
* 07/27/98 23401 GMH Add declaration
|
||
|
* 07/17/98 16692 GMH Fix problems
|
||
|
* 07/02/98 16692 GMH Support deleted records
|
||
|
* 05/20/98 21718 LPC/WSM Add support for file suspension
|
||
|
* GG/MM/HH 16692 GMH Support deleted records, ready for 64bit support
|
||
|
* 05/04/98 22671 GMH Create new header file and implement shared memory
|
||
|
* cache. Split backup.h
|
||
|
*******************************************************************************
|
||
|
*
|
||
|
* HISTORICAL MODS FROM OLD BACKUP.H FILE
|
||
|
*
|
||
|
* 08/14/97 18114 DJL Bundle a file and its indices together
|
||
|
* 05/01/97 19940 GMH Remove WLATCH define
|
||
|
* 08/23/96 17637 DJL Add X option to exclude a file
|
||
|
* 03/11/96 18088 JJV Changed UVDevice fd to Win32 handle for port to NT.
|
||
|
* 03/04/96 17481 NDP Added REVISION05, FILE_SKIPPED, EXIT_ON_BAD_NLS_STATE
|
||
|
* for NLS. Reduced FILEPATH_LEN from 386. Added
|
||
|
* NLSDATA_LOC, NLS_NONE_MAP, TMPBUFSIZ.
|
||
|
* 01/19/96 16389 GMH Add new structure for devices
|
||
|
* 01/19/96 16815 GMH Add init macro
|
||
|
* 06/26/95 16372 GMH Add new defines
|
||
|
* 06/12/95 15988 FRA Fix Multiply defined variables
|
||
|
* 02/21/95 16007 GMH Add close to macros
|
||
|
* 01/18/95 15728 RM Moved PRI_RO and GENMSG into uvbackup.c
|
||
|
* 12/27/94 15491 GMH Add new SICA definition, change SKIP def'n
|
||
|
* 10/28/94 15232 GMH Up revision level for adding new data to FILEhdr defn
|
||
|
* 04/29/94 12669 GMH Up revision level for block checksumming
|
||
|
* 02/10/94 12535 JBG Moved WLATCH defination to DBFILE.h
|
||
|
* 12/20/93 12388 GMH Add new definitions
|
||
|
* 12/01/93 12535 JBG Assigned WLATCH bit in mode field
|
||
|
* 12/01/93 12388 GMH Add to structure
|
||
|
* 09/09/93 12219 PVW Add DISPLAY_SYNTAX
|
||
|
* 09/08/93 12200 PVW Change names of some variables
|
||
|
* 09/03/93 12184 PVW Change names of some variables
|
||
|
* 09/02/93 12181 PVW Add flags for operating system
|
||
|
* 05/27/93 11597 PVW Add prev to node structure
|
||
|
* 04/23/93 10379 PVW Put in changes for caching
|
||
|
* 09/17/92 6818 GMH Initial installation
|
||
|
*
|
||
|
*****************************************************************************/
|
||
|
/* IMPORTANT NOTE: This include header file must ALWAYS be declared
|
||
|
AFTER disk.h. If disk.h is NOT defined, then this
|
||
|
will include it here!
|
||
|
*/
|
||
|
#ifndef h_disk
|
||
|
#include "disk.h"
|
||
|
#endif
|
||
|
/*****************************************************************************/
|
||
|
/* This header includes entries used by external modules */
|
||
|
#include "backup.h"
|
||
|
/*****************************************************************************/
|
||
|
/* Revision history. These stamps are required for the 'REVISION_current' variable */
|
||
|
#define REVISION01 01 /* original - not supported */
|
||
|
#define REVISION02 02 /* initial released version */
|
||
|
#define REVISION03 03 /* checksum value for each written block */
|
||
|
/* --- rev 8 --- */
|
||
|
#define REVISION04 04 /* add plnum,tlflags and chkpoint to file hdr */
|
||
|
/* save rev7 sica as rev7 sica */
|
||
|
/* convert rev8 sica to rev7 sica for -rev7 */
|
||
|
/* move sica data out of file header */
|
||
|
/* --- rev 9.3 --- */
|
||
|
#define REVISION05 05 /* NLS support added */
|
||
|
/* --- rev 9.4 --- */
|
||
|
#define REVISION06 06 /* Bundle indexes with file */
|
||
|
/* --- rev 9.5 --- */
|
||
|
#define REVISION07 07 /* Deleted Records, 64bit setup */
|
||
|
/* --- rev 9.5C -- */
|
||
|
#define REVISION08 8 /* Longer schema & file names in SICA */
|
||
|
/* revert to 18 ch schema, table name */
|
||
|
/* The current (default) revision level created by uvbackup */
|
||
|
PRI_RW int REVISION_current = REVISION08;
|
||
|
/*****************************************************************************/
|
||
|
/* Offsets */
|
||
|
#define REELNUM_LOC 16 /* reel number location */
|
||
|
#define OSFILELEFT_LOC 121 /* osfile left location */
|
||
|
#define FILEPATH_LOC 125 /* filepath location */
|
||
|
#define FILEPATH_LEN 256 /* filepath length */
|
||
|
#define NLSDATA_LOC (FILEPATH_LOC + FILEPATH_LEN) /* start of NLS data */
|
||
|
#define DATA_LEN_POS (REVISION_current>=REVISION07?9:5) /* offset for data length in Data */
|
||
|
#define DATA_LEN_INSOFFSET 2 /* offset */
|
||
|
#define LENGTH_POS 5
|
||
|
#define INT32SIZE 4 /* these MUST be hardcoded values to */
|
||
|
#define INT64SIZE 8 /* insure correct image alignment */
|
||
|
/*****************************************************************************/
|
||
|
/* logicals */
|
||
|
#define FORCE_NEW_REEL 4
|
||
|
#define SKIPIT 3
|
||
|
#define TRUE 1
|
||
|
#define FALSE 0
|
||
|
#define ZERO 0
|
||
|
#define MINUS_ONE -1
|
||
|
#define MINUS_TWO -2
|
||
|
#define MINUS_THREE -3
|
||
|
#define MINUS_FOUR -4
|
||
|
#define MINUS_FIVE -5
|
||
|
#define MINUS_SIX -6
|
||
|
/*****************************************************************************/
|
||
|
/* item type */
|
||
|
#define a_FILE 0
|
||
|
#define a_RECORD 1
|
||
|
#define a_DIR 2
|
||
|
#define x_FILE 3
|
||
|
/*****************************************************************************/
|
||
|
/* Size definitions */
|
||
|
#define BLKSIZ 8192
|
||
|
#define NHDRSIZ 512
|
||
|
#define TMPBUFSIZ 512
|
||
|
/*****************************************************************************/
|
||
|
/* Exit states */
|
||
|
#define BAD_NLS_ID_CHARS32 -32
|
||
|
#define BAD_NLS_ID_CHARS16 -16
|
||
|
#define EXIT_ON_BAD_NLS_STATE -13
|
||
|
#define FILE_SKIPPED -12
|
||
|
#define EXIT_ON_BAD_DEVICE -11
|
||
|
#define SICA_SKIPPED -10
|
||
|
#define EXIT_ON_BAD_CKSUM -9
|
||
|
#define EXIT_ON_BAD_BLOCK -8
|
||
|
#define EXIT_ON_BAD_IMAGE -7
|
||
|
#define EXIT_ON_BADF -6
|
||
|
#define EXIT_ON_SIGNAL -5
|
||
|
#define EXIT_ON_USER_REQ -4
|
||
|
#define CHANGED_DEVICE -3
|
||
|
#define EXIT_INCOMPAT 1
|
||
|
#define EXIT_ILLEGAL 2
|
||
|
#define EXIT_INVALID 3
|
||
|
#define EXIT_SYNTAX 4
|
||
|
/*****************************************************************************/
|
||
|
/* Startup options */
|
||
|
#define FILE_VERBOSE 1
|
||
|
#define RECORD_VERBOSE 2
|
||
|
/*****************************************************************************/
|
||
|
/* Maximum number of -t option devices that can be specified at one time */
|
||
|
#define UVBAKMAX 10
|
||
|
/*****************************************************************************/
|
||
|
/* These are for use with dirname function */
|
||
|
#define FULLPATH 1
|
||
|
#define LOCALPATH 2
|
||
|
/*****************************************************************************/
|
||
|
/* File types */
|
||
|
#define BTREE_FILE 25
|
||
|
#define saved_INDEX 26
|
||
|
#define DISTRIBUTED_FILE 27
|
||
|
#define ak_NAME 28
|
||
|
#define rel_INDEX 29
|
||
|
#define DYNAMIC_FILE 30
|
||
|
#define VIEW_FILE 41
|
||
|
/*****************************************************************************/
|
||
|
/* Current list of supported image definition items */
|
||
|
#define IMAGE_DEFINITION 'I'
|
||
|
#define OSFILE_DEFINITION 'U'
|
||
|
#define FILE_DEFINITION 'F'
|
||
|
#define RECORD_DEFINITION 'R'
|
||
|
#define DATA_DEFINITION 'D'
|
||
|
#define SICA_DEFINITION 'S'
|
||
|
#define TRAILER_DEFINITION 'T'
|
||
|
#define SKIP_DEFINITION 'X'
|
||
|
#define NOT_REEL1_START 'A'
|
||
|
#define GROUP_DEFINITION 'G'
|
||
|
/*****************************************************************************/
|
||
|
#define NLS_NONE_MAP "NONE"
|
||
|
#define UVrev7 7
|
||
|
#define UVrev8 8
|
||
|
#define UVrev9D 9
|
||
|
#define SicaRev4 4
|
||
|
#define SicaRev3 3
|
||
|
#define SicaRev2 2
|
||
|
#define SicaRev0 0
|
||
|
/*****************************************************************************/
|
||
|
/* errors from ClearGroup function */
|
||
|
#define CG_NOLOCK 0x01 /* unable to get file lock */
|
||
|
#define CG_NOMEM 0x02 /* insufficient memory */
|
||
|
#define CG_BLKRDERR 0x04 /* error when reading from DBrblok */
|
||
|
#define CG_BLKWRERR 0x08 /* error when writing from DBwblok */
|
||
|
/*****************************************************************************/
|
||
|
/* state of flags in fastbuf */
|
||
|
#define NO_CLRGROUP 0x01 /* do NOT clear group */
|
||
|
/*****************************************************************************/
|
||
|
/* Fast Group Write structure */
|
||
|
struct fastbuf
|
||
|
{
|
||
|
UVINT currgroup; /* current group number */
|
||
|
int flags; /* different status flags */
|
||
|
DBDADDR currbase; /* base address of group for locking */
|
||
|
DBDADDR curroffset; /* offset to seek, read and write */
|
||
|
DBITEMNEW *currptr; /* pointer within buffer */
|
||
|
int currovf30; /* current buffer is in OVER.30 file */
|
||
|
char *currbuf; /* current group buffer */
|
||
|
DBDADDR ovfoffset; /* offset to seek, read, write ovf data */
|
||
|
char *ovfbuf; /* ovf buffer */
|
||
|
DBITEMNEW *ovfptr; /* pointer used within overflow buffer */
|
||
|
DBDADDR blink; /* current blink value */
|
||
|
int space_left; /* number of bytes left in active buffer */
|
||
|
};
|
||
|
PRI_RW struct fastbuf *FastInfo; /* structure pointer of FG write */
|
||
|
/*****************************************************************************/
|
||
|
/* listnode structure definition */
|
||
|
struct listnode
|
||
|
{
|
||
|
struct listnode *prev; /* ptr to previous node in list */
|
||
|
struct listnode *next; /* ptr to next node in list */
|
||
|
int oldlen; /* file name len on LEFT of = sign */
|
||
|
char *oldpath; /* file name on LEFT of = sign */
|
||
|
int newlen; /* file name len on RIGHT of = sign */
|
||
|
char *newpath; /* file name on RIGHT of = sign */
|
||
|
int found; /* file/record was located - remove node */
|
||
|
};
|
||
|
PRI_RW struct listnode *FILElisthead; /* Head of file list */
|
||
|
PRI_RW struct listnode *FILElistnode; /* One node in file list */
|
||
|
PRI_RW struct listnode *RECORDlisthead; /* Head of record list */
|
||
|
PRI_RW struct listnode *INDEXlisthead; /* Head of index list */
|
||
|
PRI_RW struct listnode *RELINDEXlisthead; /* Head of relpath index list */
|
||
|
PRI_RW struct listnode *S_INDEXlisthead; /* Head of saved index list */
|
||
|
PRI_RW struct listnode *AKlisthead; /* Head of temporary list for AK */
|
||
|
PRI_RW struct listnode *RECORDlistnode; /* One node in record list */
|
||
|
PRI_RW struct listnode *FILEXlisthead; /* Head of excluded file list */
|
||
|
PRI_RW struct listnode *FILEXlistnode; /* One node in excluded file list */
|
||
|
/* UVDevice structure definition */
|
||
|
struct uvdevitem
|
||
|
{
|
||
|
char list[UVBAKMAX][512]; /* full pathname to device */
|
||
|
char orig[UVBAKMAX][512]; /* name of device from command line */
|
||
|
int curr; /* current device slot in use */
|
||
|
int max; /* max number of defined devices */
|
||
|
#ifdef MSWIN
|
||
|
HANDLE hDev; /* handle of device - NT only */
|
||
|
#endif
|
||
|
int fd; /* descriptor of device UNIX only */
|
||
|
};
|
||
|
PRI_RW struct uvdevitem UVDEVlist;
|
||
|
PRI_RW struct uvdevitem *UVDevice;
|
||
|
/* Statistics structure definition */
|
||
|
struct BK_time {
|
||
|
UVLONG start_time; /* Start time of backup/restore */
|
||
|
UVINT uvfile_cnt, /* Number of uv files processed */
|
||
|
uvfile_err, /* Number of broken uv files */
|
||
|
uvrec_cnt, /* Number of uv records saved */
|
||
|
uvrec_err, /* Number of uv records broken */
|
||
|
uvrec_data, /* Number of uv record bytes */
|
||
|
uxfile_cnt, /* Number of non-uv files seen */
|
||
|
uxfile_err, /* Number of broken non-uv files */
|
||
|
uxfile_data; /* Number of non-uv bytes saved */
|
||
|
};
|
||
|
PRI_RW struct BK_time *Timings;
|
||
|
|
||
|
struct uv_stat_buf Statbuf;
|
||
|
/*****************************************************************************/
|
||
|
/* Macro to initialize UVDevice structure */
|
||
|
#ifdef MSWIN
|
||
|
#define UVDEVICE_INIT { \
|
||
|
for(UVDevice->curr=0;UVDevice->curr<UVBAKMAX;UVDevice->curr++)\
|
||
|
{ \
|
||
|
UVDevice->list[UVDevice->curr][0] = '\0';\
|
||
|
UVDevice->orig[UVDevice->curr][0] = '\0';\
|
||
|
}\
|
||
|
UVDevice->max = 0;\
|
||
|
UVDevice->curr = (int)INVALID_HANDLE_VALUE;\
|
||
|
if (UVDevice->hDev != INVALID_HANDLE_VALUE) CloseHandle(UVDevice->hDev);\
|
||
|
UVDevice->hDev = INVALID_HANDLE_VALUE;\
|
||
|
}
|
||
|
#else
|
||
|
#define UVDEVICE_INIT { \
|
||
|
for(UVDevice->curr=0;UVDevice->curr<UVBAKMAX;UVDevice->curr++)\
|
||
|
{ \
|
||
|
UVDevice->list[UVDevice->curr][0] = '\0';\
|
||
|
UVDevice->orig[UVDevice->curr][0] = '\0';\
|
||
|
}\
|
||
|
UVDevice->max = 0;\
|
||
|
UVDevice->curr = -1;\
|
||
|
if (UVDevice->fd >=0) close(UVDevice->fd);\
|
||
|
UVDevice->fd = -1;\
|
||
|
}
|
||
|
#endif /* MSWIN */
|
||
|
#define END_o_DEVICE {\
|
||
|
if (!strcmp(UVDevice->orig[UVDevice->curr],UVDevice->list[UVDevice->curr]))\
|
||
|
{ /* path is same as device name */\
|
||
|
DisplayMessage(uvgetmsg(85496,*Reel_number,map_c_to_internal(UVDevice->orig[UVDevice->curr])));\
|
||
|
}\
|
||
|
else\
|
||
|
{ /* path is different from device name */\
|
||
|
char xtmp[1024];\
|
||
|
(void)strcpy(xtmp,UVDevice->orig[UVDevice->curr]);\
|
||
|
(void)strcat(xtmp," [");\
|
||
|
(void)strcat(xtmp,UVDevice->list[UVDevice->curr]);\
|
||
|
(void)strcat(xtmp,"] ");\
|
||
|
DisplayMessage(uvgetmsg(85496,*Reel_number,map_c_to_internal(xtmp)));\
|
||
|
/*Rfree(xtmp);*/\
|
||
|
}\
|
||
|
}
|
||
|
/*****************************************************************************/
|
||
|
/* Conversion macros - converts 8bytes ascii to 64bit integer.
|
||
|
** This macro will load a 64bit integer if the OS supports it, otherwise
|
||
|
** the high 32bits will be discarded and the low 32bits loaded. */
|
||
|
#if IS_64BIT_ADDR == 1
|
||
|
#define load64bit(x,y) if (Fdesc.addr_support == NEW64) {\
|
||
|
x = (0x00000000000000ff & y);\
|
||
|
x = (x << 8) + (0x00000000000000ff & y);\
|
||
|
x = (x << 8) + (0x00000000000000ff & y);\
|
||
|
x = (x << 8) + (0x00000000000000ff & y);\
|
||
|
x = (x << 8) + (0x00000000000000ff & y);\
|
||
|
x = (x << 8) + (0x00000000000000ff & y);\
|
||
|
x = (x << 8) + (0x00000000000000ff & y);\
|
||
|
x = (x << 8) + (0x00000000000000ff & y);\
|
||
|
} else {\
|
||
|
int value;\
|
||
|
load32bit(value,y);\
|
||
|
load32bit(x,y);\
|
||
|
}
|
||
|
#else
|
||
|
#define load64bit(x,y) {\
|
||
|
int value;\
|
||
|
load32bit(value,y);\
|
||
|
load32bit(x,y);\
|
||
|
}
|
||
|
#endif
|
||
|
/* converts 4bytes ascii to 32bit integer */
|
||
|
#define load32bit(x,y) {\
|
||
|
x = (0x000000ff & y);\
|
||
|
x = (x << 8) + (0x000000ff & y);\
|
||
|
x = (x << 8) + (0x000000ff & y);\
|
||
|
x = (x << 8) + (0x000000ff & y);\
|
||
|
}
|
||
|
/* converts 2bytes ascii to short */
|
||
|
#define load16bit(x,y) {\
|
||
|
x = (0x00ff & y);\
|
||
|
x = (x << 8) + (0x00ff & y);\
|
||
|
}
|
||
|
/* converts 4- or 8-byte ascii to 32/64bit integers */
|
||
|
#define loadint(x,y) if (Revision >= REVISION07) {\
|
||
|
load64bit(x,y);\
|
||
|
} else {\
|
||
|
load32bit(x,y);\
|
||
|
}
|
||
|
|
||
|
#define putbyte(x,y) y = (int)x;
|
||
|
|
||
|
/* converts 64bit integer to 8bytes ascii
|
||
|
** This macro will always save 64bits, but may pad the high 32bits
|
||
|
** with zeros if the current File is not 64bit. */
|
||
|
#if IS_64BIT_ADDR == 1
|
||
|
#define store64bit(x,y) if (Fdesc.addr_support == NEW64) {\
|
||
|
putbyte((0x00000000000000ff & (x >> 56)),y)\
|
||
|
putbyte((0x00000000000000ff & (x >> 48)),y)\
|
||
|
putbyte((0x00000000000000ff & (x >> 40)),y)\
|
||
|
putbyte((0x00000000000000ff & (x >> 32)),y)\
|
||
|
putbyte((0x00000000000000ff & (x >> 24)),y)\
|
||
|
putbyte((0x00000000000000ff & (x >> 16)),y)\
|
||
|
putbyte((0x00000000000000ff & (x >> 8)),y)\
|
||
|
putbyte((0x00000000000000ff & x),y);\
|
||
|
} else {\
|
||
|
store32bit(0,y);\
|
||
|
store32bit(x,y);\
|
||
|
}
|
||
|
#else
|
||
|
#define store64bit(x,y) {\
|
||
|
store32bit(0,y);\
|
||
|
store32bit(x,y);\
|
||
|
}
|
||
|
#endif
|
||
|
/* converts 32bit integer to 4bytes ascii */
|
||
|
#define store32bit(x,y) \
|
||
|
putbyte((0x000000ff & (x >> 24)),y)\
|
||
|
putbyte((0x000000ff & (x >> 16)),y)\
|
||
|
putbyte((0x000000ff & (x >> 8)),y)\
|
||
|
putbyte((0x000000ff & x),y);
|
||
|
/* converts short to 2 ytes ascii */
|
||
|
#define store16bit(x,y) \
|
||
|
putbyte((0x000000ff & (x >> 8)),y)\
|
||
|
putbyte((0x000000ff & x),y);
|
||
|
/* routes to correct macro */
|
||
|
#define storeint(x,y) if (REVISION_current >= REVISION07) {\
|
||
|
store64bit(x,y);\
|
||
|
} else {\
|
||
|
store32bit(x,y);\
|
||
|
}
|
||
|
/*****************************************************************************/
|
||
|
/* used during uvbackup */
|
||
|
#define CHECK_RETURN_VALUE if (retval == EXIT_ON_USER_REQ)\
|
||
|
{ if (File_opened)\
|
||
|
{ close(File_pointer);\
|
||
|
File_opened=FALSE;\
|
||
|
}\
|
||
|
return(EXIT_ON_USER_REQ);\
|
||
|
}\
|
||
|
else\
|
||
|
wrote_out = TRUE;
|
||
|
/*****************************************************************************/
|
||
|
/* Startup macros - Option x previously set. Ignored. */
|
||
|
#define ALREADY_SET_OPTION(x) ( fprintf(stderr,GENMSG(1),x) )
|
||
|
/* Incompatible option x when using option y. */
|
||
|
#define INCOMPATIBLE_OPTION(x,y) ( fprintf(stderr,GENMSG(2),x,y) )
|
||
|
/* Invalid option x */
|
||
|
#define ILLEGAL_OPTION(x) ( fprintf(stderr,GENMSG(3),x) )
|
||
|
/* Invalid argument */
|
||
|
#define INVALID_ARG ( fprintf(stderr,GENMSG(4)) )
|
||
|
/* Option not implemented */
|
||
|
#define NOT_YET_IMPLEMENTED(x) ( fprintf(stderr,GENMSG(8),x) )
|
||
|
/* Multiple revision keywords are not allowed */
|
||
|
#define MULTIPLE_REVISIONS_ILLEGAL ( fprintf(stderr,GENMSG(16)) )
|
||
|
/* This is the special macro used to generate messages found **
|
||
|
** in the msg.text file in the uvhome directory */
|
||
|
#define GENMSG(xxxx) ( ( (xxxx) > bakmax ) ?\
|
||
|
( sprintf(defmsg,"Message[BAK%04d]\n",(xxxx)), defmsg ) :\
|
||
|
( bakmsg[(xxxx-1)] != ZERO ?\
|
||
|
bakmsg[(xxxx-1)] :\
|
||
|
( sprintf(defmsg,"Message[BAK%04d]\n",(xxxx)),\
|
||
|
defmsg )))
|
||
|
#define GET_NEXT_PARAM param++;\
|
||
|
if (param >= argc)\
|
||
|
{ INVALID_ARG;\
|
||
|
return(EXIT_INVALID);\
|
||
|
}
|
||
|
|
||
|
#define GROUP_ERROR \
|
||
|
/* Unable to complete operation */\
|
||
|
DisplayMessage(uvgetmsg(85566));\
|
||
|
/* Prompt */\
|
||
|
DisplayMessage(uvgetmsg(85571));\
|
||
|
/* phantom auto skips file on error */\
|
||
|
if (A_phantom) return(FILE_SKIPPED);\
|
||
|
/* switch to upper case */\
|
||
|
Emulated_tty.ucase.invert = TRUE;\
|
||
|
/* read answer from stdin */\
|
||
|
answer = input(' ',10,0);\
|
||
|
/* switch to lower case */\
|
||
|
Emulated_tty.ucase.invert = FALSE;\
|
||
|
/* If user did not respond with a C or c, then skip file remainder */\
|
||
|
if (answer.text[0]!='c' && answer.text[0]!='C')\
|
||
|
{ /* user did not chose to continue with this file */\
|
||
|
return(FILE_SKIPPED);\
|
||
|
}
|
||
|
|
||
|
#define GROUP_ERROR_RETRY(msg) \
|
||
|
/* Unable to complete operation */\
|
||
|
DisplayMessage(uvgetmsg(85566));\
|
||
|
/* Prompt */\
|
||
|
DisplayMessage(uvgetmsg(85578));\
|
||
|
/* phantom auto skips file on error */\
|
||
|
if (A_phantom) return(msg);\
|
||
|
/* switch to upper case */\
|
||
|
Emulated_tty.ucase.invert = TRUE;\
|
||
|
/* read answer from stdin */\
|
||
|
answer = input(' ',10,0);\
|
||
|
/* switch to lower case */\
|
||
|
Emulated_tty.ucase.invert = FALSE;\
|
||
|
/* If user did not respond with a C or c, then skip file remainder */\
|
||
|
if (answer.text[0]!='c' && answer.text[0]!='C')\
|
||
|
{ /* user did not chose to continue with this file */\
|
||
|
return(msg);\
|
||
|
}\
|
||
|
retry = 10;
|
||
|
/*****************************************************************************/
|
||
|
#define Xfree(x) {Rfree(x); x=ZERO;}
|
||
|
#define Ifree(x) {if(x) {Rfree(x); x=ZERO;}}
|
||
|
/*****************************************************************************/
|
||
|
/* SourceOS contains the number identifying the OS of this system */
|
||
|
/* BackupOS contains the number identifying the OS of the system */
|
||
|
/* the backup image was made on, initialised to 00 for unix. */
|
||
|
/* NOTE: that both of these must be exactly two chars to work. */
|
||
|
/* a value of 00 identifies Unix OS */
|
||
|
#define _OSunix "00"
|
||
|
#define _OSnt "01"
|
||
|
#ifdef MSWIN
|
||
|
PRI_RO char _SourceOS[] = _OSnt;
|
||
|
PRI_RW char _BackupOS[] = _OSnt;
|
||
|
#else
|
||
|
PRI_RO char _SourceOS[] = _OSunix;
|
||
|
PRI_RW char _BackupOS[] = _OSunix;
|
||
|
#endif
|
||
|
PRI_RO uchar _uvbackupNT[] ="uvbackup.exe";
|
||
|
PRI_RO uchar _uvrestoreNT[] ="uvrestore.exe";
|
||
|
PRI_RO uchar _uvrestore[] = "uvrestore";
|
||
|
PRI_RO uchar _uvbackup[] = "uvbackup";
|
||
|
PRI_RO uchar _BackupTrailer[] = "EndOfUvbackup";
|
||
|
PRI_RO uchar _RestoreTrailer[] = "EndOfUvrestore";
|
||
|
/*****************************************************************************/
|
||
|
/* The following flag is used on unix when restoring a backup from NT.
|
||
|
* In an NT backup image the pathnames of the backed-up files may have
|
||
|
* a DOS style drive letter at the start of the path and this MUST be
|
||
|
* removed for a unix restore operation. On Unix, if the backup is an
|
||
|
* NT image (identified by the header) the falg is set TRUE.
|
||
|
* On NT it is set up via the "-nodrv" command line option.
|
||
|
*/
|
||
|
PRI_RW int stripDOSdrive = FALSE;
|
||
|
PRI_RW int sameOS = TRUE;
|
||
|
/*****************************************************************************/
|
||
|
/* Constant strings */
|
||
|
PRI_RO char dictdot[] = "D_.";
|
||
|
PRI_RO char ctlmap[] = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ12345";
|
||
|
PRI_RW char _UVBACKUP[] = "UVBACKUP"; /* token for DBopen_acl function */
|
||
|
PRI_RO char _slash[] = "/"; /* forward slash char */
|
||
|
PRI_RO char Wildcard = '*'; /* pseudo wildcard */
|
||
|
PRI_RO char _newline[] = "\n"; /* newline char */
|
||
|
/*****************************************************************************/
|
||
|
/* External executables and options */
|
||
|
#if CHOWNCALL != 1
|
||
|
PRI_RO char _binuvpset[] = "bin/uvpset"; /* set utility */
|
||
|
PRI_RO char _uvpset[] = "uvpset"; /* uv permissions set utility */
|
||
|
PRI_RO char _uvpsetpwd[] = "/etc/cron"; /* uvpset pword */
|
||
|
#endif
|
||
|
|
||
|
PRI_RO char _binrm[] = "/bin/rm"; /* full path */
|
||
|
PRI_RO char _rm[] = "rm"; /* remove command */
|
||
|
PRI_RO char _rf[] = "-rf"; /* remove/force */
|
||
|
|
||
|
PRI_RO char _VOC[] = "VOC"; /* name of voc file */
|
||
|
/*****************************************************************************/
|
||
|
/* CACHE buffer variables */
|
||
|
PRI_RW int Cache_cnt = 0; /* Number of chars in Cache */
|
||
|
PRI_RW int Cache_max = 0; /* Max num of char in Cache, or blocksiz */
|
||
|
PRI_RW char *Cache; /* ptr to Cache buffer*/
|
||
|
PRI_RW char *Cache_ptr; /* ptr into Cache */
|
||
|
PRI_RW char *Cache_orig; /* orig addr of Cache */
|
||
|
PRI_RW char *RDCache; /* ptr to Cache for ReaderEngine */
|
||
|
/*****************************************************************************/
|
||
|
PRI_RW char Buffer[BLKSIZ]; /* Buffer for reading data */
|
||
|
PRI_RW char *Bufptr; /* ptr to buffer */
|
||
|
PRI_RW char Last_valid_path[2048]; /* Last known valid directory */
|
||
|
PRI_RW int Last_valid_len = 0;
|
||
|
/*****************************************************************************/
|
||
|
/* DATA buffer variables */
|
||
|
PRI_RW char *Data; /* ptr to restore data */
|
||
|
PRI_RW UVINT Data_len = 0; /* Length of Data */
|
||
|
PRI_RW int Data_max = BLKSIZ; /* Max num of chars in Data */
|
||
|
PRI_RW int Data_pos = 0; /* position witin Data Buffer */
|
||
|
PRI_RW int Data_read = 0; /* no of chars actually read */
|
||
|
PRI_RW UVINT Data_written = 0; /* no of chars actually written */
|
||
|
PRI_RW int N_opt_written = 0; /* used for N option */
|
||
|
PRI_RW int BundleIDX = 0; /* gtar 18114 */
|
||
|
PRI_RW char Previous_data_type; /* previous data type */
|
||
|
/*****************************************************************************/
|
||
|
/* General COMMAND LINE options */
|
||
|
PRI_RO char _dash[] = "-"; /* READ_FROM_STDIN */
|
||
|
PRI_RO char _dash_b[] = "-b"; /* BLOCK_SIZE */
|
||
|
PRI_RO char _dash_l[] = "-l"; /* LABEL */
|
||
|
PRI_RO char _dash_v[] = "-v"; /* VERBOSE */
|
||
|
PRI_RO char _dash_vf[] = "-vf"; /* VERBOSE file det */
|
||
|
PRI_RO char _dash_V[] = "-V"; /* RECORD_VERBOSE */
|
||
|
PRI_RO char _dash_t[] = "-t"; /* devices */
|
||
|
/*****************************************************************************/
|
||
|
/* uvbackup ONLY command line options */
|
||
|
PRI_RO char _dash_f[] = "-f"; /* FULL_BACKUP */
|
||
|
PRI_RO char _dash_w[] = "-w"; /* WEEKLY_BACKUP */
|
||
|
PRI_RO char _dash_d[] = "-d"; /* DAILY_BACKUP */
|
||
|
PRI_RO char _dash_s[] = "-s"; /* dup stderr to file */
|
||
|
PRI_RO char _dash_2[] = "-2"; /* Rev2 compatible - no blocksum */
|
||
|
PRI_RO char _dash_rev7[] = "-rev7"; /* Synonym for -2 */
|
||
|
PRI_RO char _dash_rev8[] = "-rev8"; /* Make revision 8 compatible backup */
|
||
|
PRI_RO char _dash_rev93[] = "-rev93"; /* Make revision 9.3 compatible backup */
|
||
|
PRI_RO char _dash_rev94[] = "-rev94"; /* Make revision 9.4 compatible backup */
|
||
|
PRI_RO char _dash_rev95C[] = "-rev95"; /* Make revision 9.5C compatable backup */
|
||
|
PRI_RO char _dash_limit[] = "-limit"; /* utilize argument number of shmem caches */
|
||
|
PRI_RO char _dash_delay[] = "-delay"; /* number of cache that must be filled */
|
||
|
PRI_RO char _dash_Cdetail[] = "-cachedetail"; /* show cache detail */
|
||
|
PRI_RO char _dash_cmdfil[] = "-cmdfil"; /* cmd file with list of backup files */
|
||
|
#ifdef MSWIN
|
||
|
PRI_RO char _dash_walk[] = "-walk"; /* use walk to generate the list on the fly */
|
||
|
#endif
|
||
|
/*****************************************************************************/
|
||
|
/* uvrestore ONLY command line options */
|
||
|
PRI_RO char _dash_i[] = "-i"; /* INDEX_ONLY */
|
||
|
PRI_RO char _dash_ib[] = "-ib"; /* INDEX and BLOCK */
|
||
|
PRI_RO char _dash_n[] = "-n"; /* NOT AUTOCREATE */
|
||
|
PRI_RO char _dash_p[] = "-p"; /* PROMPT B4 Restore*/
|
||
|
PRI_RO char _dash_F[] = "-F"; /* FILE_RESTORE */
|
||
|
PRI_RO char _dash_L[] = "-L"; /* LABEL_ONLY */
|
||
|
PRI_RO char _dash_N[] = "-N"; /* NonExistantOnly */
|
||
|
PRI_RO char _dash_R[] = "-R"; /* RECORD_RESTORE */
|
||
|
PRI_RO char _dash_U[] = "-U"; /* OVERWRITING */
|
||
|
PRI_RO char _dash_P[] = "-P"; /* PAGINATE output */
|
||
|
PRI_RO char _dash_X[] = "-X"; /* Excluded Files */
|
||
|
PRI_RO char _plus_I[] = "+I"; /* restore INDEX with file */
|
||
|
PRI_RO char _dash_B[] = "-B"; /* bug with uv_tables, uv_column file */
|
||
|
PRI_RO char _dash_startb[] = "-startb"; /* skip up to given block */
|
||
|
PRI_RO char _dash_rehash[] = "-rehash"; /* don't use fast group write */
|
||
|
PRI_RO char _dash_verify[] = "-verify"; /* verify image */
|
||
|
PRI_RO char _dash_nocsum[] = "-nocsum"; /* disable checksums */
|
||
|
PRI_RO char _dash_hdrsiz[] = "-hdrsiz"; /* sets size of image header */
|
||
|
#ifdef MSWIN
|
||
|
PRI_RO char _dash_nodrv[] = "-nodrv"; /* Strip DOS drive letter from */
|
||
|
/* restored filenames */
|
||
|
#endif
|
||
|
/*****************************************************************************/
|
||
|
/* Alternate Index Identifier tokens */
|
||
|
PRI_RO char I_check[] = "I_"; /* check for alt index */
|
||
|
PRI_RO char I_check2[] = "INDEX."; /* 2nd check for alt index */
|
||
|
/*****************************************************************************/
|
||
|
/* Default settings for options */
|
||
|
PRI_RW int Autocreate = TRUE; /* AUTOCREATE */
|
||
|
PRI_RW int Blksiz_max = 0; /* BLOCK_SIZE */
|
||
|
PRI_RW int Blkcount = 0; /* Number of blocks processed */
|
||
|
PRI_RW int Display_label = FALSE; /* LABEL */
|
||
|
PRI_RW short Image_type = 0; /* FULL, WEEKLY, DAILY */
|
||
|
PRI_RW int Dump_TOC = FALSE; /* INDEX_ONLY */
|
||
|
PRI_RW int Dump_BLK = FALSE; /* INDEX_ONLY show BLKS */
|
||
|
PRI_RW int Label_only = FALSE; /* LABEL_ONLY */
|
||
|
PRI_RW int Prompt_user = FALSE; /* PROMPT */
|
||
|
PRI_RW int Prompt_hold = FALSE; /* used by prompt_to_restore */
|
||
|
PRI_RW int Read_from_stdin = FALSE; /* READ_STDIN */
|
||
|
PRI_RW int VerboseFileMsg = FALSE; /* used with N option */
|
||
|
PRI_RW int NonExistOnly = FALSE; /* NonExistantOnly */
|
||
|
PRI_RW int LoadIndex = FALSE; /* Load INDEX with file */
|
||
|
PRI_RW int VerifyImage = FALSE; /* Used with -verify option */
|
||
|
PRI_RW int VerifyChecksum = TRUE ; /* Used with -nocsum option */
|
||
|
PRI_RW int VerifyHdrsize = 0 ; /* Used with -hdrsiz option */
|
||
|
PRI_RW int FileInfoOut = 0 ; /* Used with -vf option */
|
||
|
/****************************************************************************/
|
||
|
PRI_RW int Restore = FALSE; /* Restore or Backup */
|
||
|
PRI_RW int Uncond_restore = FALSE; /* OVERWRITE */
|
||
|
PRI_RW int Verbose = FALSE; /* VERBOSE level */
|
||
|
PRI_RW int Line_counter = 1; /* Current Line output */
|
||
|
PRI_RW int Line_maximum = 0; /* Maximum Line output */
|
||
|
PRI_RW int Data_bug_flag = FALSE; /* Do data records have bug? */
|
||
|
PRI_RW int Blk_to_start = 0; /* from -startb # option */
|
||
|
PRI_RW int Fast_Group_Load = TRUE; /* from -rehash option */
|
||
|
PRI_RW int Read_from_cmdfil= FALSE; /* Read from command file */
|
||
|
PRI_RW int Read_from_walk = FALSE; /* Use the walk command */
|
||
|
/*****************************************************************************/
|
||
|
/* Miscellaneous Declarations */
|
||
|
PRI_RW char Labeltext[81]; /* User specified LABEL text */
|
||
|
PRI_RW char Logfile_path[256]; /* Stderr to file -s */
|
||
|
PRI_RW char Cmdfile_path[256]; /* Cmd file for backup - list of files */
|
||
|
#ifdef MSWIN
|
||
|
PRI_RW HANDLE pipe_fd[2]; /* Pipe handle to talk to uvwalk with */
|
||
|
PRI_RW STRING walk_path; /* String to contain the walk path */
|
||
|
#endif
|
||
|
/*****************************************************************************/
|
||
|
/* SECURITY details */
|
||
|
PRI_RW int Mode_val = 0; /* file permissions */
|
||
|
PRI_RW int Uid_val = 0; /* owner id */
|
||
|
PRI_RW int Gid_val = 0; /* group id */
|
||
|
PRI_RW int Is_super_user = FALSE; /* is superuser ? */
|
||
|
/*****************************************************************************/
|
||
|
/* "F" & "U" LEVEL variables */
|
||
|
PRI_RW int Restore_file = MINUS_ONE; /* file Restored */
|
||
|
PRI_RW char File_curr[2048]; /* current file for uvbackup */
|
||
|
PRI_RW char File_prev[2048]; /* previous file for restore */
|
||
|
PRI_RW int File_continued = FALSE; /* file on multiple devices */
|
||
|
PRI_RW int File_exists = TRUE; /* is file on disk */
|
||
|
PRI_RW int File_opened = FALSE; /* is file opened */
|
||
|
PRI_RW int File_pointer = 0; /* descriptor of file */
|
||
|
PRI_RW UVINT File_rec_count = 0; /* records processed */
|
||
|
PRI_RW int Osfileleft_curr = 0; /* Len to process of osfile image current */
|
||
|
PRI_RW int Osfileleft_save = 0; /* Len to process of osfile image saved */
|
||
|
PRI_RW int File_flags = 0; /* various bit flags of the file */
|
||
|
/*****************************************************************************/
|
||
|
/* "R" LEVEL variables */
|
||
|
PRI_RW STRING Record_key; /* record key */
|
||
|
PRI_RW int Write_record = FALSE; /* Restore Data */
|
||
|
/*****************************************************************************/
|
||
|
/* IMAGE && IMAGE DEVICE variables */
|
||
|
PRI_RW int ReelNBR = 0; /* current image number */
|
||
|
PRI_RW int *Reel_number; /* pointer to ReelNBR */
|
||
|
PRI_RW int Old_reel = 0; /* Previous image number */
|
||
|
PRI_RW int Revision = 0; /* Revision from image */
|
||
|
PRI_RW int End_of_image = FALSE; /* indicates end of image */
|
||
|
PRI_RW int Rewind_device = FALSE; /* Rewind current? */
|
||
|
/*****************************************************************************/
|
||
|
/* HEADER variables */
|
||
|
PRI_RW char *Head_buffer; /* header data */
|
||
|
PRI_RW int Buffersize = 2048; /* Starting buffer size */
|
||
|
PRI_RW char *Image_header; /* ptr to Image header */
|
||
|
PRI_RW int U_hdr_len = 0; /* Len of osfile header */
|
||
|
PRI_RW char *Unix_header; /* ptr to osfile header */
|
||
|
PRI_RW int F_hdr_len = 0; /* Len of File header */
|
||
|
PRI_RW char *File_header; /* ptr to F file header */
|
||
|
PRI_RW int R_hdr_len = 0; /* Len of Record header */
|
||
|
PRI_RW char *Record_header; /* ptr to Record header */
|
||
|
PRI_RW char *Group_header; /* ptr to group header */
|
||
|
PRI_RW char *Data_header; /* ptr to data header */
|
||
|
/*****************************************************************************/
|
||
|
/* SQL variables */
|
||
|
PRI_RW UVSICAREGION *Sica; /* ptr to sica region */
|
||
|
PRI_RW int Sicalen; /* length of sica */
|
||
|
PRI_RW UVSICAREGION00 *Sica00; /* ptr to sica region */
|
||
|
PRI_RW char *Schema; /* ptr to schema */
|
||
|
/*****************************************************************************/
|
||
|
/* file status bits */
|
||
|
#define A64BITFILE 1
|
||
|
#define CLRB4RESTORE 2
|
||
|
#define IS_64BIT_FILE (File_flags & A64BITFILE)
|
||
|
#define DO_FILECLEAR (File_flags & CLRB4RESTORE)
|
||
|
/*****************************************************************************/
|
||
|
/* External function declarations */
|
||
|
EXTERN UVSICAREGION *DBdecodeSICA(),
|
||
|
*DBreadSICA(),
|
||
|
*DBencodeSICA(),
|
||
|
*DBwriteSICA();
|
||
|
EXTERN UVSICAREGION00 *mkv0(); /* convert v1 or v2 sica to v0 */
|
||
|
EXTERN UVSICAREGION02 *mkv2(); /* convert v3 sica to v2 */
|
||
|
EXTERN UVSICAREGION03 *mkv3f4(); /* convert v4 sica to v3 */
|
||
|
EXTERN STRING oconv(), dyn_extract(),
|
||
|
dyn_delete(), dyn_replace(),
|
||
|
field(), *DBread_part(),*map_uv_to_internal(),
|
||
|
input(), trim(), uvgetmsg(), numbertoa();
|
||
|
EXTERN pid_t getpid(), fork(), wait();
|
||
|
EXTERN UVLONG now();
|
||
|
EXTERN UVOFFT netlseekdisp();
|
||
|
EXTERN void initmsg(), DBrelover(),
|
||
|
uv_init_global_function_pointers(),
|
||
|
uv_init_runtime_environment(),
|
||
|
uv_init_SQL_environment(),
|
||
|
uv_cleanup_runtime_environment(),
|
||
|
shminit(), DBsuspend();
|
||
|
EXTERN char *getcwd(), *getuvhome(), *abspath(),*map_c_to_internal();
|
||
|
EXTERN int STRdiff(), NLSLCFindLocale(), DBwrite_pads(),
|
||
|
count(), strpathncmp(), DBopen_acl(), mkpath(),callunix(), DBclrfl(),
|
||
|
DBset_write(), DBwrite_part(), strpathcmp(), DBrblok(), DBwblok(),
|
||
|
filehdr_get_offsize(), do_mkdb();
|
||
|
PUB_RO int WriteBlockToUVDevice(), ReadImageHeader(),
|
||
|
prompt_for_new_devices(), translate_uvdevices(),
|
||
|
SetFilePermissions(),RestoreDistributedRecord(),
|
||
|
UpdateUniverseFile(),UpdateSica(),BackupDistributedRecord(),
|
||
|
start_uvwalk(), ClearGroup(), FastGroupWrite(), FastGroupFlush();
|
||
|
PUB_RO void set_signals();
|
||
|
#ifndef MSWIN
|
||
|
EXTERN int isatty(),errno, atoi(),
|
||
|
strncmp(), Get_next_uvdevice(),
|
||
|
pwrite(), pread();
|
||
|
EXTERN char *strchr();
|
||
|
#else
|
||
|
PUB_RO int convert_nt_slashes();
|
||
|
#endif
|
||
|
/*****************************************************************************/
|
||
|
/* External variables */
|
||
|
EXTERN int Convertsica;
|
||
|
EXTERN int signature; /* user signature from startup */
|
||
|
EXTERN int Mypid; /* Process id of current process */
|
||
|
#if OURMALLOC
|
||
|
EXTERN int Mnabort; /* flag to not fatal when out of memory */
|
||
|
#endif
|
||
|
EXTERN DBITEMNEW *DBbuf; /* Data buffer for DBblok read */
|
||
|
EXTERN int ovf30; /* for indication if in OVER.30 file */
|
||
|
EXTERN int T30zero_is_locked; /* indicates existing lock on t30 file */
|
||
|
EXTERN int watchlock; /* status from locking */
|
||
|
EXTERN int NET_signature; /* unique user sig */
|
||
|
EXTERN uchar *NLSsortmapstr; /* for use with do_mkdb function call */
|
||
|
/*****************************************************************************/
|
||
|
/* External structures */
|
||
|
EXTERN struct DBsegment *DBshmseg;
|
||
|
EXTERN struct SHdata SHd_global;
|
||
|
/*****************************************************************************/
|
||
|
/* SICA declarations */
|
||
|
PRI_RW int Sicaprompt = TRUE; /* prompt before converting sica */
|
||
|
PRI_RW int Sicaaction = TRUE; /* convert sica */
|
||
|
/*****************************************************************************/
|
||
|
/* DISTRIBUTED FILE variables */
|
||
|
PUB_RW STRING *pf_block;
|
||
|
PRI_RW STRING PF_block; /* part file block */
|
||
|
/*****************************************************************************/
|
||
|
/* MISCELLANEOUS variables */
|
||
|
PRI_RW DBFILE Fdesc; /* for DBopen */
|
||
|
PRI_RW LAYER layer; /* layer */
|
||
|
PRI_RW FILE *Input_chan; /* Remapped stdin */
|
||
|
PRI_RW FILE *Logfile = 0; /* logfile */
|
||
|
PRI_RO STRING A_space = { 1," " }; /* literal space string */
|
||
|
PRI_RW STRING Filename; /* uvrestore file */
|
||
|
PRI_RW STRING Save_stamp; /* Orig Label timestamp */
|
||
|
PRI_RW STRING New_line; /* Newline string */
|
||
|
PRI_RW STRING origname; /* original file name */
|
||
|
PRI_RW char Temp[2048]; /* junk area */
|
||
|
PRI_RW char NLSnewsortmap[256]; /* holds NLS option for mkdbfile */
|
||
|
PRI_RW char **bakmsg = ZERO; /* for msg.text file support */
|
||
|
PRI_RW char defmsg[20]; /* for msg.text file support */
|
||
|
PRI_RW char *Akpath; /* ptr to alt index path */
|
||
|
PRI_RW char *Current_dir; /* ptr to 'cwd' return */
|
||
|
PRI_RW char *Filepath_curr; /* ptr to filepath current */
|
||
|
PRI_RW char *Filepath_save; /* ptr to filepath saved */
|
||
|
PRI_RW int bakmax = 0; /* for msg.txt file support */
|
||
|
PRI_RW int A_phantom = FALSE; /* is current process a phantom */
|
||
|
PRI_RW int A_DBopen = FALSE; /* did DBopen succeed? */
|
||
|
PRI_RW int End_of_restore = FALSE; /* Flag indicating found TRAILER */
|
||
|
PRI_RW int Errcode = FALSE; /* longjump pointer */
|
||
|
PRI_RW int Found_blksiz = 0; /* Used in auto block size code */
|
||
|
PRI_RW int nlsbackup; /* Was backup made with NLS on or off? */
|
||
|
PRI_RW long Mtime_val; /* Mod time value */
|
||
|
PRI_RW int SleepVal=0; /* sleep value */
|
||
|
PRI_RW int File_offset = 0; /* File_curr index */
|
||
|
/*****************************************************************************/
|
||
|
/* UniVerse'ism declarations */
|
||
|
PRI_RO char _Type1[] = ".Type1"; /* Marker denoting a type 1 file */
|
||
|
PRI_RO char _Type30[] = ".Type30"; /* Marker denoting a type 30 file */
|
||
|
PRI_RO char _OVER30[] = "OVER.30"; /* Secondary portion of dynamic file */
|
||
|
PRI_RO char _DATA30[] = "DATA.30"; /* Primary portion of dynamic file */
|
||
|
PRI_RO char _PROC[] = "/proc"; /* system partition of memory files */
|
||
|
/*****************************************************************************/
|
||
|
/* Maximum number of cache buffers that can exist within shared memory */
|
||
|
#ifdef MSWIN
|
||
|
#define CACHEMAX 1
|
||
|
#else
|
||
|
#define CACHEMAX 30
|
||
|
#endif
|
||
|
|
||
|
#if (COMPUTER == Solaris)
|
||
|
/* Maximum number of bytes in cache. solaris can only handle 64k block size*/
|
||
|
#define CACHEBLKSIZEMAX (32 * 1024)
|
||
|
#else
|
||
|
/* Maximum number of bytes in cache. Allow 128K block size */
|
||
|
#define CACHEBLKSIZEMAX (128 * 1024)
|
||
|
#endif
|
||
|
/* Shared Memory Key - use uv userno */
|
||
|
#define _BAKSHMKEY (0xabac0000 | (signature & 0x0000FFFF))
|
||
|
/* macro to tell is shared memory is being used */
|
||
|
#define USING_SHARED_MEM_CACHE (CacheLimit > 1)
|
||
|
#define WR_IN_USE 1
|
||
|
#define RD_IN_USE 2
|
||
|
/* meaning of ints in Control */
|
||
|
#define IMAGE_HDR_IN_CACHE1 0
|
||
|
#define WRITE_ENGINE_DUMP 1
|
||
|
#define TRAILER_HDR_IN_CACHE 2
|
||
|
#define SWITCH_MESSAGE_SHOWN 3
|
||
|
#define SHUT_DOWN_READER 4
|
||
|
#define SHUT_DOWN_WRITER 5
|
||
|
#define NEED_MORE_DEVICES 6
|
||
|
#define DISPLAY_NEW_HDR 7
|
||
|
/* Shared memory structure definition */
|
||
|
struct SharedCache
|
||
|
{
|
||
|
pid_t WR_engine_pid, /* pid number of data packaging engine */
|
||
|
RD_engine_pid; /* pid number of output engine */
|
||
|
int Control[10]; /* 0=free, 1=too bad */
|
||
|
int delay; /* delay variable */
|
||
|
int ShmCacheVal; /* Max integer value of cache buffer */
|
||
|
int Cache_state[CACHEMAX];
|
||
|
int ReelNBR; /* current reel number */
|
||
|
int WR_cache; /* current write cache */
|
||
|
int RD_cache; /* current read cache */
|
||
|
char ImageHDR[NHDRSIZ]; /* pointer to header */
|
||
|
struct uvdevitem UVDEVlist; /* shared device list */
|
||
|
char CacheBlock[CACHEMAX * CACHEBLKSIZEMAX]; /* cache block */
|
||
|
};
|
||
|
PRI_RW int BAKshmkey = 0; /* Pointer to shared memory */
|
||
|
PRI_RW struct SharedCache *BAKshmseg; /* Pointer to mapped shared memory */
|
||
|
PRI_RW int CacheLimit = CACHEMAX; /* number of cache buffers to use */
|
||
|
PRI_RW int DelayFactor = 0; /* delay startup for reader */
|
||
|
PRI_RW int CacheDetail = FALSE; /* output misc info about cache state */
|
||
|
PRI_RW int ReaderProcess =FALSE; /* Indicates if READER on command line */
|
||
|
|
||
|
#define DUMPSHMEM {\
|
||
|
fprintf(stderr,"\nCurrent Shared Cache...\n");\
|
||
|
fprintf(stderr,"WR_engine_pid=%i\n",BAKshmseg->WR_engine_pid);\
|
||
|
fprintf(stderr,"RD_engine_pid=%i\n",BAKshmseg->RD_engine_pid);\
|
||
|
fprintf(stderr,"Control=%i\n",BAKshmseg->Control[0]);\
|
||
|
fprintf(stderr,"delay=%i\treel#=%i\n",BAKshmseg->delay,BAKshmseg->ReelNBR);\
|
||
|
fprintf(stderr,"WR_cache=%i\tRD_cache=%i\n",BAKshmseg->WR_cache,BAKshmseg->RD_cache);\
|
||
|
fprintf(stderr,"ShmCacheVal=%i (%x)\n",BAKshmseg->ShmCacheVal,BAKshmseg->ShmCacheVal);\
|
||
|
fprintf(stderr,"Cache_state=%i\n",BAKshmseg->Cache_state[0]);\
|
||
|
}
|
||
|
#define DEVICE_CHECK if (BAKshmseg->Control[NEED_MORE_DEVICES])\
|
||
|
{ /* prompt new device */\
|
||
|
if ((prompt_for_new_devices()) == EXIT_ON_USER_REQ)\
|
||
|
{ /* Shut down child process */\
|
||
|
BAKshmseg->Control[SHUT_DOWN_READER] = 1;\
|
||
|
return(EXIT_ON_USER_REQ);\
|
||
|
}\
|
||
|
/* Clear lock */\
|
||
|
BAKshmseg->Control[NEED_MORE_DEVICES] = 0;\
|
||
|
} else if (BAKshmseg->Control[DISPLAY_NEW_HDR])\
|
||
|
{ /* Child requested header to be displayed */\
|
||
|
if (Display_label || Verbose)\
|
||
|
(void) ReadImageHeader(&BAKshmseg->ImageHDR);\
|
||
|
BAKshmseg->Control[DISPLAY_NEW_HDR] = 0;\
|
||
|
}\
|
||
|
|
||
|
#if COMPUTER == SEQUENT
|
||
|
/* This function does a shmat just like shmat except that it sets
|
||
|
** sets the close on exec bit of the file used to hold the
|
||
|
** shared memory */
|
||
|
struct DBsegment *seq_shmt( id, addr, accflg, crflg )
|
||
|
int id;
|
||
|
char *addr;
|
||
|
int accflg;
|
||
|
int crflg;
|
||
|
{
|
||
|
int test[_NFILE];
|
||
|
char *rval;
|
||
|
struct uv_stat_buf bf;
|
||
|
int j;
|
||
|
for( j = 0 ; j < _NFILE ; j++)
|
||
|
test[j] = uv_fstat(j,&bf);
|
||
|
|
||
|
rval = sm_attach_shm(id, addr, accflg, crflg );
|
||
|
|
||
|
for( j = 0 ; j < _NFILE ; j++)
|
||
|
{ if( test[j] != uv_fstat(j,&bf))
|
||
|
{ (void) fcntl( j,F_SETFD,1);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return((struct SharedCache *)rval);
|
||
|
}
|
||
|
#else
|
||
|
#define seq_shmt(a, b ,c, d) ((struct SharedCache *)sm_attach_shm(a, b, c, d))
|
||
|
#endif
|
||
|
#endif /* end of backup1.h */
|