-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/ansiTapeLabel.c,v 1.7 2001-03-07 16:02:43 hades Exp $";
-
-/* For msglog() */
-#include <hadesstd.h>
-#include <errno.h>
-/* For allocMem(), freeMem() */
-#include <hadesstd.h>
-/* For memcpy() */
-#include <string.h>
#include <stdio.h>
-
-/* For read(), write(), gethostname() */
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
+#include <time.h>
#include <unistd.h>
-/* For time() */
-#include <time.h>
/* For getpwent() */
#include <pwd.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/types.h>
+#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;
}
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),
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",
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();
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,
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);
}
+
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