summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2021-02-07 12:12:54 +0200
committerToomas Soome <tsoome@me.com>2021-02-13 08:29:54 +0200
commitd9529689937cca41f8af4b28094109ebe366870d (patch)
tree26d5d3d61a88f3bb59369b99a8f44bb1bd8cfff2
parent648766a76d4408cb08159179078fb2d5d2bb26cc (diff)
downloadillumos-joyent-d9529689937cca41f8af4b28094109ebe366870d.tar.gz
6036 ufsrestore segfaults in lookupparent
Reviewed by: Andy Fiddaman <andy@omnios.org> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/cmd/backup/restore/dirs.c86
-rw-r--r--usr/src/cmd/backup/restore/interactive.c77
-rw-r--r--usr/src/cmd/backup/restore/restore.c107
-rw-r--r--usr/src/cmd/backup/restore/restore.h28
-rw-r--r--usr/src/cmd/backup/restore/symtab.c89
-rw-r--r--usr/src/cmd/backup/restore/utilities.c27
6 files changed, 117 insertions, 297 deletions
diff --git a/usr/src/cmd/backup/restore/dirs.c b/usr/src/cmd/backup/restore/dirs.c
index 774dbf6add..566f177c2f 100644
--- a/usr/src/cmd/backup/restore/dirs.c
+++ b/usr/src/cmd/backup/restore/dirs.c
@@ -76,7 +76,6 @@ struct odirect {
char d_name[ODIRSIZ];
};
-#ifdef __STDC__
static ino_t search(ino_t, char *);
static void putdir(char *, size_t);
static void putent(struct direct *);
@@ -89,20 +88,6 @@ static void rst_seekdir(RST_DIR *, offset_t, offset_t);
static struct inotab *allocinotab(ino_t, struct dinode *, off64_t);
static void nodeflush(void);
static struct inotab *inotablookup(ino_t);
-#else
-static ino_t search();
-static void putdir();
-static void putent();
-static void skipmetadata();
-static void flushent();
-static void dcvt();
-static RST_DIR *rst_initdirfile();
-static offset_t rst_telldir();
-static void rst_seekdir();
-static struct inotab *allocinotab();
-static void nodeflush();
-static struct inotab *inotablookup();
-#endif
/*
* Extract directory contents, building up a directory structure
@@ -126,7 +111,7 @@ extractdirs(int genmode)
saverr = errno;
(void) fprintf(stderr,
gettext("%s: %s - cannot create directory temporary\n"),
- progname, dirfile);
+ progname, dirfile);
errno = saverr;
perror("fopen");
done(1);
@@ -137,7 +122,7 @@ extractdirs(int genmode)
saverr = errno;
(void) fprintf(stderr,
gettext("%s: %s - cannot create modefile \n"),
- progname, modefile);
+ progname, modefile);
errno = saverr;
perror("fopen");
done(1);
@@ -210,8 +195,8 @@ void
skipdirs()
{
while (curfile.dip != NULL &&
- ((curfile.dip->di_mode & IFMT) == IFDIR ||
- (curfile.dip->di_mode & IFMT) == IFATTRDIR)) {
+ ((curfile.dip->di_mode & IFMT) == IFDIR ||
+ (curfile.dip->di_mode & IFMT) == IFATTRDIR)) {
skipfile();
}
}
@@ -256,13 +241,13 @@ treescan(char *pname, ino_t ino, long (*todo)())
else
(void) fprintf(stderr,
gettext("Warning: `.' missing from directory %s\n"),
- pname);
+ pname);
if (dp != NULL && strcmp(dp->d_name, "..") == 0)
dp = rst_readdir(dirp); /* first real entry */
else
(void) fprintf(stderr,
gettext("Warning: `..' missing from directory %s\n"),
- pname);
+ pname);
bpt = rst_telldir(dirp);
/*
* a zero inode signals end of directory
@@ -272,7 +257,7 @@ treescan(char *pname, ino_t ino, long (*todo)())
if ((loclen + dp->d_namlen) >= (sizeof (locname) - 2)) {
(void) fprintf(stderr,
gettext(
- "%s%s: ignoring name that exceeds %d char\n"),
+ "%s%s: ignoring name that exceeds %d char\n"),
locname, dp->d_name, MAXCOMPLEXLEN);
} else {
/* Always fits by if() condition */
@@ -287,7 +272,7 @@ treescan(char *pname, ino_t ino, long (*todo)())
}
if (dp == NULL)
(void) fprintf(stderr,
- gettext("corrupted directory: %s.\n"), locname);
+ gettext("corrupted directory: %s.\n"), locname);
}
/*
@@ -316,25 +301,26 @@ attrscan(int always, long (*todo)())
(parent->e_flags & (NEW|EXTRACT)) == 0)
continue;
len = complexcpy(name, myname(parent),
- MAXCOMPLEXLEN - 3);
+ MAXCOMPLEXLEN - 3);
name[len] = '.';
name[len+1] = '\0';
name[len+2] = '\0';
inattrspace = 1;
if ((ep = lookupino(itp->t_ino)) == NULL) {
ep = addentry(name, itp->t_ino,
- NODE|ROOT);
+ NODE|ROOT);
}
ep->e_flags |= XATTRROOT;
treescan(name, itp->t_ino, todo);
inattrspace = 0;
} else {
(void) fprintf(stderr,
- gettext("Warning: orphaned attribute directory\n"));
+ gettext("Warning: orphaned attribute "
+ "directory\n"));
}
} else {
- (void) fprintf(stderr,
- gettext("Warning: `..' missing from attribute directory\n"));
+ (void) fprintf(stderr, gettext("Warning: `..' missing "
+ "from attribute directory\n"));
}
}
}
@@ -473,11 +459,7 @@ putent(struct direct *dp)
* flush out a directory that is finished.
*/
static void
-#ifdef __STDC__
flushent(void)
-#else
-flushent()
-#endif
{
/* LINTED prev += dp->d_reclen, prev % 4 == 0 */
@@ -591,7 +573,7 @@ rst_seekdir(RST_DIR *sdirp, offset_t loc, offset_t base)
loc -= base;
if (loc < 0)
(void) fprintf(stderr,
- gettext("bad seek pointer to rst_seekdir %d\n"), loc);
+ gettext("bad seek pointer to rst_seekdir %d\n"), loc);
(void) llseek(sdirp->dd_fd, base + (loc & ~(DIRBLKSIZ - 1)), 0);
sdirp->dd_loc = loc & (DIRBLKSIZ - 1);
if (sdirp->dd_loc != 0)
@@ -612,7 +594,7 @@ rst_readdir(RST_DIR *rdirp)
DIRBLKSIZ);
if (rdirp->dd_size <= 0) {
dprintf(stderr,
- gettext("error reading directory\n"));
+ gettext("error reading directory\n"));
return ((struct direct *)0);
}
}
@@ -626,7 +608,7 @@ rst_readdir(RST_DIR *rdirp)
(long)dp->d_reclen > (DIRBLKSIZ + 1 - rdirp->dd_loc)) {
dprintf(stderr,
gettext("corrupted directory: bad reclen %d\n"),
- dp->d_reclen);
+ dp->d_reclen);
return ((struct direct *)0);
}
rdirp->dd_loc += dp->d_reclen;
@@ -634,8 +616,8 @@ rst_readdir(RST_DIR *rdirp)
continue;
if ((ino_t)(dp->d_ino) >= maxino) {
dprintf(stderr,
- gettext("corrupted directory: bad inum %lu\n"),
- dp->d_ino);
+ gettext("corrupted directory: bad inum %lu\n"),
+ dp->d_ino);
continue;
}
return (dp);
@@ -646,11 +628,7 @@ rst_readdir(RST_DIR *rdirp)
* Set the mode, owner, and times for all new or changed directories
*/
void
-#ifdef __STDC__
setdirmodes(void)
-#else
-setdirmodes()
-#endif
{
FILE *smf;
struct entry *ep;
@@ -670,9 +648,9 @@ setdirmodes()
if (smf == NULL) {
perror("fopen");
(void) fprintf(stderr,
- gettext("cannot open mode file %s\n"), modefile);
+ gettext("cannot open mode file %s\n"), modefile);
(void) fprintf(stderr,
- gettext("directory mode, owner, and times not set\n"));
+ gettext("directory mode, owner, and times not set\n"));
return;
}
clearerr(smf);
@@ -710,7 +688,7 @@ setdirmodes()
}
if (ep == NIL) {
panic(gettext("cannot find directory inode %d\n"),
- node.ino);
+ node.ino);
skipmetadata(smf, node.metasize);
continue;
}
@@ -720,8 +698,8 @@ setdirmodes()
if (fchdir(dfd) < 0) {
saverr = errno;
(void) fprintf(stderr,
- gettext("Can not set attribute context: %s\n"),
- strerror(saverr));
+ gettext("Can not set attribute context: %s\n"),
+ strerror(saverr));
(void) close(dfd);
continue;
}
@@ -730,7 +708,7 @@ setdirmodes()
saverr = errno;
(void) fprintf(stderr,
gettext("Can not set directory permissions: %s\n"),
- strerror(saverr));
+ strerror(saverr));
complained_chmod = 1;
}
if (node.metasize != 0) {
@@ -739,7 +717,7 @@ setdirmodes()
metasize = node.metasize);
if (metadata == NULL) {
(void) fprintf(stderr,
- gettext("Cannot malloc metadata\n"));
+ gettext("Cannot malloc metadata\n"));
done(1);
}
(void) fread(metadata, 1, node.metasize, smf);
@@ -820,15 +798,15 @@ genliteraldir(char *name, ino_t ino)
/* XXX instead of done(), clean up and return FAIL? */
if (read(dp, buf, size) == -1) {
(void) fprintf(stderr, gettext(
- "read error extracting inode %d, name %s\n"),
- curfile.ino, curfile.name);
+ "read error extracting inode %d, name %s\n"),
+ curfile.ino, curfile.name);
perror("read");
done(1);
}
if (write(ofile, buf, size) == -1) {
(void) fprintf(stderr, gettext(
- "write error extracting inode %d, name %s\n"),
- curfile.ino, curfile.name);
+ "write error extracting inode %d, name %s\n"),
+ curfile.ino, curfile.name);
perror("write");
done(1);
}
@@ -882,9 +860,9 @@ allocinotab(ino_t ino, struct dinode *dip, off64_t seekpt)
node.timep[1] = dip->di_mtime;
node.mode = dip->di_mode;
node.uid =
- dip->di_suid == UID_LONG ? dip->di_uid : (uid_t)dip->di_suid;
+ dip->di_suid == UID_LONG ? dip->di_uid : (uid_t)dip->di_suid;
node.gid =
- dip->di_sgid == GID_LONG ? dip->di_gid : (gid_t)dip->di_sgid;
+ dip->di_sgid == GID_LONG ? dip->di_gid : (gid_t)dip->di_sgid;
return (itp);
}
diff --git a/usr/src/cmd/backup/restore/interactive.c b/usr/src/cmd/backup/restore/interactive.c
index 3d2c2c7bb0..7c4be45255 100644
--- a/usr/src/cmd/backup/restore/interactive.c
+++ b/usr/src/cmd/backup/restore/interactive.c
@@ -33,7 +33,6 @@ static char *nextarg = NULL;
static int dontexpand; /* co-routine state set in getnext, used in expandarg */
-#ifdef __STDC__
static void getcmd(char *, char *, size_t, char *, size_t, struct arglist *);
static void expandarg(char *, struct arglist *);
static void printlist(char *, ino_t, char *, int);
@@ -43,27 +42,12 @@ static int fcmp(struct afile *, struct afile *);
static char *fmtentry(struct afile *);
static void setpagercmd(void);
static uint_t setpagerargs(char **);
-#else
-static void getcmd();
-static void expandarg();
-static void printlist();
-static void formatf();
-static char *copynext();
-static int fcmp();
-static char *fmtentry();
-static void setpagercmd();
-static uint_t setpagerargs();
-#endif
/*
* Read and execute commands from the terminal.
*/
void
-#ifdef __STDC__
runcmdshell(void)
-#else
-runcmdshell()
-#endif
{
struct entry *np;
ino_t ino;
@@ -120,7 +104,7 @@ loop:
break;
if (inodetype(ino) == LEAF) {
(void) fprintf(stderr,
- gettext("%s: not a directory\n"), name);
+ gettext("%s: not a directory\n"), name);
break;
}
@@ -139,7 +123,7 @@ loop:
np = lookupname(name);
if (np == NIL || (np->e_flags & NEW) == 0) {
(void) fprintf(stderr,
- gettext("%s: not on extraction list\n"), name);
+ gettext("%s: not on extraction list\n"), name);
break;
}
treescan(name, np->e_ino, deletefile);
@@ -168,7 +152,7 @@ loop:
case '?':
/* ANSI string catenation, to shut cstyle up */
(void) fprintf(stderr, "%s",
- gettext("Available commands are:\n"
+ gettext("Available commands are:\n"
"\tls [arg] - list directory\n"
"\tmarked [arg] - list items marked for extraction from directory\n"
"\tcd arg - change directory\n"
@@ -235,7 +219,7 @@ loop:
">>>pager_vector[%d] = `%s'\n",
index,
pager_vector[index] ?
- pager_vector[index] : "(null)");
+ pager_vector[index] : "(null)");
index += 1;
}
}
@@ -313,7 +297,7 @@ loop:
default:
bad:
(void) fprintf(stderr,
- gettext("%s: unknown command; type ? for help\n"), cmd);
+ gettext("%s: unknown command; type ? for help\n"), cmd);
break;
ambiguous:
(void) fprintf(stderr,
@@ -339,10 +323,8 @@ static char input[MAXCOMPLEXLEN]; /* shared by getcmd() and setpagercmd() */
*/
/* ARGSUSED */
static void
-getcmd(curdir, cmd, cmdsiz, name, namesiz, ap)
- char *curdir, *cmd, *name;
- size_t cmdsiz, namesiz;
- struct arglist *ap;
+getcmd(char *curdir, char *cmd, size_t cmdsiz, char *name, size_t namesiz,
+ struct arglist *ap)
{
char *cp;
char output[MAXCOMPLEXLEN];
@@ -460,9 +442,7 @@ getnext:
* Strip off the next token of the input.
*/
static char *
-copynext(input, output, outsize)
- char *input, *output;
- size_t outsize;
+copynext(char *input, char *output, size_t outsize)
{
char *cp, *bp, *limit;
char quote;
@@ -528,9 +508,7 @@ copynext(input, output, outsize)
* The pathname "canonname" is returned double null terminated.
*/
void
-canon(rawname, canonname, limit)
- char *rawname, *canonname;
- size_t limit;
+canon(char *rawname, char *canonname, size_t limit)
{
char *cp, *np, *prefix;
uint_t len;
@@ -609,9 +587,7 @@ canon(rawname, canonname, limit)
* "[...a-z...]" in params matches a through z.
*/
static void
-expandarg(arg, ap)
- char *arg;
- struct arglist *ap;
+expandarg(char *arg, struct arglist *ap)
{
static struct afile single;
int size;
@@ -646,11 +622,7 @@ expandarg(arg, ap)
* Do an "ls" style listing of a directory
*/
static void
-printlist(name, ino, basename, marked_only)
- char *name;
- ino_t ino;
- char *basename;
- int marked_only;
+printlist(char *name, ino_t ino, char *basename, int marked_only)
{
struct afile *fp;
struct direct *dp;
@@ -731,8 +703,7 @@ printlist(name, ino, basename, marked_only)
* Print out a pretty listing of a directory
*/
static void
-formatf(ap)
- struct arglist *ap;
+formatf(struct arglist *ap)
{
struct afile *fp;
struct entry *np;
@@ -829,8 +800,7 @@ formatf(ap)
* Comparison routine for qsort.
*/
static int
-fcmp(f1, f2)
- struct afile *f1, *f2;
+fcmp(struct afile *f1, struct afile *f2)
{
return (strcoll(f1->fname, f2->fname));
@@ -840,8 +810,7 @@ fcmp(f1, f2)
* Format a directory entry.
*/
static char *
-fmtentry(fp)
- struct afile *fp;
+fmtentry(struct afile *fp)
{
static char fmtres[MAXCOMPLEXLEN];
static int precision = 0;
@@ -890,8 +859,7 @@ fmtentry(fp)
*/
/* ARGSUSED */
void
-onintr(sig)
- int sig;
+onintr(int sig)
{
char buf[300];
@@ -907,11 +875,7 @@ onintr(sig)
* Set up pager_catenated and pager_vector.
*/
void
-#ifdef __STDC__
initpagercmd(void)
-#else
-initpagercmd()
-#endif
{
char *cp;
@@ -944,11 +908,7 @@ initpagercmd()
* Resets pager_catenated and pager_vector from user input.
*/
void
-#ifdef __STDC__
setpagercmd(void)
-#else
-setpagercmd()
-#endif
{
uint_t catenate_length;
int index;
@@ -984,7 +944,7 @@ setpagercmd()
(void) fprintf(stderr, gettext("got command `%s'\n"), input);
catenate_length = setpagerargs(&nextarg) + strlen(pager_vector[0]) + 1;
pager_catenated = (char *)malloc(catenate_length *
- (size_t)sizeof (char));
+ (size_t)sizeof (char));
if (pager_catenated == (char *)NULL) {
(void) fprintf(stderr, gettext("out of memory\n"));
done(1);
@@ -1001,8 +961,7 @@ setpagercmd()
* Extract arguments for the pager command from getcmd()'s input buffer.
*/
static uint_t
-setpagerargs(source)
- char **source;
+setpagerargs(char **source)
{
char word[MAXCOMPLEXLEN];
char *cp = *source;
@@ -1013,7 +972,7 @@ setpagerargs(source)
if (dflag)
fprintf(stderr, gettext("got word `%s'\n"), word);
pager_vector = (char **)realloc(pager_vector,
- (size_t)sizeof (char *) * (pager_len + 1));
+ (size_t)sizeof (char *) * (pager_len + 1));
if (pager_vector == (char **)NULL) {
(void) fprintf(stderr, gettext("out of memory\n"));
done(1);
diff --git a/usr/src/cmd/backup/restore/restore.c b/usr/src/cmd/backup/restore/restore.c
index f10603e549..f2bb6b4447 100644
--- a/usr/src/cmd/backup/restore/restore.c
+++ b/usr/src/cmd/backup/restore/restore.c
@@ -17,25 +17,16 @@
#undef MAXNAMLEN
#include <dirent.h>
-#ifdef __STDC__
static char *keyval(int);
static void removexattrs(struct entry *);
static void movexattrs(char *, char *);
-#else
-static char *keyval();
-static void removexattrs();
-static void movexattrs();
-#endif
/*
* This implements the 't' option.
* List entries on the tape.
*/
long
-listfile(name, ino, type)
- char *name;
- ino_t ino;
- int type;
+listfile(char *name, ino_t ino, int type)
{
long descend = hflag ? GOOD : FAIL;
@@ -52,10 +43,7 @@ listfile(name, ino, type)
* Request that new entries be extracted.
*/
long
-addfile(name, ino, type)
- char *name;
- ino_t ino;
- int type;
+addfile(char *name, ino_t ino, int type)
{
struct entry *ep;
long descend = hflag ? GOOD : FAIL;
@@ -106,10 +94,7 @@ addfile(name, ino, type)
*/
/* ARGSUSED */
long
-deletefile(name, ino, type)
- char *name;
- ino_t ino;
- int type;
+deletefile(char *name, ino_t ino, int type)
{
long descend = hflag ? GOOD : FAIL;
struct entry *ep;
@@ -145,11 +130,7 @@ static struct entry *removelist;
* Remove directories from the lookup chains.
*/
void
-#ifdef __STDC__
removeoldleaves(void)
-#else
-removeoldleaves()
-#endif
{
struct entry *ep;
ino_t i;
@@ -192,10 +173,7 @@ removeoldleaves()
* Renames are done at the same time.
*/
long
-nodeupdates(name, ino, type)
- char *name;
- ino_t ino;
- int type;
+nodeupdates(char *name, ino_t ino, int type)
{
struct entry *ep, *np, *ip;
long descend = GOOD;
@@ -282,7 +260,7 @@ nodeupdates(name, ino, type)
} else {
dprintf(stdout,
gettext("name/inode conflict, mktempname %s\n"),
- myname(np));
+ myname(np));
mktempname(np);
}
np = NIL;
@@ -351,7 +329,7 @@ nodeupdates(name, ino, type)
/* LINTED: result fits into a short */
ep->e_flags |= NEW|KEEP;
dprintf(stdout, "[%s] %s: %s\n", keyval(key), name,
- flagvalues(ep));
+ flagvalues(ep));
break;
/*
@@ -409,7 +387,7 @@ nodeupdates(name, ino, type)
/* LINTED: result fits into a short */
np->e_flags |= KEEP;
dprintf(stdout, "[%s] %s: %s\n", keyval(key), name,
- flagvalues(np));
+ flagvalues(np));
break;
/*
@@ -448,7 +426,7 @@ nodeupdates(name, ino, type)
/* LINTED: result fits into a short */
ip->e_flags |= NEW|KEEP;
dprintf(stdout, "[%s] %s: %s\n", keyval(key), name,
- flagvalues(ip));
+ flagvalues(ip));
break;
/*
@@ -457,8 +435,7 @@ nodeupdates(name, ino, type)
*/
case NAMEFND:
dprintf(stdout, gettext("[%s] %s: Extraneous name\n"),
- keyval(key),
- name);
+ keyval(key), name);
descend = FAIL;
break;
@@ -505,8 +482,7 @@ nodeupdates(name, ino, type)
* Calculate the active flags in a key.
*/
static char *
-keyval(key)
- int key;
+keyval(int key)
{
static char keybuf[32];
@@ -529,11 +505,7 @@ keyval(key)
* Find unreferenced link names.
*/
void
-#ifdef __STDC__
findunreflinks(void)
-#else
-findunreflinks()
-#endif
{
struct entry *ep, *np;
ino_t i;
@@ -561,7 +533,7 @@ findunreflinks()
if (np->e_type == LEAF) {
if (np->e_flags != 0)
badentry(np, gettext(
- "unreferenced with flags"));
+ "unreferenced with flags"));
dprintf(stdout, gettext(
"%s: remove unreferenced name\n"),
myname(np));
@@ -582,11 +554,7 @@ findunreflinks()
* time O(N).
*/
void
-#ifdef __STDC__
removeoldnodes(void)
-#else
-removeoldnodes()
-#endif
{
struct entry *ep, **prev;
long change;
@@ -615,8 +583,7 @@ removeoldnodes()
* Extract new leaves.
*/
void
-createleaves(symtabfile)
- char *symtabfile;
+createleaves(char *symtabfile)
{
struct entry *ep;
char name[MAXCOMPLEXLEN];
@@ -668,7 +635,7 @@ createleaves(symtabfile)
if (first != curfile.ino) {
(void) fprintf(stderr,
gettext("expected next file %d, got %d\n"),
- first, curfile.ino);
+ first, curfile.ino);
skipfile();
goto next;
}
@@ -724,11 +691,7 @@ createleaves(symtabfile)
* Efficiently extract a subset of the files on a tape.
*/
void
-#ifdef __STDC__
createfiles(void)
-#else
-createfiles()
-#endif
{
ino_t first, next, last;
struct entry *ep;
@@ -842,11 +805,7 @@ createfiles()
* Add links.
*/
void
-#ifdef __STDC__
createlinks(void)
-#else
-createlinks()
-#endif
{
struct entry *np, *ep;
ino_t i;
@@ -868,8 +827,9 @@ createlinks()
if (fchdir(dfd) < 0) {
saverr = errno;
(void) fprintf(stderr,
- gettext("%s->%s: link failed: %s\n"),
- from, to, strerror(saverr));
+ gettext(
+ "%s->%s: link failed: %s\n"),
+ from, to, strerror(saverr));
(void) close(dfd);
continue;
}
@@ -896,11 +856,7 @@ createlinks()
* that no temporary names remain.
*/
void
-#ifdef __STDC__
checkrestore(void)
-#else
-checkrestore()
-#endif
{
struct entry *ep;
ino_t i;
@@ -925,10 +881,7 @@ checkrestore()
* A paranoid check that things are as they should be.
*/
long
-verifyfile(name, ino, type)
- char *name;
- ino_t ino;
- int type;
+verifyfile(char *name, ino_t ino, int type)
{
struct entry *np, *ep;
long descend = GOOD;
@@ -961,8 +914,7 @@ verifyfile(name, ino, type)
* parent file is removed.
*/
static void
-removexattrs(ep)
- struct entry *ep;
+removexattrs(struct entry *ep)
{
struct entry *np = ep;
@@ -985,9 +937,7 @@ removexattrs(ep)
* the file named by the second argument (targ).
*/
static void
-movexattrs(orig, targ)
- char *orig;
- char *targ;
+movexattrs(char *orig, char *targ)
{
char *to, *from;
int fromfd, fromdir, tofd, todir, tfd;
@@ -1014,11 +964,12 @@ movexattrs(orig, targ)
goto out;
}
if ((fromdir = openat64(fromfd, ".",
- O_RDONLY|O_NONBLOCK|O_XATTR)) == -1) {
+ O_RDONLY|O_NONBLOCK|O_XATTR)) == -1) {
fprintf(stderr, gettext("%s: cannot access attributes: "),
- from);
+ from);
perror("");
- if (tfd != AT_FDCWD) (void) close(tfd);
+ if (tfd != AT_FDCWD)
+ (void) close(tfd);
goto out;
}
if (tfd != AT_FDCWD) (void) close(tfd);
@@ -1036,8 +987,8 @@ movexattrs(orig, targ)
if ((tfd = dup(fromdir)) == -1 ||
(dirp = fdopendir(tfd)) == NULL) {
fprintf(stderr,
- gettext("%s: cannot allocate DIR structure to attribute directory: "),
- from);
+ gettext("%s: cannot allocate DIR structure to attribute "
+ "directory: "), from);
perror("");
if (tfd != -1) (void) close(tfd);
goto out;
@@ -1045,13 +996,13 @@ movexattrs(orig, targ)
while ((dp = readdir(dirp)) != NULL) {
if ((dp->d_name[0] == '.' && dp->d_name[1] == '\0') ||
- (dp->d_name[0] == '.' && dp->d_name[1] == '.' &&
- dp->d_name[2] == '\0'))
+ (dp->d_name[0] == '.' && dp->d_name[1] == '.' &&
+ dp->d_name[2] == '\0'))
continue;
if ((renameat(fromdir, dp->d_name, todir, dp->d_name)) == -1) {
fprintf(stderr,
- gettext("%s: cannot move attribute %s: "),
- from, dp->d_name);
+ gettext("%s: cannot move attribute %s: "),
+ from, dp->d_name);
goto out;
}
}
diff --git a/usr/src/cmd/backup/restore/restore.h b/usr/src/cmd/backup/restore/restore.h
index 3bd76044c4..d1002703b3 100644
--- a/usr/src/cmd/backup/restore/restore.h
+++ b/usr/src/cmd/backup/restore/restore.h
@@ -63,8 +63,8 @@ extern int autoload_tries; /* number of times to check on autoload */
extern int autoload_period; /* seconds, tries*period = total wait time */
extern struct byteorder_ctx *byteorder;
extern char *progname; /* our name */
-extern char *dumpmap; /* map of inodes on this dump tape */
-extern char *clrimap; /* map of inodes to be deleted */
+extern char *dumpmap; /* map of inodes on this dump tape */
+extern char *clrimap; /* map of inodes to be deleted */
extern char *c_label; /* label we expect to see on the tape */
extern ino_t maxino; /* highest numbered inode in this file system */
extern long dumpnum; /* location of the dump on this tape */
@@ -120,7 +120,6 @@ struct entry {
/*
* functions defined on entry structs
*/
-#ifdef __STDC__
extern struct entry *lookupino(ino_t);
extern struct entry *lookupname(char *);
extern struct entry *addentry(char *, ino_t, int);
@@ -142,29 +141,6 @@ extern ino_t upperbnd(ino_t);
extern void badentry(struct entry *, char *);
extern char *flagvalues(struct entry *);
extern ino_t dirlookup(char *);
-#else
-extern struct entry *lookupino();
-extern struct entry *lookupname();
-extern struct entry *addentry();
-extern void deleteino();
-extern char *myname();
-extern void freeentry();
-extern void moveentry();
-extern char *savename();
-extern void freename();
-extern void dumpsymtable();
-extern void initsymtable();
-extern void mktempname();
-extern char *gentempname();
-extern void newnode();
-extern void removenode();
-extern void removeleaf();
-extern ino_t lowerbnd();
-extern ino_t upperbnd();
-extern void badentry();
-extern char *flagvalues();
-extern ino_t dirlookup();
-#endif
#define NIL ((struct entry *)(0))
/*
diff --git a/usr/src/cmd/backup/restore/symtab.c b/usr/src/cmd/backup/restore/symtab.c
index 5bffc3d5c4..94221a377e 100644
--- a/usr/src/cmd/backup/restore/symtab.c
+++ b/usr/src/cmd/backup/restore/symtab.c
@@ -35,22 +35,15 @@
static struct entry **entry;
static uint_t entrytblsize;
-#ifdef __STDC__
static void addino(ino_t, struct entry *);
static struct entry *lookupparent(char *);
static void removeentry(struct entry *);
-#else
-static void addino();
-static struct entry *lookupparent();
-static void removeentry();
-#endif
/*
* Look up an entry by inode number
*/
struct entry *
-lookupino(inum)
- ino_t inum;
+lookupino(ino_t inum)
{
struct entry *ep;
@@ -78,9 +71,7 @@ static int complained_about_range = 0;
* Add an entry into the entry table
*/
static void
-addino(inum, np)
- ino_t inum;
- struct entry *np;
+addino(ino_t inum, struct entry *np)
{
struct entry **epp;
@@ -107,8 +98,7 @@ addino(inum, np)
* arranges for the necessary memory reclamation, if needed.
*/
void
-deleteino(inum)
- ino_t inum;
+deleteino(ino_t inum)
{
struct entry *next;
struct entry **prev;
@@ -141,8 +131,7 @@ deleteino(inum)
* NULL characters.
*/
struct entry *
-lookupname(name)
- char *name;
+lookupname(char *name)
{
struct entry *ep;
char *np, *cp;
@@ -186,8 +175,7 @@ lookupname(name)
* names so the provided name argument must terminate with two NULLs.
*/
static struct entry *
-lookupparent(name)
- char *name;
+lookupparent(char *name)
{
struct entry *ep;
char *tailindex, savechar, *lastpart;
@@ -233,8 +221,7 @@ lookupparent(name)
* terminated with two NULLs.
*/
char *
-myname(ep)
- struct entry *ep;
+myname(struct entry *ep)
{
char *cp;
struct entry *root = lookupino(ROOTINO);
@@ -268,10 +255,7 @@ static struct entry *freelist = NIL;
* add an entry to the symbol table
*/
struct entry *
-addentry(name, inum, type)
- char *name;
- ino_t inum;
- int type;
+addentry(char *name, ino_t inum, int type)
{
struct entry *np, *ep;
char *cp;
@@ -362,8 +346,7 @@ addentry(name, inum, type)
* delete an entry from the symbol table
*/
void
-freeentry(ep)
- struct entry *ep;
+freeentry(struct entry *ep)
{
struct entry *np;
ino_t inum;
@@ -406,9 +389,7 @@ freeentry(ep)
* Relocate an entry in the tree structure
*/
void
-moveentry(ep, newname)
- struct entry *ep;
- char *newname;
+moveentry(struct entry *ep, char *newname)
{
struct entry *np;
char *cp;
@@ -444,8 +425,7 @@ moveentry(ep, newname)
* Remove an entry in the tree structure
*/
static void
-removeentry(ep)
- struct entry *ep;
+removeentry(struct entry *ep)
{
struct entry *np;
@@ -455,7 +435,7 @@ removeentry(ep)
np->e_xattrs = NIL;
else
badentry(ep, gettext(
- "parent does not reference this xattr tree"));
+ "parent does not reference this xattr tree"));
} else if (np->e_entries == ep) {
np->e_entries = ep->e_sibling;
} else {
@@ -467,7 +447,7 @@ removeentry(ep)
}
if (np == NIL)
badentry(ep, gettext(
- "cannot find entry in parent list"));
+ "cannot find entry in parent list"));
}
}
@@ -499,8 +479,7 @@ static struct strhdr strtblhdr[allocsize(MAXCOMPLEXLEN) / STRTBLINCR];
* has an appropriate sized entry, and if not allocates a new one.
*/
char *
-savename(name)
- char *name;
+savename(char *name)
{
struct strhdr *np;
size_t len, as;
@@ -540,8 +519,7 @@ savename(name)
* appropriate free list.
*/
void
-freename(name)
- char *name;
+freename(char *name)
{
struct strhdr *tp, *np;
@@ -572,9 +550,7 @@ struct symtableheader {
* dump a snapshot of the symbol table
*/
void
-dumpsymtable(filename, checkpt)
- char *filename;
- int checkpt;
+dumpsymtable(char *filename, int checkpt)
{
struct entry *ep, *tep;
ino_t i;
@@ -621,19 +597,19 @@ dumpsymtable(filename, checkpt)
tep->e_parent = (struct entry *)ep->e_parent->e_index;
if (ep->e_links != NIL)
tep->e_links =
- (struct entry *)ep->e_links->e_index;
+ (struct entry *)ep->e_links->e_index;
if (ep->e_sibling != NIL)
tep->e_sibling =
- (struct entry *)ep->e_sibling->e_index;
+ (struct entry *)ep->e_sibling->e_index;
if (ep->e_entries != NIL)
tep->e_entries =
- (struct entry *)ep->e_entries->e_index;
+ (struct entry *)ep->e_entries->e_index;
if (ep->e_xattrs != NIL)
tep->e_xattrs =
- (struct entry *)ep->e_xattrs->e_index;
+ (struct entry *)ep->e_xattrs->e_index;
if (ep->e_next != NIL)
tep->e_next =
- (struct entry *)ep->e_next->e_index;
+ (struct entry *)ep->e_next->e_index;
(void) fwrite((char *)tep, sizeof (*tep), 1, fp);
}
}
@@ -672,8 +648,7 @@ dumpsymtable(filename, checkpt)
* Initialize a symbol table from a file
*/
void
-initsymtable(filename)
- char *filename;
+initsymtable(char *filename)
{
char *base;
off64_t tblsize;
@@ -693,15 +668,23 @@ initsymtable(filename)
}
/* LINTED: result fits in entrytblsize */
entrytblsize = maxino / HASHFACTOR;
- entry = (struct entry **)
- /* LINTED entrytblsize fits in a size_t */
- calloc((size_t)entrytblsize, sizeof (*entry));
- if (entry == (struct entry **)NULL) {
+ entry = calloc((size_t)entrytblsize, sizeof (*entry));
+ if (entry == NULL) {
(void) fprintf(stderr,
gettext("no memory for entry table\n"));
done(1);
}
- ep = addentry(".", ROOTINO, NODE);
+ ep = calloc(1, sizeof (*ep));
+ if (ep == NULL) {
+ (void) fprintf(stderr,
+ gettext("no memory for entry\n"));
+ done(1);
+ }
+ ep->e_type = NODE;
+ ep->e_name = savename(".");
+ ep->e_namlen = 1;
+ ep->e_parent = ep;
+ addino(ROOTINO, ep);
/* LINTED: result fits in a short */
ep->e_flags |= NEW;
return;
@@ -763,10 +746,10 @@ initsymtable(filename)
if (hdr.dumpdate != dumptime) {
if (hdr.dumpdate < dumptime)
(void) fprintf(stderr, gettext(
- "Incremental volume too low\n"));
+ "Incremental volume too low\n"));
else
(void) fprintf(stderr, gettext(
- "Incremental volume too high\n"));
+ "Incremental volume too high\n"));
done(1);
}
break;
diff --git a/usr/src/cmd/backup/restore/utilities.c b/usr/src/cmd/backup/restore/utilities.c
index db232c545d..8edc5c0b5e 100644
--- a/usr/src/cmd/backup/restore/utilities.c
+++ b/usr/src/cmd/backup/restore/utilities.c
@@ -484,7 +484,6 @@ reply(char *question)
/*
* Note that a panic w/ EOF on the tty means all panics will return...
*/
-#ifdef __STDC__
#include <stdarg.h>
/* VARARGS1 */
@@ -502,27 +501,6 @@ panic(const char *msg, ...)
done(1);
}
}
-#else
-#include <varargs.h>
-
-/* VARARGS1 */
-void
-panic(va_dcl)
-{
- va_list args;
- char *msg;
-
- va_start(args);
- msg = va_arg(args, char *);
- (void) vfprintf(stderr, msg, args);
- va_end(args);
- if (reply(gettext("abort")) == GOOD) {
- if (reply(gettext("dump core")) == GOOD)
- abort();
- done(1);
- }
-}
-#endif
/*
* Locale-specific version of ctime
@@ -823,13 +801,8 @@ mkentry(char *name, ino_t ino, struct arglist *ap)
return (GOOD);
}
-#ifdef __STDC__
static int gmatch(wchar_t *, wchar_t *);
static int addg(struct direct *, char *, char *, struct arglist *);
-#else
-static int gmatch();
-static int addg();
-#endif
/*
* XXX This value is ASCII (but not language) dependent. In