****************************************************************************** * * System Admin Transaction Logging - Save Files from Raw device * * 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 intended * publication of such source code. * ******************************************************************************* * * Maintenence log - insert most recent change descriptions at top * * Date.... GTAR# WHO Description........................................ * 10/14/98 23801 SAP Change copyrights. * 06/26/98 23161 RGA Module created * ******************************************************************************* $OPTIONS INFORMATION id = "%W%" ******************************************************************************* $INCLUDE UNIVERSE.INCLUDE TLOG.H $INCLUDE UNIVERSE.INCLUDE FILENAMES.H $INCLUDE UNIVERSE.INCLUDE MACHINE.NAME $INCLUDE UNIVERSE.INCLUDE VMADMCMN.H $IFDEF UV.MSWIN $DEFINE COMMAND.SEPARATOR "&&" $ELSE $DEFINE COMMAND.SEPARATOR ";" $ENDIF EQU FULLSTATE TO 'F' SKIPREC = 0 * Initialize OPENED.FLAG = @FALSE DICT.OPENED.FLAG = @FALSE DICT.LOCKED.FLAG = @FALSE Open 'VOC' To VOC Else @SYSTEM.RETURN.CODE = -1 Return End * Look for VMADMDBG record in VOC. If it's present, switch DEBUGGING on Read Rec From VOC, "VMADMDBG" Then DEBUGGING = True End Else DEBUGGING = False End If DEBUGGING Then DebugFile = "./Debug_":@UserNo OpenSeq DebugFile To DEBUGFL Else Create DEBUGFL Else DEBUGGING = False End Seek DEBUGFL, -1, 2 Else Null LogText = Oconv(Date(), "D2/"):" ":Oconv(Time(), "MTS") GoSub WriteDbg End End If DEBUGGING Then LogText = "Initialising in LOGRAW.SAVE.B" GoSub WriteDbg End TMP = TRIM( @SENTENCE ) @SYSTEM.RETURN.CODE = 0 CNT = COUNT( TMP, " " ) IF ( CNT < 2 OR CNT > 6 ) THEN PRINT "Error: Incorrect number of arguments" @SYSTEM.RETURN.CODE = -1 END FirstLog = FIELD( TMP, " ", 2 ) LastLog = FIELD( TMP, " ", 3 ) PATH = FIELD( TMP, " ", 4 ) RAWPATH = FIELD( TMP, " ", 5 ) DELDSKLOGS = FIELD( TMP, " ",7) If DEBUGGING Then LogText = "Fl = ":FirstLog:" Ll = ":LastLog:" Path = ":PATH:" RAWP = ":RAWPATH:" DELDSKLOGS = ":DELDSKLOGS GoSub WriteDbg End * First, open UV_LOGS to check for any logs which have status * other than released. If so, then we disallow this operation * and return to user * Do some initialization GOSUB INIT * process list of log file numbers - we have at least one * If we drop out because SEQUENCE.NUMBER is zero an error * is sent back FOR I = 1 TO SEQUENCE.NUMBER GOSUB CHECK.LOGFILE IF SKIPREC <> 0 Then CONTINUE END IF EOF <> 0 THEN IF I < INT(SEQUENCE.NUMBER) THEN CONTINUE END END * * This will create normal log files in the PATH directory * Exec.uvfile = OS.EXEC:" '":UV.BIN:"/UVtlconvert ":RAWPATH:" ":FILE.OFFSET:" ":PATH:"'" If DEBUGGING Then LogText = "Exec.uvfile = ":Exec.uvfile GoSub WriteDbg End EXECUTE Exec.uvfile CAPTURING trashcan If DEBUGGING Then LogText = "trashcan = ":trashcan GoSub WriteDbg End * * Only if all files are converted will * the rest proceed * IF NOT(INDEX(trashcan, "1", 1)) THEN @SYSTEM.RETURN.CODE = -1 GOTO EXIT END NEXT I IF PATH = "" THEN * Use current logging directory RECIO( PATH, RECIO$PATH ) END * Check that the specified directory exists OPENPATH PATH TO FVAR THEN IF STATUS() <> 19 AND STATUS() <> 1 THEN PRINT "Error: ":PATH:" is not a directory." @SYSTEM.RETURN.CODE = -1 END END ELSE PRINT "Error: Unable to open ":PATH @SYSTEM.RETURN.CODE = -1 END CLOSE FVAR Device = FIELD( TMP, " ", 6 ) IF Device = "" THEN * use MT0 Device = "MT0" END * If Device is the id of a record in the &DEVICE& file then it is a * Universe device name otherwise its is an OS file name which on UNIX * could be an OS tape device name. OPEN "","&DEVICE&" TO FVAR ELSE PRINT "Error: Unable to open &DEVICE& file." @SYSTEM.RETURN.CODE = -1 END READV REC FROM FVAR,Device,0 ELSE Filename = Device Device = "" END CLOSE FVAR * Generate a list of log file names to save. list = "" FOR i = FirstLog TO LastLog list := " lg":i NEXT i IF @SYSTEM.RETURN.CODE = 0 AND list <> "" THEN * Get settings for terminal so that we can restore them after * uvbackup has completed. TTYGET tty.settings ELSE NULL * cd to logging directory and save using file name list so that the log files * can be easily restored somewhere else. * Blocksize of 512 is temporary workaround for Gtar 18540 Exec.Sentence = OS.EXEC:" 'cd ":PATH:COMMAND.SEPARATOR:UV.ROOT:"/bin/uvbackup -v -b 512 -f":list IF Device <> "" THEN Exec.Sentence := " -t ":Device END ELSE Exec.Sentence := " >":Filename END Exec.Sentence := "'" EXECUTE Exec.Sentence TTYSET tty.settings ELSE NULL END IF DELDSKLOGS <> "" THEN Exec.Sentence = "" Exec.Sentence = OS.EXEC:" 'rm ":PATH:"lg* " Exec.Sentence := "'" EXECUTE Exec.Sentence CAPTURING trashcan If DEBUGGING Then LogText = "trashcan = ":trashcan GoSub WriteDbg End END RETURN ********************************************************************** * WriteDbg - log debug text to file * Expects debug text in LogText variable ********************************************************************** WriteDbg: WriteSeq Change(LogText, @fm, Char(10)) On DEBUGFL Else Null Seek DEBUGFL, 0, 2 Else Null Return *==== INIT: *==== * Open UV.LOGS OPEN '', UV.LOGS.FILE.NAME TO UV.LOGS.FVAR ELSE ERROR = CANNOT.OPEN.UV.LOGS.ERROR GOSUB ERROR.SUB GOTO EXIT END OPENED.FLAG = @TRUE * Open DICT UV.LOGS OPEN 'DICT', UV.LOGS.FILE.NAME TO UV.LOGS.DICT.FVAR ELSE ERROR = CANNOT.OPEN.UV.LOGS.DICT.ERROR GOSUB ERROR.SUB GOTO EXIT END DICT.OPENED.FLAG = @TRUE * Lock UV.LOGS to protect us from other users READU LOG.NEXT FROM UV.LOGS.DICT.FVAR, "LOG.NEXT" ELSE ERROR = UV.LOGS.DICT.IS.LOCKED.ERROR GOSUB ERROR.SUB GOTO EXIT END SEQUENCE.NUMBER = LOG.NEXT<2> - 1 DICT.LOCKED.FLAG = @TRUE RETURN *============= CHECK.LOGFILE: *============= * Open the After-Image logfile FILENAME = AL.PREFIX : SEQUENCE.NUMBER * Determine state of the file AI.REC = "" EOF = 0 FILE.STATE = "" FILE.OFFSET = "" FILE.SIZE = "" * * The subscript I is the key to fetching * the records from the UV_LOGS file * READ AI.REC FROM UV.LOGS.FVAR, I ELSE EOF = 1 END IF (EOF = 1) THEN RETURN END FILE.STATE = AI.REC< AIF.STATUS > If DEBUGGING Then LogText = "FILE.STATE = ":FILE.STATE GoSub WriteDbg End * If file state not EMPTY, error SKIPREC = 0 IF FILE.STATE # FULLSTATE THEN * only process FULL logs * go on to the next record SKIPREC = 1 RETURN END FILE.OFFSET = AI.REC< AIF.OFFSET > FILE.SIZE = AI.REC< AIF.SIZE > If DEBUGGING Then LogText = "FILE.SIZE = ":FILE.SIZE GoSub WriteDbg LogText = "FILE.OFFSET = ":FILE.OFFSET GoSub WriteDbg End RETURN *========= ERROR.SUB: *========= * Error handling routine PRINT @SYS.BELL * Set return code and report the error BEGIN CASE CASE ERROR = NOT.ADMINISTRATOR.ERROR PRINT 'Error: Only the UniVerse Administrator can DELETE log files.' CASE ERROR = CANNOT.OPEN.UV.LOGS.ERROR PRINT 'Error: Cannot open UV.LOGS file, Status = ' : STATUS() CASE ERROR = UV.LOGS.IS.LOCKED.ERROR PRINT 'Error: The UV.LOGS file is currently locked by another user.' CASE ERROR = UV.LOGS.DICT.IS.LOCKED.ERROR PRINT 'Error: The DICT UV.LOGS file is currently locked by another user.' CASE ERROR = CANNOT.READ.UV.LOGS.ERROR PRINT 'Error: Reading from UV.LOGS file, Status = ' : STATUS() CASE ERROR = CANNOT.WRITE.UV.LOGS.ERROR PRINT 'Error: Writing to UV.LOGS file, Status = ' : STATUS() CASE ERROR = CANNOT.WRITE.UV.LOGS.DICT.ERROR PRINT 'Error: Writing to DICT UV.LOGS file, Status = ' : STATUS() CASE ERROR = CANNOT.DELETE.CURR.LOGFILE.ERROR PRINT 'Error: Cannot DELETE CURRENT log file "' : FILENAME : '".' CASE ERROR = FILE.STATE.NOT.EMPTY.ERROR PRINT 'Error: Log file "' : FILENAME : '" is not empty."' CASE ERROR = LOGFILE.NOT.FULL.ERROR PRINT 'Error: Log file "' : FILENAME : '" is not full."' CASE ERROR = INVALID.UV.LOGS.DIR.ERROR PRINT 'Error: No Logging Directory Exists.' CASE ERROR = INCORRECT.NUM.ARGS PRINT 'Error: Incorrect number of arguments' END CASE RETURN *--------------- EXIT: *--------------- * RELEASE the lock and close UV.LOGS IF DICT.LOCKED.FLAG THEN RELEASE UV.LOGS.DICT.FVAR END IF OPENED.FLAG THEN CLOSE UV.LOGS.FVAR END IF DICT.OPENED.FLAG THEN CLOSE UV.LOGS.DICT.FVAR END STOP END * END-CODE