summaryrefslogtreecommitdiffstats
path: root/sbin/restore
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/restore')
-rw-r--r--sbin/restore/dirs.c14
-rw-r--r--sbin/restore/interactive.c4
-rw-r--r--sbin/restore/restore.c17
-rw-r--r--sbin/restore/symtab.c7
-rw-r--r--sbin/restore/tape.c34
5 files changed, 44 insertions, 32 deletions
diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c
index 203d977..b2cd8fd 100644
--- a/sbin/restore/dirs.c
+++ b/sbin/restore/dirs.c
@@ -637,7 +637,8 @@ setdirmodes(int flags)
continue;
}
if (ep == NULL) {
- panic("cannot find directory inode %d\n", node.ino);
+ panic("cannot find directory inode %ju\n",
+ (uintmax_t)node.ino);
continue;
}
cp = myname(ep);
@@ -678,7 +679,8 @@ genliteraldir(char *name, ino_t ino)
itp = inotablookup(ino);
if (itp == NULL)
- panic("Cannot find directory inode %d named %s\n", ino, name);
+ panic("Cannot find directory inode %ju named %s\n",
+ (uintmax_t)ino, name);
if ((ofile = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) {
fprintf(stderr, "%s: ", name);
(void) fflush(stderr);
@@ -691,15 +693,15 @@ genliteraldir(char *name, ino_t ino)
size = i < BUFSIZ ? i : BUFSIZ;
if (read(dp, buf, (int) size) == -1) {
fprintf(stderr,
- "write error extracting inode %d, name %s\n",
- curfile.ino, curfile.name);
+ "write error extracting inode %ju, name %s\n",
+ (uintmax_t)curfile.ino, curfile.name);
fprintf(stderr, "read: %s\n", strerror(errno));
done(1);
}
if (!Nflag && write(ofile, buf, (int) size) == -1) {
fprintf(stderr,
- "write error extracting inode %d, name %s\n",
- curfile.ino, curfile.name);
+ "write error extracting inode %ju, name %s\n",
+ (uintmax_t)curfile.ino, curfile.name);
fprintf(stderr, "write: %s\n", strerror(errno));
done(1);
}
diff --git a/sbin/restore/interactive.c b/sbin/restore/interactive.c
index 3cd311d..05d1a58 100644
--- a/sbin/restore/interactive.c
+++ b/sbin/restore/interactive.c
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <glob.h>
#include <limits.h>
#include <setjmp.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -675,7 +676,8 @@ formatf(struct afile *list, int nentry)
for (j = 0; j < columns; j++) {
fp = &list[j * lines + i];
if (vflag) {
- fprintf(stderr, "%*d ", precision, fp->fnum);
+ fprintf(stderr, "%*ju ",
+ precision, (uintmax_t)fp->fnum);
fp->len += precision + 1;
}
if (haveprefix) {
diff --git a/sbin/restore/restore.c b/sbin/restore/restore.c
index e494cdb..fbc24ec 100644
--- a/sbin/restore/restore.c
+++ b/sbin/restore/restore.c
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <limits.h>
+#include <stdint.h>
#include <stdio.h>
#include <string.h>
@@ -61,7 +62,7 @@ listfile(char *name, ino_t ino, int type)
if (TSTINO(ino, dumpmap) == 0)
return (descend);
vprintf(stdout, "%s", type == LEAF ? "leaf" : "dir ");
- fprintf(stdout, "%10d\t%s\n", ino, name);
+ fprintf(stdout, "%10ju\t%s\n", (uintmax_t)ino, name);
return (descend);
}
@@ -83,7 +84,7 @@ addfile(char *name, ino_t ino, int type)
if (ino == WINO && command == 'i' && !vflag)
return (descend);
if (!mflag) {
- (void) sprintf(buf, "./%u", ino);
+ (void) sprintf(buf, "./%ju", (uintmax_t)ino);
name = buf;
if (type == NODE) {
(void) genliteraldir(name, ino);
@@ -457,8 +458,8 @@ nodeupdates(char *name, ino_t ino, int type)
* next incremental tape.
*/
case 0:
- fprintf(stderr, "%s: (inode %d) not found on tape\n",
- name, ino);
+ fprintf(stderr, "%s: (inode %ju) not found on tape\n",
+ name, (uintmax_t)ino);
break;
/*
@@ -612,7 +613,7 @@ createleaves(char *symtabfile)
while (first < curfile.ino) {
ep = lookupino(first);
if (ep == NULL)
- panic("%d: bad first\n", first);
+ panic("%ju: bad first\n", (uintmax_t)first);
fprintf(stderr, "%s: not found on tape\n", myname(ep));
ep->e_flags &= ~(NEW|EXTRACT);
first = lowerbnd(first);
@@ -625,8 +626,8 @@ createleaves(char *symtabfile)
* on the next incremental tape.
*/
if (first != curfile.ino) {
- fprintf(stderr, "expected next file %d, got %d\n",
- first, curfile.ino);
+ fprintf(stderr, "expected next file %ju, got %ju\n",
+ (uintmax_t)first, (uintmax_t)curfile.ino);
skipfile();
goto next;
}
@@ -852,7 +853,7 @@ verifyfile(char *name, ino_t ino, int type)
if (np == ep)
break;
if (np == NULL)
- panic("missing inumber %d\n", ino);
+ panic("missing inumber %ju\n", (uintmax_t)ino);
if (ep->e_type == LEAF && type != LEAF)
badentry(ep, "type should be LEAF");
return (descend);
diff --git a/sbin/restore/symtab.c b/sbin/restore/symtab.c
index 3e52335..9d0313d 100644
--- a/sbin/restore/symtab.c
+++ b/sbin/restore/symtab.c
@@ -52,6 +52,7 @@ static const char rcsid[] =
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -100,7 +101,7 @@ addino(ino_t inum, struct entry *np)
struct entry **epp;
if (inum < WINO || inum >= maxino)
- panic("addino: out of range %d\n", inum);
+ panic("addino: out of range %ju\n", (uintmax_t)inum);
epp = &entry[inum % entrytblsize];
np->e_ino = inum;
np->e_next = *epp;
@@ -121,7 +122,7 @@ deleteino(ino_t inum)
struct entry **prev;
if (inum < WINO || inum >= maxino)
- panic("deleteino: out of range %d\n", inum);
+ panic("deleteino: out of range %ju\n", (uintmax_t)inum);
prev = &entry[inum % entrytblsize];
for (next = *prev; next != NULL; next = next->e_next) {
if (next->e_ino == inum) {
@@ -131,7 +132,7 @@ deleteino(ino_t inum)
}
prev = &next->e_next;
}
- panic("deleteino: %d not found\n", inum);
+ panic("deleteino: %ju not found\n", (uintmax_t)inum);
}
/*
diff --git a/sbin/restore/tape.c b/sbin/restore/tape.c
index a566c5a..4f34549 100644
--- a/sbin/restore/tape.c
+++ b/sbin/restore/tape.c
@@ -164,7 +164,11 @@ setinput(char *source, int ispipecommand)
}
pipein++;
}
- setuid(getuid()); /* no longer need or want root privileges */
+ /* no longer need or want root privileges */
+ if (setuid(getuid()) != 0) {
+ fprintf(stderr, "setuid failed\n");
+ done(1);
+ }
magtape = strdup(source);
if (magtape == NULL) {
fprintf(stderr, "Cannot allocate space for magtape buffer\n");
@@ -274,7 +278,7 @@ setup(void)
done(1);
}
maxino = (spcl.c_count * TP_BSIZE * NBBY) + 1;
- dprintf(stdout, "maxino = %d\n", maxino);
+ dprintf(stdout, "maxino = %ju\n", (uintmax_t)maxino);
map = calloc((unsigned)1, (unsigned)howmany(maxino, NBBY));
if (map == NULL)
panic("no memory for active inode map\n");
@@ -1050,8 +1054,9 @@ setupextattr(int extsize)
}
extbufsize = 0;
extbuf = NULL;
- fprintf(stderr, "Cannot extract %d bytes %s for inode %d, name %s\n",
- extsize, "of extended attributes", curfile.ino, curfile.name);
+ fprintf(stderr, "Cannot extract %d bytes %s for inode %ju, name %s\n",
+ extsize, "of extended attributes", (uintmax_t)curfile.ino,
+ curfile.name);
return (NULL);
}
@@ -1079,8 +1084,8 @@ xtrfile(char *buf, long size)
return;
if (write(ofile, buf, (int) size) == -1) {
fprintf(stderr,
- "write error extracting inode %d, name %s\nwrite: %s\n",
- curfile.ino, curfile.name, strerror(errno));
+ "write error extracting inode %ju, name %s\nwrite: %s\n",
+ (uintmax_t)curfile.ino, curfile.name, strerror(errno));
}
}
@@ -1094,8 +1099,8 @@ xtrskip(char *buf, long size)
if (lseek(ofile, size, SEEK_CUR) == -1) {
fprintf(stderr,
- "seek error extracting inode %d, name %s\nlseek: %s\n",
- curfile.ino, curfile.name, strerror(errno));
+ "seek error extracting inode %ju, name %s\nlseek: %s\n",
+ (uintmax_t)curfile.ino, curfile.name, strerror(errno));
done(1);
}
}
@@ -1243,8 +1248,8 @@ getmore:
fprintf(stderr, "restoring %s\n", curfile.name);
break;
case SKIP:
- fprintf(stderr, "skipping over inode %d\n",
- curfile.ino);
+ fprintf(stderr, "skipping over inode %ju\n",
+ (uintmax_t)curfile.ino);
break;
}
if (!yflag && !reply("continue"))
@@ -1477,10 +1482,11 @@ accthdr(struct s_spcl *header)
fprintf(stderr, "Used inodes map header");
break;
case TS_INODE:
- fprintf(stderr, "File header, ino %d", previno);
+ fprintf(stderr, "File header, ino %ju", (uintmax_t)previno);
break;
case TS_ADDR:
- fprintf(stderr, "File continuation header, ino %d", previno);
+ fprintf(stderr, "File continuation header, ino %ju",
+ (uintmax_t)previno);
break;
case TS_END:
fprintf(stderr, "End of tape header");
@@ -1631,8 +1637,8 @@ checksum(int *buf)
}
if (i != CHECKSUM) {
- fprintf(stderr, "Checksum error %o, inode %d file %s\n", i,
- curfile.ino, curfile.name);
+ fprintf(stderr, "Checksum error %o, inode %ju file %s\n", i,
+ (uintmax_t)curfile.ino, curfile.name);
return(FAIL);
}
return(GOOD);
OpenPOWER on IntegriCloud