From ebe16beb6804c50c409f4c807e87f0bc5ac83800 Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 6 Jun 2001 15:49:02 +0000 Subject: [PATCH] *** empty log message *** --- hadaq/ansiTape.c | 3 + hadaq/ansiTape.h | 5 +- hadaq/ansiTapeChar.c | 8 +-- hadaq/ansiTapeLabel.c | 128 ++++++++++++++++++------------------------ hadaq/ansiTapeLabel.h | 8 +-- hadaq/evtbuild.c | 4 +- hadaq/hwship.c | 6 +- hadaq/hwsoft.c | 4 +- hadaq/param.tcl | 26 ++++----- 9 files changed, 87 insertions(+), 105 deletions(-) diff --git a/hadaq/ansiTape.c b/hadaq/ansiTape.c index 7a95ae5..ecb7ea4 100644 --- a/hadaq/ansiTape.c +++ b/hadaq/ansiTape.c @@ -51,6 +51,9 @@ AnsiTape *openAnsiTape(const char* filename, const char *dev) { } mtoper->mt_op = MTBSF; + /* BUGBUG this varies from tape to tape. * + * Old DLT III drives seem to work with 2, * + * the new DLT 8000 needs 3. To investigate. */ mtoper->mt_count = 3; stat = ioctl(tape, MTIOCTOP, mtoper); if (stat == -1) { diff --git a/hadaq/ansiTape.h b/hadaq/ansiTape.h index 4442593..cd6d5af 100644 --- a/hadaq/ansiTape.h +++ b/hadaq/ansiTape.h @@ -8,16 +8,15 @@ typedef struct AnsiTapeS { unsigned int bufferFull; unsigned long bytesWritten; - char buf[8192]; + char buf[BLOCKSIZE]; const char *filename; int fileSeqNum; } AnsiTape; -AnsiTape *openAnsiTape(const char *); +AnsiTape *openAnsiTape(const char *, const char *); int writeAnsiTape(AnsiTape *, const char *, size_t); - int closeAnsiTape(AnsiTape *); #endif diff --git a/hadaq/ansiTapeChar.c b/hadaq/ansiTapeChar.c index 2969a38..68d8707 100644 --- a/hadaq/ansiTapeChar.c +++ b/hadaq/ansiTapeChar.c @@ -1,6 +1,4 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/ansiTapeChar.c,v 1.3 2001-03-07 16:02:43 hades Exp $"; - -#include +#include #include "ansiTapeChar.h" @@ -54,7 +52,9 @@ char *ansichar(char *s, int length) { } char *unixchar(char *s, int length) { - int i, end = 0; + int i; + int end = 0; + for(i=0 ; i -#include -/* For allocMem(), freeMem() */ -#include -/* For memcpy() */ -#include #include - -/* For read(), write(), gethostname() */ +#include +#include +#include +#include #include -/* For time() */ -#include /* For getpwent() */ #include #include @@ -21,77 +12,66 @@ static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hada #include #include +#include "ansiTape.h" #include "ansiTapeChar.h" #include "ansiTapeLabel.h" /* Functions concerning the volume label */ -char *readVolumeLabel(int tape) { - char *vol; +int readVolumeLabel(int tape, char *vol) { int stat; - vol = allocMem(80*sizeof(char)); - stat = read(tape, vol, 80); - if(stat != 80) { - vol = 0; + stat = read(tape, vol, LABELSIZE); + if(stat != LABELSIZE) { + return -1; } - return vol; - freeMem(vol); + return 0; } -int writeVolumeLabel(const char *vol, int tape) { - char *v; +int writeVolumeLabel(int tape, const char *vol) { int stat; - v = allocMem(80*sizeof(char)); - memcpy(v, vol, 80); - stat = write(tape, v, 80); - if(stat != 80) { - msglog(LOG_ERR, "Could not write volume label to tape!\n"); - exit(-3); + + stat = write(tape, vol, LABELSIZE); + if(stat != LABELSIZE) { + syslog(LOG_ERR, "Could not write volume label to tape."); + return -1; } - freeMem(v); return 0; } -int writeNewVolumeLabel(const char *volId, const char *ownerId, int tape) { - char *vol, *oid; +int writeNewVolumeLabel(int tape, const char *volId, const char *ownerId) { int stat; - + char vol[LABELSIZE]; + char oid[15]; const char *impId = " HADAQ0023"; - vol = allocMem(80*sizeof(char)); - - oid = allocMem(15*sizeof(char)); - if (80 != sprintf(vol, "VOL1HADAQ %s%s 4", impId, ansichar(oid, 14))) { - msglog(LOG_ERR, "LabelV not 80 char!\n"); - exit(-3); + strncpy(oid, ownerId, 15); + if (LABELSIZE != sprintf(vol, "VOL1HADAQ %s%s 4", impId, ansichar(oid, 14))) { + syslog(LOG_ERR, "Volume label not %d char.", LABELSIZE); + return -1; } - freeMem(oid); - stat = write(tape, vol, 80); - if(stat != 80) { - msglog(LOG_ERR, "Could not write volume label to tape!\n"); - exit(-3); + stat = write(tape, vol, LABELSIZE); + if(stat != LABELSIZE) { + syslog(LOG_ERR, "Could not write volume label to tape."); + return -1; } - freeMem(vol); return 0; } /* Functions concerning the hdr-label and the eof-label */ -int writeLabel(const char *hdreof, int tape, int fileSeqNum, int bytes, const char *filename) { +static int writeLabel(int tape, const char *hdreof, int fileSeqNum, int bytes, const char *filename) { int stat; int i; int blockSize = BLOCKSIZE; char hostname[21]; char *creaCent; - char label[81]; + char label[LABELSIZE + 1]; char fn[37]; - const char *impId = " HADAQ0023"; - uid_t uid; char *user; time_t tim; @@ -107,7 +87,7 @@ int writeLabel(const char *hdreof, int tape, int fileSeqNum, int bytes, const ch } strcpy(fn, filename); - if (80 != sprintf(label, "%-3s%1d%-17s%06d%04d%04d%04d%02d%1s%02d%03d%6d%1s%06d%-13s%-7s", + if (LABELSIZE != sprintf(label, "%-3s%1d%-17s%06d%04d%04d%04d%02d%1s%02d%03d%6d%1s%06d%-13s%-7s", hdreof, 1, ansichar(fn, 17), @@ -119,22 +99,21 @@ int writeLabel(const char *hdreof, int tape, int fileSeqNum, int bytes, const ch creaCent, (cd->tm_year)%100, cd->tm_yday, 99366, " ", - (bytes + BLOCKSIZE -1) / BLOCKSIZE, + (bytes + BLOCKSIZE - 1) / BLOCKSIZE, impId, "") ) { - msglog(LOG_ERR, "Label1 not 80 char!\n"); - exit(-3); + syslog(LOG_ERR, "Label 1 not %d char.", LABELSIZE); + return -1; } - stat = write(tape, label, 80); - if(stat != 80) { - msglog(LOG_ERR, "Could not write ANSI label 1 on tape!\n"); - perror("And Why?\n"); - exit(-3); + stat = write(tape, label, LABELSIZE); + if(stat != LABELSIZE) { + syslog(LOG_ERR, "Could not write ANSI label 1 on tape."); + return -1; } - if (80 != sprintf(label, "%-3s%1d%1s%05d%05d%-21s%1s%010d%-3s%02d%28s", + if (LABELSIZE != sprintf(label, "%-3s%1d%1s%05d%05d%-21s%1s%010d%-3s%02d%28s", hdreof, 2, "F", @@ -147,13 +126,13 @@ int writeLabel(const char *hdreof, int tape, int fileSeqNum, int bytes, const ch 0, "") ) { - msglog(LOG_ERR, "Label2 not 80 char!\n"); - exit(-3); + syslog(LOG_ERR, "Label 2 not %d char.", LABELSIZE); + return -1; } - stat = write(tape, label, 80); - if(stat != 80) { - msglog(LOG_ERR, "Could not write ANSI label 2 on tape!\n"); - exit(-3); + stat = write(tape, label, LABELSIZE); + if(stat != LABELSIZE) { + syslog(LOG_ERR, "Could not write ANSI label 2 on tape."); + return -1; } uid = getuid(); @@ -168,7 +147,7 @@ int writeLabel(const char *hdreof, int tape, int fileSeqNum, int bytes, const ch gethostname(hostname, 20); - if (80 != sprintf(label, "%-3s%1d%010d%-10s%-20s%-36s", + if (LABELSIZE != sprintf(label, "%-3s%1d%010d%-10s%-20s%-36s", hdreof, 3, tim, @@ -176,22 +155,23 @@ int writeLabel(const char *hdreof, int tape, int fileSeqNum, int bytes, const ch hostname, filename) ) { - msglog(LOG_ERR, "Label3 not 80 char!\n"); - exit(-3); + syslog(LOG_ERR, "Label 3 not %d char.", LABELSIZE); + return -1; } - stat = write(tape, label, 80); - if(stat != 80) { - msglog(LOG_ERR, "Could not write ANSI label 3 on tape!\n"); - exit(-3); + stat = write(tape, label, LABELSIZE); + if(stat != LABELSIZE) { + syslog(LOG_ERR, "Could not write ANSI label 3 on tape."); + return -1; } return 0; } int writeHeader(int tape, int fileSeqNum, const char *filename) { - return writeLabel("HDR", tape, fileSeqNum, 0, filename); + return writeLabel(tape, "HDR", fileSeqNum, 0, filename); } int writeTrailer(int tape, int fileSeqNum, unsigned long numBytes, const char *filename) { - return writeLabel("EOF", tape, fileSeqNum, numBytes, filename); + return writeLabel(tape, "EOF", fileSeqNum, numBytes, filename); } + diff --git a/hadaq/ansiTapeLabel.h b/hadaq/ansiTapeLabel.h index f90761a..c7380a7 100644 --- a/hadaq/ansiTapeLabel.h +++ b/hadaq/ansiTapeLabel.h @@ -1,11 +1,11 @@ #ifndef ANSITAPELABEL_H #define ANSITAPELABEL_H -#define BLOCKSIZE 8192 +#define LABELSIZE 80 -char *readVolumeLabel(int); -int writeVolumeLabel(const char *, int); -int writeNewVolumeLabel(const char *, const char *, int); +int readVolumeLabel(int, char *); +int writeVolumeLabel(int, const char *); +int writeNewVolumeLabel(int, const char *, const char *); int writeHeader(int, int, const char *); int writeTrailer(int, int, unsigned long, const char *); diff --git a/hadaq/evtbuild.c b/hadaq/evtbuild.c index ac1c8d1..9e6bc3a 100644 --- a/hadaq/evtbuild.c +++ b/hadaq/evtbuild.c @@ -1,4 +1,4 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.28 2001-04-26 11:59:49 hades Exp $"; +static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.29 2001-06-06 15:49:03 hades Exp $"; #define _POSIX_C_SOURCE 199309L @@ -319,7 +319,7 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } } else if (strcmp(theArgs->outDev, "tape") == 0) { - if (NULL == (outTape = openAnsiTape(theArgs->outPath))) { + if (NULL == (outTape = openAnsiTape(theArgs->outPath, "/dev/tape"))) { msglog(LOG_NOTICE, "Opening of tape failed (no tape available?): Writing to /dev/null.\n"); strcpy(theArgs->outDev, "null"); outFile = NULL; diff --git a/hadaq/hwship.c b/hadaq/hwship.c index 167f758..ec420ce 100644 --- a/hadaq/hwship.c +++ b/hadaq/hwship.c @@ -1,4 +1,4 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwship.c,v 6.16 2001-05-10 18:29:24 hades Exp $"; +static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwship.c,v 6.17 2001-06-06 15:49:04 hades Exp $"; #include #include @@ -40,10 +40,10 @@ int conHwShip(HwShip * my, const char *name, const Param *param) strcpy(my->name, name); - Param_getInt(param, my->name, "ipc_vmebase", ¶mWasFound, &cardBase); + Param_getInt(param, my->name, "cardbase", ¶mWasFound, &cardBase); if (!paramWasFound) { msglog(LOG_WARNING, - "Parameter %s(%s) not found, default = 0\n", my->name, "ipc_vmebase"); + "Parameter %s(%s) not found, default = 0\n", my->name, "cardbase"); cardBase = 0; } diff --git a/hadaq/hwsoft.c b/hadaq/hwsoft.c index db3b9f3..85974a7 100644 --- a/hadaq/hwsoft.c +++ b/hadaq/hwsoft.c @@ -1,4 +1,4 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwsoft.c,v 6.21 2001-04-26 11:59:49 hades Exp $"; +static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwsoft.c,v 6.22 2001-06-06 15:49:04 hades Exp $"; #define _POSIX_C_SOURCE 199309L @@ -58,7 +58,7 @@ void deleteHardware(Hardware *my) void Hardware_waitForTrigger(Hardware *my, void *partEvt) { -#if 1 +#if 0 struct timespec tS, *t = &tS; t->tv_sec = 0; diff --git a/hadaq/param.tcl b/hadaq/param.tcl index c3d30da..9ff88e0 100644 --- a/hadaq/param.tcl +++ b/hadaq/param.tcl @@ -29,22 +29,22 @@ set sam5(cardbase) 0xcC000000 set sam6(cardbase) 0xdC000000 set sam7(cardbase) 0xeC000000 set sam8(cardbase) 0x5C000000 -set soft(size) 1024 +set soft(size) 8192 set dtu(cardbase) 0x44100000 -set ipc0(ipc_vmebase) 0x100000 -set ipc1(ipc_vmebase) 0x200000 -set ipc2(ipc_vmebase) 0x300000 -set ipc3(ipc_vmebase) 0x400000 -set ipc4(ipc_vmebase) 0x500000 -set ipc5(ipc_vmebase) 0x600000 -set ipc6(ipc_vmebase) 0x700000 -set ipc7(ipc_vmebase) 0x800000 -set ipc8(ipc_vmebase) 0x900000 -set ipc9(ipc_vmebase) 0xa00000 -set ipc10(ipc_vmebase) 0xb00000 -set ipc11(ipc_vmebase) 0xc00000 +set ipc0(cardbase) 0x100000 +set ipc1(cardbase) 0x200000 +set ipc2(cardbase) 0x300000 +set ipc3(cardbase) 0x400000 +set ipc4(cardbase) 0x500000 +set ipc5(cardbase) 0x600000 +set ipc6(cardbase) 0x700000 +set ipc7(cardbase) 0x800000 +set ipc8(cardbase) 0x900000 +set ipc9(cardbase) 0xa00000 +set ipc10(cardbase) 0xb00000 +set ipc11(cardbase) 0xc00000 set race0(cardbase) 0x00000000 set race1(cardbase) 0x10000000 -- 2.43.0