summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2005-03-25 07:35:59 +0000
committerimp <imp@FreeBSD.org>2005-03-25 07:35:59 +0000
commit931f79b73836c973aae2133ddf60d6d3ddf034c6 (patch)
treebd794ca8f11b806d04a312f91f077b870f3b9253 /sbin
parent490dc8aaa3f8ff1dd78d580d1061fc349896e689 (diff)
downloadFreeBSD-src-931f79b73836c973aae2133ddf60d6d3ddf034c6.zip
FreeBSD-src-931f79b73836c973aae2133ddf60d6d3ddf034c6.tar.gz
Restore the ability to read FreeBSD 1 tapes (and I think any net2
based tapes, but I'm not sure where NFS_MAGIC was introduced after 4.3). When support for the pre-4.4 format was removed (the ability to read 4.2 and 4.3 BSD tapes), the old format inode conversion was junked as well. However, FreeBSD 1 dump tapes use the NFS_MAGIC format, but have this inode format. Before, restore would fail complaining that '.' wasn't found and the root directory wasn't on this tape. Since the conversion from the not so old format is relatively trivial, restore the code to make that conversion. FreeBSD 1 dumps are once again readable. MFC After: a few days
Diffstat (limited to 'sbin')
-rw-r--r--sbin/restore/dirs.c10
-rw-r--r--sbin/restore/restore.h3
-rw-r--r--sbin/restore/tape.c11
3 files changed, 24 insertions, 0 deletions
diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c
index ee37113..f0ed7f8 100644
--- a/sbin/restore/dirs.c
+++ b/sbin/restore/dirs.c
@@ -331,6 +331,16 @@ putdir(char *buf, long size)
dp = (struct direct *)(buf + loc);
if (Bcvt)
swabst((u_char *)"ls", (u_char *) dp);
+ if (oldinofmt && dp->d_ino != 0) {
+#if BYTE_ORDER == BIG_ENDIAN
+ if (Bcvt)
+ dp->d_namlen = dp->d_type;
+#else
+ if (!Bcvt && dp->d_namlen == 0)
+ dp->d_namlen = dp->d_type;
+#endif
+ dp->d_type = DT_UNKNOWN;
+ }
i = DIRBLKSIZ - (loc & (DIRBLKSIZ - 1));
if ((dp->d_reclen & 0x3) != 0 ||
dp->d_reclen > i ||
diff --git a/sbin/restore/restore.h b/sbin/restore/restore.h
index 05ca620..2221b20 100644
--- a/sbin/restore/restore.h
+++ b/sbin/restore/restore.h
@@ -60,6 +60,7 @@ extern time_t dumpdate; /* time that this dump was made */
extern char command; /* opration being performed */
extern FILE *terminal; /* file descriptor for the terminal input */
extern int Bcvt; /* need byte swapping on inodes and dirs */
+extern int oldinofmt; /* reading tape with FreeBSD 1 format inodes */
/*
* Each file in the file system is described by one of these entries
@@ -146,3 +147,5 @@ typedef struct rstdirdesc RST_DIR;
#define GOOD 1
#define FAIL 0
+
+#define NFS_DR_NEWINODEFMT 0x2 /* Tape uses 4.4 BSD inode format */
diff --git a/sbin/restore/tape.c b/sbin/restore/tape.c
index 1c8907b..ea5d37f 100644
--- a/sbin/restore/tape.c
+++ b/sbin/restore/tape.c
@@ -87,6 +87,7 @@ static char lnkbuf[MAXPATHLEN + 1];
static int pathlen;
int Bcvt; /* Swap Bytes */
+int oldinofmt; /* FreeBSD 1 inode format needs cvt */
#define FLUSHTAPEBUF() blkcnt = ntrec + 1
@@ -1086,6 +1087,8 @@ gethead(struct s_spcl *buf)
case TS_TAPE:
if (buf->c_magic == NFS_MAGIC) {
+ if ((buf->c_flags & NFS_DR_NEWINODEFMT) == 0)
+ oldinofmt = 1;
buf->c_date = _time32_to_time(buf->c_old_date);
buf->c_ddate = _time32_to_time(buf->c_old_ddate);
buf->c_tapea = buf->c_old_tapea;
@@ -1117,6 +1120,14 @@ gethead(struct s_spcl *buf)
panic("gethead: unknown inode type %d\n", buf->c_type);
break;
}
+ /*
+ * If we're restoring a filesystem with the old (FreeBSD 1)
+ * format inodes, copy the uid/gid to the new location
+ */
+ if (oldinofmt) {
+ buf->c_uid = buf->c_spare1[1];
+ buf->c_gid = buf->c_spare1[2];
+ }
buf->c_magic = FS_UFS2_MAGIC;
tapeaddr = buf->c_tapea;
if (dflag)
OpenPOWER on IntegriCloud