+++ /dev/null
-/* For msglog() */
-#include <hadesstd.h>
-#include <errno.h>
-
-/* For time() */
-#include <time.h>
-
-/* For gethostname() */
-#include <unistd.h>
-
-/* For getpwent() */
-#include <pwd.h>
-#include <sys/types.h>
-
-/* For getuid() */
-#include <unistd.h>
-#include <sys/types.h>
-
-#include "hwtapeal.h"
-
-int writeHeader(int tape, int fileSeqNum, const char *filename) {
- int stat;
- int i;
- int blockSize = BLOCKSIZE;
- char *hostname;
- char *creaCent;
- char *label;
-#ifdef LINUX
- const char *impId = "LINUXHADAQ023";
-#endif
-#ifdef UNIX
- const char *impId = "UNIXHADAQ0023";
-#endif
-#ifndef LINUX
- #ifndef UNIX
- const char *impId = " HADAQ0023";
- #endif
-#endif
- uid_t uid, first_uid;
- time_t tim;
- struct passwd *pwentry;
- struct tm *cd;
-
- gethostname(hostname, 20);
-
- tim = time(0);
- cd = gmtime(&tim);
- if ((cd->tm_year)/100 == 19) {
- *creaCent = ' ';
- } else {
- *creaCent = '0';
- }
-
- label = allocMem(80*sizeof(char));
-
- sprintf(label, "HDR1 %s0000010001%04d000100%s%02d%03d 99366 000000%s ", ansichar(filename, 17), fileSeqNum, creaCent, (cd->tm_year)%100, cd->tm_yday, impId);
- stat = write(tape, label, 80);
- if(stat == -1) {
- msglog(LOG_ERR, "Could not write ANSI label on tape!\n");
- exit(-3);
- }
-
- sprintf(label, "HDR2F%05d%05d010664 bin 33000 ", blockSize, blockSize);
- stat = write(tape, label, 80);
- if(stat == -1) {
- msglog(LOG_ERR, "Could not write ANSI label on tape!\n");
- exit(-3);
- }
-
- uid = getuid();
- pwentry = getpwent();
- first_uid = pwentry->pw_uid;
- do {
- pwentry = getpwent();
- } while (pwentry->pw_uid != uid && pwentry->pw_uid != first_uid);
-
- if (pwentry->pw_name == "root") {
- pwentry->pw_name = "hades";
- }
-
- sprintf(label, "HDR3%010d%s%s%s", tim, unixchar(pwentry->pw_name, 10), unixchar(hostname, 20), unixchar(filename, 36));
- stat = write(tape, label, 80);
- if(stat == -1) {
- msglog(LOG_ERR, "Could not write ANSI label on tape!\n");
- exit(-3);
- }
-
- freeMem(label);
- return 0;
-}
-
-
-int writeTrailer(int tape, int fileSeqNum, int numBlocks, const char *filename) {
- int stat;
- int i;
- int blockSize = BLOCKSIZE;
- char *hostname;
- char *creaCent;
- char *label;
-#ifdef LINUX
- const char *impId = "LINUXHADAQ023";
-#endif
-#ifdef UNIX
- const char *impId = "UNIXHADAQ0023";
-#endif
-#ifndef LINUX
- #ifndef UNIX
- const char *impId = " HADAQ0023";
- #endif
-#endif
- uid_t uid, first_uid;
- time_t tim;
- struct passwd *pwentry;
- struct tm *cd;
-
- gethostname(hostname, 20);
-
- tim = time(0);
- cd = gmtime(&tim);
- if ((cd->tm_year)/100 == 19) {
- *creaCent = ' ';
- } else {
- *creaCent = '0';
- }
-
- label = allocMem(80*sizeof(char));
-
- sprintf(label, "HDR1 %s0000010001%04d000100%s%02d%03d 99366 %06d%s ", ansichar(filename, 17), fileSeqNum, creaCent, (cd->tm_year)%100, cd->tm_yday, numBlocks, impId);
- stat = write(tape, label, 80);
- if(stat == -1) {
- msglog(LOG_ERR, "Could not write ANSI label on tape!\n");
- exit(-3);
- }
-
- sprintf(label, "HDR2F%05d%05d010664 bin %010d33000 ", blockSize, blockSize, numBlocks*blockSize);
- stat = write(tape, label, 80);
- if(stat == -1) {
- msglog(LOG_ERR, "Could not write ANSI label on tape!\n");
- exit(-3);
- }
-
- uid = getuid();
- pwentry = getpwent();
- first_uid = pwentry->pw_uid;
- do {
- pwentry = getpwent();
- } while (pwentry->pw_uid != uid && pwentry->pw_uid != first_uid);
-
- if (pwentry->pw_name == "root") {
- pwentry->pw_name = "hades";
- }
-
- sprintf(label, "HDR3%010d%s%s%s", tim, unixchar(pwentry->pw_name, 10), unixchar(hostname, 20), unixchar(filename, 36));
- stat = write(tape, label, 80);
- if(stat == -1) {
- msglog(LOG_ERR, "Could not write ANSI label on tape!\n");
- exit(-3);
- }
-
- freeMem(label);
- return 0;
-}
-
+++ /dev/null
-/* For read(), write() */
-#include <unistd.h>
-
-/* For allocMem(), freeMem() */
-#include <hadesstd.h>
-
-/* For msglog() */
-#include <hadesstd.h>
-#include <errno.h>
-
-/* For memcpy() */
-#include <string.h>
-
-#include "hwtapevol.h"
-
-char *readVolumeLabel(int tape) {
- char *vol;
- int stat;
- vol = allocMem(80*sizeof(char));
- stat = read(tape, vol, 80);
- if(stat == -1) {
- msglog(LOG_ERR, "Could not read volume label from tape!\n");
- exit(-3);
- }
- return vol;
- freeMem(vol);
-}
-
-int writeVolumeLabel(const char *vol, int tape) {
- char *v;
- int stat;
- v = allocMem(80*sizeof(char));
- memcpy(v, vol, 80);
- stat = write(tape, v, 80);
- if(stat == -1) {
- msglog(LOG_ERR, "Could not write volume label to tape!\n");
- exit(-3);
- }
- freeMem(v);
- return 0;
-}
-
-int writeNewVolumeLabel(const char *volId, const char *ownerId, int tape) {
- char *vol;
- int stat;
-
-#ifdef LINUX
- const char *impId = "LINUXHADAQ023";
-#endif
-#ifdef UNIX
- const char *impId = "UNIXHADAQ0023";
-#endif
-#ifndef LINUX
-#ifndef UNIX
- const char *impId = " HADAQ0023";
-#endif
-#endif
-
- vol = allocMem(80*sizeof(char));
-
- sprintf(vol, "VOL1HADAQ %s%s 4", impId, ansichar(ownerId, 14));
-
- stat = write(tape, vol, 80);
- if(stat == -1) {
- msglog(LOG_ERR, "Could not write volume label to tape!\n");
- exit(-3);
- }
- freeMem(vol);
-
- return 0;
-}
-