1
0
mirror of https://github.com/brouhaha/tapeutils.git synced 2026-01-11 23:53:18 +00:00

Made it compile under FreeBSD and fixed a small bug

This commit is contained in:
aap 2017-01-21 17:29:52 +01:00
parent 19d644a821
commit fc2b9b93f4
2 changed files with 22 additions and 9 deletions

View File

@ -19,12 +19,18 @@
# options # options
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
UNAME != uname
# CFLAGS = -O2 -Wall # CFLAGS = -O2 -Wall
# LDFLAGS = # LDFLAGS =
CFLAGS = -g -Wall CFLAGS = -g -Wall
LDFLAGS = -g LDFLAGS = -g
ifeq ($(UNAME),FreeBSD)
LIBS=-lcompat
endif
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# You shouldn't have to change anything below this point, but if you do please # You shouldn't have to change anything below this point, but if you do please
# let me know why so I can improve this Makefile. # let me know why so I can improve this Makefile.
@ -55,19 +61,19 @@ clean:
rm -f $(PROGRAMS) $(MISC_TARGETS) *.o rm -f $(PROGRAMS) $(MISC_TARGETS) *.o
tapecopy: tapecopy.o tapeio.o tapecopy: tapecopy.o tapeio.o $(LIBS)
tapedump: tapedump.o tapeio.o tapedump: tapedump.o tapeio.o $(LIBS)
taperead: taperead.o tapeio.o taperead: taperead.o tapeio.o $(LIBS)
tapewrite: tapewrite.o tapeio.o tapewrite: tapewrite.o tapeio.o $(LIBS)
t10backup: t10backup.o tapeio.o t10backup: t10backup.o tapeio.o $(LIBS)
read20: read20.o tapeio.o read20: read20.o tapeio.o $(LIBS)
tapex: tapex.o tapeio.o tapex: tapex.o tapeio.o $(LIBS)
include $(SOURCES:.c=.d) include $(SOURCES:.c=.d)

View File

@ -64,6 +64,10 @@
struct mtop { int mt_op; int mt_count; }; struct mtop { int mt_op; int mt_count; };
#else #else
#include <sys/mtio.h> #include <sys/mtio.h>
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#define MTSETBLK MTSETBSIZ
#define MTSETDENSITY MTSETDNSTY
#endif
#endif #endif
#include "tapeio.h" #include "tapeio.h"
@ -424,6 +428,7 @@ int getrec (tape_handle_t mtape, void *buf, int len)
{ {
unsigned char byte [4]; /* 32 bits for length field(s) */ unsigned char byte [4]; /* 32 bits for length field(s) */
unsigned long l; /* at least 32 bits */ unsigned long l; /* at least 32 bits */
int i;
if (mtape->tape_type == TT_IMAGE) if (mtape->tape_type == TT_IMAGE)
{ /* image file */ { /* image file */
@ -454,21 +459,23 @@ int getrec (tape_handle_t mtape, void *buf, int len)
{ /* rmt tape server */ { /* rmt tape server */
len = sprintf (mtape->netbuf, "R%d\n", len); len = sprintf (mtape->netbuf, "R%d\n", len);
dowrite (mtape->tapefd, mtape->netbuf, len); dowrite (mtape->tapefd, mtape->netbuf, len);
if ((l = response (mtape)) < 0) if ((i = response (mtape)) < 0)
{ {
perror("?Error reading tape"); perror("?Error reading tape");
exit(1); exit(1);
} }
l = i;
if (l) if (l)
doread (mtape->tapefd, buf, l); doread (mtape->tapefd, buf, l);
} }
else else
{ /* local tape drive */ { /* local tape drive */
if ((l = read (mtape->tapefd, buf, len)) < 0) if ((i = read (mtape->tapefd, buf, len)) < 0)
{ {
perror("?Error reading tape"); perror("?Error reading tape");
exit(1); exit(1);
} }
l = i;
} }
return(l); return(l);