summaryrefslogtreecommitdiffstats
path: root/sbin/restore/interactive.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1997-03-11 12:55:19 +0000
committerpeter <peter@FreeBSD.org>1997-03-11 12:55:19 +0000
commit494e7b3a77c6b07213586c03d8ee844304aafe20 (patch)
tree4dfb78949ad3c93600795746b894fcbb170c485f /sbin/restore/interactive.c
parenta4f4635e03e0fdc84d465c0517f302f55961b645 (diff)
downloadFreeBSD-src-494e7b3a77c6b07213586c03d8ee844304aafe20.zip
FreeBSD-src-494e7b3a77c6b07213586c03d8ee844304aafe20.tar.gz
Merge from Lite2
- cleanups, - whiteout support - bug fixes (chflags missing on a few file types etc) The dump/restore folks would want to have a closer look at this, the change is pretty big.
Diffstat (limited to 'sbin/restore/interactive.c')
-rw-r--r--sbin/restore/interactive.c51
1 files changed, 35 insertions, 16 deletions
diff --git a/sbin/restore/interactive.c b/sbin/restore/interactive.c
index 9e8b9ae..600cc90 100644
--- a/sbin/restore/interactive.c
+++ b/sbin/restore/interactive.c
@@ -32,16 +32,16 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)interactive.c 8.1 (Berkeley) 6/5/93";
+static char sccsid[] = "@(#)interactive.c 8.5 (Berkeley) 5/1/95";
#endif /* not lint */
#include <sys/param.h>
#include <sys/time.h>
#include <sys/stat.h>
-#include <ufs/ffs/fs.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ufs/dir.h>
+#include <ufs/ffs/fs.h>
#include <protocols/dumprestore.h>
#include <setjmp.h>
@@ -85,7 +85,7 @@ static void formatf __P((struct afile *, int));
static void getcmd __P((char *, char *, char *, int, struct arglist *));
struct dirent *glob_readdir __P((RST_DIR *dirp));
static int glob_stat __P((const char *, struct stat *));
-static void mkentry __P((struct direct *, struct afile *));
+static void mkentry __P((char *, struct direct *, struct afile *));
static void printlist __P((char *, char *));
/*
@@ -503,15 +503,17 @@ printlist(name, basename)
register struct direct *dp;
struct afile single;
RST_DIR *dirp;
- int entries, len;
+ int entries, len, namelen;
+ char locname[MAXPATHLEN + 1];
dp = pathsearch(name);
- if (dp == NULL || (!dflag && TSTINO(dp->d_ino, dumpmap) == 0))
+ if (dp == NULL || (!dflag && TSTINO(dp->d_ino, dumpmap) == 0) ||
+ (!vflag && dp->d_ino == WINO))
return;
if ((dirp = rst_opendir(name)) == NULL) {
entries = 1;
list = &single;
- mkentry(dp, list);
+ mkentry(name, dp, list);
len = strlen(basename) + 1;
if (strlen(name) - len > single.len) {
freename(single.fname);
@@ -533,17 +535,28 @@ printlist(name, basename)
fprintf(stderr, "%s:\n", name);
entries = 0;
listp = list;
+ (void) strncpy(locname, name, MAXPATHLEN);
+ (void) strncat(locname, "/", MAXPATHLEN);
+ namelen = strlen(locname);
while (dp = rst_readdir(dirp)) {
- if (dp == NULL || dp->d_ino == 0)
+ if (dp == NULL)
break;
if (!dflag && TSTINO(dp->d_ino, dumpmap) == 0)
continue;
- if (vflag == 0 &&
- (strcmp(dp->d_name, ".") == 0 ||
+ if (!vflag && (dp->d_ino == WINO ||
+ strcmp(dp->d_name, ".") == 0 ||
strcmp(dp->d_name, "..") == 0))
continue;
- mkentry(dp, listp++);
- entries++;
+ locname[namelen] = '\0';
+ if (namelen + dp->d_namlen >= MAXPATHLEN) {
+ fprintf(stderr, "%s%s: name exceeds %d char\n",
+ locname, dp->d_name, MAXPATHLEN);
+ } else {
+ (void) strncat(locname, dp->d_name,
+ (int)dp->d_namlen);
+ mkentry(locname, dp, listp++);
+ entries++;
+ }
}
rst_closedir(dirp);
if (entries == 0) {
@@ -566,7 +579,8 @@ printlist(name, basename)
* Read the contents of a directory.
*/
static void
-mkentry(dp, fp)
+mkentry(name, dp, fp)
+ char *name;
struct direct *dp;
register struct afile *fp;
{
@@ -581,7 +595,7 @@ mkentry(dp, fp)
fp->len = cp - fp->fname;
if (dflag && TSTINO(fp->fnum, dumpmap) == 0)
fp->prefix = '^';
- else if ((np = lookupino(fp->fnum)) != NULL && (np->e_flags & NEW))
+ else if ((np = lookupname(name)) != NULL && (np->e_flags & NEW))
fp->prefix = '*';
else
fp->prefix = ' ';
@@ -609,6 +623,10 @@ mkentry(dp, fp)
fp->postfix = '#';
break;
+ case DT_WHT:
+ fp->postfix = '%';
+ break;
+
case DT_UNKNOWN:
case DT_DIR:
if (inodetype(dp->d_ino) == NODE)
@@ -704,7 +722,7 @@ glob_readdir(dirp)
static struct dirent adirent;
while ((dp = rst_readdir(dirp)) != NULL) {
- if (dp->d_ino == 0)
+ if (!vflag && dp->d_ino == WINO)
continue;
if (dflag || TSTINO(dp->d_ino, dumpmap))
break;
@@ -713,7 +731,7 @@ glob_readdir(dirp)
return (NULL);
adirent.d_fileno = dp->d_ino;
adirent.d_namlen = dp->d_namlen;
- bcopy(dp->d_name, adirent.d_name, dp->d_namlen + 1);
+ memmove(adirent.d_name, dp->d_name, dp->d_namlen + 1);
return (&adirent);
}
@@ -728,7 +746,8 @@ glob_stat(name, stp)
register struct direct *dp;
dp = pathsearch(name);
- if (dp == NULL || (!dflag && TSTINO(dp->d_ino, dumpmap) == 0))
+ if (dp == NULL || (!dflag && TSTINO(dp->d_ino, dumpmap) == 0) ||
+ (!vflag && dp->d_ino == WINO))
return (-1);
if (inodetype(dp->d_ino) == NODE)
stp->st_mode = IFDIR;
OpenPOWER on IntegriCloud