summaryrefslogtreecommitdiff
path: root/sbin/restore
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-04-13 21:51:19 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-04-13 21:51:19 +0000
commita8780e080309fc91a1dbcd87f8263df4cc68efd1 (patch)
tree15bf305fae70c0220e447a0f37cd1830b870884d /sbin/restore
parent1d54d563165f38692bbea30882290ed58a25e63c (diff)
fix restore so that it can actually restore files larger than 4GB by
changing the type of "size" to off_t in getfiles() plus little dependent type cleanup, from Daniel Lucq <daniel@lucq.org> ok tdeval@ millert@ otto@
Diffstat (limited to 'sbin/restore')
-rw-r--r--sbin/restore/dirs.c19
-rw-r--r--sbin/restore/extern.h6
-rw-r--r--sbin/restore/tape.c58
3 files changed, 42 insertions, 41 deletions
diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c
index 533e9cbee8c..50f44fe1bc2 100644
--- a/sbin/restore/dirs.c
+++ b/sbin/restore/dirs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dirs.c,v 1.26 2003/08/25 23:28:16 tedu Exp $ */
+/* $OpenBSD: dirs.c,v 1.27 2004/04/13 21:51:18 henning Exp $ */
/* $NetBSD: dirs.c,v 1.26 1997/07/01 05:37:49 lukem Exp $ */
/*
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)dirs.c 8.5 (Berkeley) 8/31/94";
#else
-static const char rcsid[] = "$OpenBSD: dirs.c,v 1.26 2003/08/25 23:28:16 tedu Exp $";
+static const char rcsid[] = "$OpenBSD: dirs.c,v 1.27 2004/04/13 21:51:18 henning Exp $";
#endif
#endif /* not lint */
@@ -126,7 +126,7 @@ static void dcvt(struct odirect *, struct direct *);
static void flushent(void);
static struct inotab *inotablookup(ino_t);
static RST_DIR *opendirfile(const char *);
-static void putdir(char *, long);
+static void putdir(char *, size_t);
static void putent(struct direct *);
static void rst_seekdir(RST_DIR *, long, long);
static long rst_telldir(RST_DIR *);
@@ -341,13 +341,13 @@ searchdir(inum, name)
static void
putdir(buf, size)
char *buf;
- long size;
+ size_t size;
{
struct direct cvtbuf;
struct odirect *odp;
struct odirect *eodp;
struct direct *dp;
- long loc, i;
+ size_t loc, i;
if (cvtflag) {
eodp = (struct odirect *)&buf[size];
@@ -382,12 +382,13 @@ putdir(buf, size)
"reclen not multiple of 4 ");
if (dp->d_reclen < DIRSIZ(0, dp))
Vprintf(stdout,
- "reclen less than DIRSIZ (%d < %d) ",
- dp->d_reclen, DIRSIZ(0, dp));
+ "reclen less than DIRSIZ (%u < %u) ",
+ (unsigned)dp->d_reclen,
+ (unsigned)DIRSIZ(0, dp));
if (dp->d_namlen > NAME_MAX)
Vprintf(stdout,
- "reclen name too big (%d > %d) ",
- dp->d_namlen, NAME_MAX);
+ "reclen name too big (%u > %u) ",
+ (unsigned)dp->d_namlen, NAME_MAX);
Vprintf(stdout, "\n");
loc += i;
continue;
diff --git a/sbin/restore/extern.h b/sbin/restore/extern.h
index 731ddeb7334..181e67ac00c 100644
--- a/sbin/restore/extern.h
+++ b/sbin/restore/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.7 2003/06/02 20:06:16 millert Exp $ */
+/* $OpenBSD: extern.h,v 1.8 2004/04/13 21:51:18 henning Exp $ */
/* $NetBSD: extern.h,v 1.4 1995/03/18 14:59:43 cgd Exp $ */
/*-
@@ -56,7 +56,7 @@ void freeentry(struct entry *);
void freename(char *);
int genliteraldir(char *, ino_t);
char *gentempname(struct entry *);
-void getfile(void (*)(char *, long), void (*)(char *, long));
+void getfile(void (*)(char *, size_t), void (*)(char *, size_t));
void getvol(long);
void initsymtable(char *);
int inodetype(ino_t);
@@ -98,7 +98,7 @@ void swabst(u_char *, u_char *);
void treescan(char *, ino_t, long (*)(char *, ino_t, int));
ino_t upperbnd(ino_t);
long verifyfile(char *, ino_t, int);
-void xtrnull(char *, long);
+void xtrnull(char *, size_t);
/* From ../dump/dumprmt.c */
void rmtclose(void);
diff --git a/sbin/restore/tape.c b/sbin/restore/tape.c
index 6f23ccda8db..cc06ec02573 100644
--- a/sbin/restore/tape.c
+++ b/sbin/restore/tape.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tape.c,v 1.27 2003/07/29 18:38:36 deraadt Exp $ */
+/* $OpenBSD: tape.c,v 1.28 2004/04/13 21:51:18 henning Exp $ */
/* $NetBSD: tape.c,v 1.26 1997/04/15 07:12:25 lukem Exp $ */
/*
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)tape.c 8.6 (Berkeley) 9/13/94";
#else
-static const char rcsid[] = "$OpenBSD: tape.c,v 1.27 2003/07/29 18:38:36 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: tape.c,v 1.28 2004/04/13 21:51:18 henning Exp $";
#endif
#endif /* not lint */
@@ -81,7 +81,7 @@ static char *host = NULL;
static int ofile;
static char *map;
static char lnkbuf[MAXPATHLEN + 1];
-static int pathlen;
+static size_t pathlen;
int oldinofmt; /* old inode format conversion required */
int Bcvt; /* Swap Bytes (for CCI or sun) */
@@ -100,12 +100,12 @@ static u_long swabl(u_long);
static u_char *swablong(u_char *, int);
static u_char *swabshort(u_char *, int);
static void terminateinput(void);
-static void xtrfile(char *, long);
-static void xtrlnkfile(char *, long);
-static void xtrlnkskip(char *, long);
-static void xtrmap(char *, long);
-static void xtrmapskip(char *, long);
-static void xtrskip(char *, long);
+static void xtrfile(char *, size_t);
+static void xtrlnkfile(char *, size_t);
+static void xtrlnkskip(char *, size_t);
+static void xtrmap(char *, size_t);
+static void xtrmapskip(char *, size_t);
+static void xtrskip(char *, size_t);
/*
* Set up an input source
@@ -639,12 +639,12 @@ skipfile()
*/
void
getfile(fill, skip)
- void (*fill)(char *, long);
- void (*skip)(char *, long);
+ void (*fill)(char *, size_t);
+ void (*skip)(char *, size_t);
{
int i;
volatile int curblk = 0;
- volatile long size = spcl.c_dinode.di_size;
+ volatile off_t size = spcl.c_dinode.di_size;
static char clearedbuf[MAXBSIZE];
char buf[MAXBSIZE / TP_BSIZE][TP_BSIZE];
char junk[TP_BSIZE];
@@ -663,19 +663,19 @@ loop:
readtape(&buf[curblk++][0]);
if (curblk == fssize / TP_BSIZE) {
(*fill)((char *)buf, size > TP_BSIZE ?
- (long) (fssize) :
- (curblk - 1) * TP_BSIZE + size);
+ fssize :
+ ((off_t)curblk - 1) * TP_BSIZE + size);
curblk = 0;
}
} else {
if (curblk > 0) {
(*fill)((char *)buf, size > TP_BSIZE ?
- (long) (curblk * TP_BSIZE) :
- (curblk - 1) * TP_BSIZE + size);
+ (curblk * TP_BSIZE) :
+ ((off_t)curblk - 1) * TP_BSIZE + size);
curblk = 0;
}
(*skip)(clearedbuf, size > TP_BSIZE ?
- (long) TP_BSIZE : size);
+ TP_BSIZE : size);
}
if ((size -= TP_BSIZE) <= 0) {
for (i++; i < spcl.c_count; i++)
@@ -692,7 +692,7 @@ loop:
curfile.name, blksread);
}
if (curblk > 0)
- (*fill)((char *)buf, (curblk * TP_BSIZE) + size);
+ (*fill)((char *)buf, ((off_t)curblk * TP_BSIZE) + size);
findinode(&spcl);
gettingfile = 0;
}
@@ -703,12 +703,12 @@ loop:
static void
xtrfile(buf, size)
char *buf;
- long size;
+ size_t size;
{
if (Nflag)
return;
- if (write(ofile, buf, (int) size) == -1)
+ if (write(ofile, buf, size) == -1)
err(1, "write error extracting inode %d, name %s\nwrite",
curfile.ino, curfile.name);
}
@@ -720,10 +720,10 @@ xtrfile(buf, size)
static void
xtrskip(buf, size)
char *buf;
- long size;
+ size_t size;
{
- if (lseek(ofile, size, SEEK_CUR) == -1)
+ if (lseek(ofile, (off_t)size, SEEK_CUR) == -1)
err(1, "seek error extracting inode %d, name %s\nlseek",
curfile.ino, curfile.name);
}
@@ -734,13 +734,13 @@ xtrskip(buf, size)
static void
xtrlnkfile(buf, size)
char *buf;
- long size;
+ size_t size;
{
pathlen += size;
if (pathlen > MAXPATHLEN)
- errx(1, "symbolic link name: %s->%s%s; too long %d",
- curfile.name, lnkbuf, buf, pathlen);
+ errx(1, "symbolic link name: %s->%s%s; too long %lu",
+ curfile.name, lnkbuf, buf, (u_long)pathlen);
(void)strlcat(lnkbuf, buf, sizeof(lnkbuf));
}
@@ -751,7 +751,7 @@ xtrlnkfile(buf, size)
static void
xtrlnkskip(buf, size)
char *buf;
- long size;
+ size_t size;
{
errx(1, "unallocated block in symbolic link %s", curfile.name);
@@ -763,7 +763,7 @@ xtrlnkskip(buf, size)
static void
xtrmap(buf, size)
char *buf;
- long size;
+ size_t size;
{
memcpy(map, buf, size);
@@ -777,7 +777,7 @@ xtrmap(buf, size)
static void
xtrmapskip(buf, size)
char *buf;
- long size;
+ size_t size;
{
panic("hole in map\n");
@@ -791,7 +791,7 @@ xtrmapskip(buf, size)
void
xtrnull(buf, size)
char *buf;
- long size;
+ size_t size;
{
return;