From 494e7b3a77c6b07213586c03d8ee844304aafe20 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 11 Mar 1997 12:55:19 +0000 Subject: 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. --- sbin/restore/interactive.c | 51 +++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 16 deletions(-) (limited to 'sbin/restore/interactive.c') 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 #include #include -#include #include #include +#include #include #include @@ -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; -- cgit v1.1