Changeset View
Changeset View
Standalone View
Standalone View
sbin/restore/interactive.c
Show First 20 Lines • Show All 499 Lines • ▼ Show 20 Lines | printlist(char *name, char *basename) | ||||
struct direct *dp; | struct direct *dp; | ||||
struct afile single; | struct afile single; | ||||
RST_DIR *dirp; | RST_DIR *dirp; | ||||
int entries, len, namelen; | int entries, len, namelen; | ||||
char locname[MAXPATHLEN]; | char locname[MAXPATHLEN]; | ||||
dp = pathsearch(name); | 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)) | (!vflag && dp->d_ino == UFS_WINO)) | ||||
return; | return; | ||||
if ((dirp = rst_opendir(name)) == NULL) { | if ((dirp = rst_opendir(name)) == NULL) { | ||||
entries = 1; | entries = 1; | ||||
list = &single; | list = &single; | ||||
mkentry(name, dp, list); | mkentry(name, dp, list); | ||||
len = strlen(basename) + 1; | len = strlen(basename) + 1; | ||||
if (strlen(name) - len > single.len) { | if (strlen(name) - len > single.len) { | ||||
freename(single.fname); | freename(single.fname); | ||||
Show All 18 Lines | if ((dirp = rst_opendir(name)) == NULL) { | ||||
(void)strlcpy(locname, name, MAXPATHLEN); | (void)strlcpy(locname, name, MAXPATHLEN); | ||||
(void)strlcat(locname, "/", MAXPATHLEN); | (void)strlcat(locname, "/", MAXPATHLEN); | ||||
namelen = strlen(locname); | namelen = strlen(locname); | ||||
while ((dp = rst_readdir(dirp))) { | while ((dp = rst_readdir(dirp))) { | ||||
if (dp == NULL) | if (dp == NULL) | ||||
break; | break; | ||||
if (!dflag && TSTINO(dp->d_ino, dumpmap) == 0) | if (!dflag && TSTINO(dp->d_ino, dumpmap) == 0) | ||||
continue; | continue; | ||||
if (!vflag && (dp->d_ino == WINO || | if (!vflag && (dp->d_ino == UFS_WINO || | ||||
strcmp(dp->d_name, ".") == 0 || | strcmp(dp->d_name, ".") == 0 || | ||||
strcmp(dp->d_name, "..") == 0)) | strcmp(dp->d_name, "..") == 0)) | ||||
continue; | continue; | ||||
locname[namelen] = '\0'; | locname[namelen] = '\0'; | ||||
if (namelen + dp->d_namlen >= MAXPATHLEN) { | if (namelen + dp->d_namlen >= MAXPATHLEN) { | ||||
fprintf(stderr, "%s%s: name exceeds %d char\n", | fprintf(stderr, "%s%s: name exceeds %d char\n", | ||||
locname, dp->d_name, MAXPATHLEN); | locname, dp->d_name, MAXPATHLEN); | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct afile *fp, *endlist; | struct afile *fp, *endlist; | ||||
int width, bigino, haveprefix, havepostfix; | int width, bigino, haveprefix, havepostfix; | ||||
int i, j, w, precision, columns, lines; | int i, j, w, precision, columns, lines; | ||||
width = 0; | width = 0; | ||||
haveprefix = 0; | haveprefix = 0; | ||||
havepostfix = 0; | havepostfix = 0; | ||||
bigino = ROOTINO; | bigino = UFS_ROOTINO; | ||||
endlist = &list[nentry]; | endlist = &list[nentry]; | ||||
for (fp = &list[0]; fp < endlist; fp++) { | for (fp = &list[0]; fp < endlist; fp++) { | ||||
if (bigino < fp->fnum) | if (bigino < fp->fnum) | ||||
bigino = fp->fnum; | bigino = fp->fnum; | ||||
if (width < fp->len) | if (width < fp->len) | ||||
width = fp->len; | width = fp->len; | ||||
if (fp->prefix != ' ') | if (fp->prefix != ' ') | ||||
haveprefix = 1; | haveprefix = 1; | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
struct dirent * | struct dirent * | ||||
glob_readdir(void *dirp) | glob_readdir(void *dirp) | ||||
{ | { | ||||
struct direct *dp; | struct direct *dp; | ||||
static struct dirent adirent; | static struct dirent adirent; | ||||
while ((dp = rst_readdir(dirp)) != NULL) { | while ((dp = rst_readdir(dirp)) != NULL) { | ||||
if (!vflag && dp->d_ino == WINO) | if (!vflag && dp->d_ino == UFS_WINO) | ||||
continue; | continue; | ||||
if (dflag || TSTINO(dp->d_ino, dumpmap)) | if (dflag || TSTINO(dp->d_ino, dumpmap)) | ||||
break; | break; | ||||
} | } | ||||
if (dp == NULL) | if (dp == NULL) | ||||
return (NULL); | return (NULL); | ||||
adirent.d_fileno = dp->d_ino; | adirent.d_fileno = dp->d_ino; | ||||
adirent.d_namlen = dp->d_namlen; | adirent.d_namlen = dp->d_namlen; | ||||
memmove(adirent.d_name, dp->d_name, dp->d_namlen + 1); | memmove(adirent.d_name, dp->d_name, dp->d_namlen + 1); | ||||
return (&adirent); | return (&adirent); | ||||
} | } | ||||
/* | /* | ||||
* Return st_mode information in response to stat or lstat calls | * Return st_mode information in response to stat or lstat calls | ||||
*/ | */ | ||||
static int | static int | ||||
glob_stat(const char *name, struct stat *stp) | glob_stat(const char *name, struct stat *stp) | ||||
{ | { | ||||
struct direct *dp; | struct direct *dp; | ||||
dp = pathsearch(name); | 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)) | (!vflag && dp->d_ino == UFS_WINO)) | ||||
return (-1); | return (-1); | ||||
if (inodetype(dp->d_ino) == NODE) | if (inodetype(dp->d_ino) == NODE) | ||||
stp->st_mode = IFDIR; | stp->st_mode = IFDIR; | ||||
else | else | ||||
stp->st_mode = IFREG; | stp->st_mode = IFREG; | ||||
return (0); | return (0); | ||||
} | } | ||||
Show All 21 Lines |