Make this work after the fsck changes.

This commit is contained in:
christos 1996-09-28 19:30:35 +00:00
parent 195da734cb
commit 60e2d41cb1
4 changed files with 70 additions and 63 deletions

View File

@ -1,14 +1,17 @@
# $NetBSD: Makefile,v 1.3 1996/04/08 21:03:06 jtc Exp $ # $NetBSD: Makefile,v 1.4 1996/09/28 19:30:35 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 6/5/93 # @(#)Makefile 8.1 (Berkeley) 6/5/93
PROG= fsdb PROG= fsdb
MAN= fsdb.8 MAN= fsdb.8
SRCS= fsdb.c fsdbutil.c \ SRCS= fsdb.c fsdbutil.c
dir.c inode.c pass1.c pass1b.c pass2.c pass3.c pass4.c \ SRCS+= dir.c inode.c pass1.c pass1b.c pass2.c pass3.c pass4.c \
pass5.c preen.c setup.c utilities.c ffs_subr.c ffs_tables.c pass5.c setup.c utilities.c
CFLAGS+= -I${.CURDIR}/../../sbin/fsck_ffs SRCS+= ffs_subr.c ffs_tables.c
SRCS+= preen.c fsutil.o
CFLAGS+= -I${.CURDIR}/../fsck_ffs -I${.CURDIR}/../fsck
LDADD+= -ledit -ltermcap LDADD+= -ledit -ltermcap
DPADD+= ${LIBEDIT} ${LIBTERMCAP} DPADD+= ${LIBEDIT} ${LIBTERMCAP}
.PATH: ${.CURDIR}/../../sbin/fsck_ffs ${.CURDIR}/../../sys/ufs/ffs .PATH: ${.CURDIR}/../fsck ${.CURDIR}/../fsck_ffs ${.CURDIR}/../../sys/ufs/ffs
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@ -1,4 +1,4 @@
/* $NetBSD: fsdb.c,v 1.4 1996/03/21 17:56:15 jtc Exp $ */ /* $NetBSD: fsdb.c,v 1.5 1996/09/28 19:30:35 christos Exp $ */
/*- /*-
* Copyright (c) 1996 The NetBSD Foundation, Inc. * Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/ */
#ifndef lint #ifndef lint
static char rcsid[] = "$NetBSD: fsdb.c,v 1.4 1996/03/21 17:56:15 jtc Exp $"; static char rcsid[] = "$NetBSD: fsdb.c,v 1.5 1996/09/28 19:30:35 christos Exp $";
#endif /* not lint */ #endif /* not lint */
#include <sys/types.h> #include <sys/types.h>
@ -55,6 +55,7 @@ static char rcsid[] = "$NetBSD: fsdb.c,v 1.4 1996/03/21 17:56:15 jtc Exp $";
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <err.h>
#include <ufs/ufs/dinode.h> #include <ufs/ufs/dinode.h>
#include <ufs/ufs/dir.h> #include <ufs/ufs/dir.h>
@ -62,20 +63,31 @@ static char rcsid[] = "$NetBSD: fsdb.c,v 1.4 1996/03/21 17:56:15 jtc Exp $";
#include "fsdb.h" #include "fsdb.h"
#include "fsck.h" #include "fsck.h"
#include "extern.h"
extern char *__progname; /* from crt0.o */ extern char *__progname; /* from crt0.o */
void usage __P((void)); int main __P((int, char *[]));
int cmdloop __P((void)); static void usage __P((void));
static int cmdloop __P((void));
static int helpfn __P((int, char *[]));
static char *prompt __P((EditLine *));
static int scannames __P((struct inodesc *));
static int dolookup __P((char *));
static int chinumfunc __P((struct inodesc *));
static int chnamefunc __P((struct inodesc *));
static int dotime __P((char *, int32_t *, int32_t *));
void int returntosingle = 0;
struct dinode *curinode;
ino_t curinum;
static void
usage() usage()
{ {
errx(1, "usage: %s [-d] -f <fsname>", __progname); errx(1, "usage: %s [-d] -f <fsname>", __progname);
} }
int returntosingle = 0;
/* /*
* We suck in lots of fsck code, and just pick & choose the stuff we want. * We suck in lots of fsck code, and just pick & choose the stuff we want.
* *
@ -89,7 +101,6 @@ main(argc, argv)
{ {
int ch, rval; int ch, rval;
char *fsys = NULL; char *fsys = NULL;
struct stat stb;
while (-1 != (ch = getopt(argc, argv, "f:d"))) { while (-1 != (ch = getopt(argc, argv, "f:d"))) {
switch (ch) { switch (ch) {
@ -119,9 +130,9 @@ main(argc, argv)
exit(rval); exit(rval);
} }
#define CMDFUNC(func) int func __P((int argc, char *argv[])) #define CMDFUNC(func) static int func __P((int argc, char *argv[]))
#define CMDFUNCSTART(func) int func(argc, argv) \ #define CMDFUNCSTART(func) static int func(argc, argv) \
int argc; \ int argc; \
char *argv[]; char *argv[];
CMDFUNC(helpfn); CMDFUNC(helpfn);
@ -149,7 +160,7 @@ CMDFUNC(chatime); /* Change atime */
CMDFUNC(chinum); /* Change inode # of dirent */ CMDFUNC(chinum); /* Change inode # of dirent */
CMDFUNC(chname); /* Change dirname of dirent */ CMDFUNC(chname); /* Change dirname of dirent */
struct cmdtable cmds[] = { static struct cmdtable cmds[] = {
{ "help", "Print out help", 1, 1, helpfn }, { "help", "Print out help", 1, 1, helpfn },
{ "?", "Print out help", 1, 1, helpfn }, { "?", "Print out help", 1, 1, helpfn },
{ "inode", "Set active inode to INUM", 2, 2, focus }, { "inode", "Set active inode to INUM", 2, 2, focus },
@ -183,7 +194,7 @@ struct cmdtable cmds[] = {
{ NULL, 0, 0, 0 }, { NULL, 0, 0, 0 },
}; };
int static int
helpfn(argc, argv) helpfn(argc, argv)
int argc; int argc;
char *argv[]; char *argv[];
@ -199,7 +210,7 @@ helpfn(argc, argv)
return 0; return 0;
} }
char * static char *
prompt(el) prompt(el)
EditLine *el; EditLine *el;
{ {
@ -209,7 +220,7 @@ prompt(el)
} }
int static int
cmdloop() cmdloop()
{ {
char *line; char *line;
@ -276,8 +287,7 @@ cmdloop()
return rval; return rval;
} }
struct dinode *curinode; static ino_t ocurrent;
ino_t curinum, ocurrent;
#define GETINUM(ac,inum) inum = strtoul(argv[ac], &cp, 0); \ #define GETINUM(ac,inum) inum = strtoul(argv[ac], &cp, 0); \
if (inum < ROOTINO || inum > maxino || cp == argv[ac] || *cp != '\0' ) { \ if (inum < ROOTINO || inum > maxino || cp == argv[ac] || *cp != '\0' ) { \
@ -355,7 +365,7 @@ CMDFUNCSTART(downlink)
return 0; return 0;
} }
const char *typename[] = { static const char *typename[] = {
"unknown", "unknown",
"fifo", "fifo",
"char special", "char special",
@ -373,9 +383,9 @@ const char *typename[] = {
"whiteout", "whiteout",
}; };
int slot; static int slot;
int static int
scannames(idesc) scannames(idesc)
struct inodesc *idesc; struct inodesc *idesc;
{ {
@ -403,9 +413,6 @@ CMDFUNCSTART(ls)
return 0; return 0;
} }
int findino __P((struct inodesc *idesc)); /* from fsck */
static int dolookup __P((char *name));
static int static int
dolookup(name) dolookup(name)
char *name; char *name;
@ -463,7 +470,6 @@ CMDFUNCSTART(focusname)
CMDFUNCSTART(ln) CMDFUNCSTART(ln)
{ {
ino_t inum; ino_t inum;
struct dinode *dp;
int rval; int rval;
char *cp; char *cp;
@ -496,9 +502,9 @@ CMDFUNCSTART(rm)
} }
} }
long slotcount, desired; static long slotcount, desired;
int static int
chinumfunc(idesc) chinumfunc(idesc)
struct inodesc *idesc; struct inodesc *idesc;
{ {
@ -513,7 +519,6 @@ chinumfunc(idesc)
CMDFUNCSTART(chinum) CMDFUNCSTART(chinum)
{ {
int rval;
char *cp; char *cp;
ino_t inum; ino_t inum;
struct inodesc idesc; struct inodesc idesc;
@ -543,31 +548,30 @@ CMDFUNCSTART(chinum)
} }
} }
int static int
chnamefunc(idesc) chnamefunc(idesc)
struct inodesc *idesc; struct inodesc *idesc;
{ {
register struct direct *dirp = idesc->id_dirp; register struct direct *dirp = idesc->id_dirp;
struct direct testdir; struct direct testdir;
if (slotcount++ == desired) { if (slotcount++ == desired) {
/* will name fit? */ /* will name fit? */
testdir.d_namlen = strlen(idesc->id_name); testdir.d_namlen = strlen(idesc->id_name);
if (DIRSIZ(NEWDIRFMT, &testdir) <= dirp->d_reclen) { if (DIRSIZ(NEWDIRFMT, &testdir) <= dirp->d_reclen) {
dirp->d_namlen = testdir.d_namlen; dirp->d_namlen = testdir.d_namlen;
strcpy(dirp->d_name, idesc->id_name); strcpy(dirp->d_name, idesc->id_name);
return STOP|ALTERED|FOUND; return STOP|ALTERED|FOUND;
} else } else
return STOP|FOUND; /* won't fit, so give up */ return STOP|FOUND; /* won't fit, so give up */
} }
return KEEPON; return KEEPON;
} }
CMDFUNCSTART(chname) CMDFUNCSTART(chname)
{ {
int rval; int rval;
char *cp; char *cp;
ino_t inum;
struct inodesc idesc; struct inodesc idesc;
slotcount = 0; slotcount = 0;
@ -598,7 +602,7 @@ CMDFUNCSTART(chname)
} }
} }
struct typemap { static struct typemap {
const char *typename; const char *typename;
int typebits; int typebits;
} typenamemap[] = { } typenamemap[] = {
@ -610,7 +614,6 @@ struct typemap {
CMDFUNCSTART(newtype) CMDFUNCSTART(newtype)
{ {
int rval = 1;
int type; int type;
struct typemap *tp; struct typemap *tp;
@ -748,7 +751,7 @@ CMDFUNCSTART(chowner)
uid = strtoul(argv[1], &cp, 0); uid = strtoul(argv[1], &cp, 0);
if (cp == argv[1] || *cp != '\0' ) { if (cp == argv[1] || *cp != '\0' ) {
/* try looking up name */ /* try looking up name */
if (pwd = getpwnam(argv[1])) { if ((pwd = getpwnam(argv[1])) != 0) {
uid = pwd->pw_uid; uid = pwd->pw_uid;
} else { } else {
warnx("bad uid `%s'", argv[1]); warnx("bad uid `%s'", argv[1]);
@ -774,7 +777,7 @@ CMDFUNCSTART(chgroup)
gid = strtoul(argv[1], &cp, 0); gid = strtoul(argv[1], &cp, 0);
if (cp == argv[1] || *cp != '\0' ) { if (cp == argv[1] || *cp != '\0' ) {
if (grp = getgrnam(argv[1])) { if ((grp = getgrnam(argv[1])) != 0) {
gid = grp->gr_gid; gid = grp->gr_gid;
} else { } else {
warnx("bad gid `%s'", argv[1]); warnx("bad gid `%s'", argv[1]);
@ -788,7 +791,7 @@ CMDFUNCSTART(chgroup)
return rval; return rval;
} }
int static int
dotime(name, rsec, rnsec) dotime(name, rsec, rnsec)
char *name; char *name;
int32_t *rsec, *rnsec; int32_t *rsec, *rnsec;

View File

@ -1,4 +1,4 @@
/* $NetBSD: fsdb.h,v 1.3 1996/02/27 22:28:13 jtc Exp $ */ /* $NetBSD: fsdb.h,v 1.4 1996/09/28 19:30:36 christos Exp $ */
/*- /*-
* Copyright (c) 1996 The NetBSD Foundation, Inc. * Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -56,9 +56,9 @@ struct cmdtable {
extern struct dinode *curinode; extern struct dinode *curinode;
extern ino_t curinum; extern ino_t curinum;
int argcount __P((struct cmdtable *cmdp, int argc, char *argv[])); char **crack __P((char *, int *));
char **crack __P((char *line, int *argc)); int argcount __P((struct cmdtable *, int, char *[]));
void printstat __P((const char *cp, ino_t inum, struct dinode *dp)); void printstat __P((const char *, ino_t, struct dinode *));
int printactive __P((void));
int checkactive __P((void)); int checkactive __P((void));
int checkactivedir __P((void)); int checkactivedir __P((void));
int printactive __P((void));

View File

@ -1,4 +1,4 @@
/* $NetBSD: fsdbutil.c,v 1.4 1996/02/27 22:28:16 jtc Exp $ */ /* $NetBSD: fsdbutil.c,v 1.5 1996/09/28 19:30:37 christos Exp $ */
/*- /*-
* Copyright (c) 1996 The NetBSD Foundation, Inc. * Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/ */
#ifndef lint #ifndef lint
static char rcsid[] = "$NetBSD: fsdbutil.c,v 1.4 1996/02/27 22:28:16 jtc Exp $"; static char rcsid[] = "$NetBSD: fsdbutil.c,v 1.5 1996/09/28 19:30:37 christos Exp $";
#endif /* not lint */ #endif /* not lint */
#include <sys/types.h> #include <sys/types.h>
@ -53,6 +53,7 @@ static char rcsid[] = "$NetBSD: fsdbutil.c,v 1.4 1996/02/27 22:28:16 jtc Exp $";
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <err.h>
#include <ufs/ufs/dinode.h> #include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h> #include <ufs/ffs/fs.h>
@ -138,7 +139,7 @@ printstat(cp, inum, dp)
puts("fifo"); puts("fifo");
break; break;
} }
printf("I=%lu MODE=%o SIZE=%qu", inum, dp->di_mode, dp->di_size); printf("I=%u MODE=%o SIZE=%qu", inum, dp->di_mode, dp->di_size);
t = dp->di_mtime; t = dp->di_mtime;
p = ctime(&t); p = ctime(&t);
printf("\n\tMTIME=%15.15s %4.4s [%d nsec]", &p[4], &p[20], printf("\n\tMTIME=%15.15s %4.4s [%d nsec]", &p[4], &p[20],
@ -152,11 +153,11 @@ printstat(cp, inum, dp)
printf("\n\tATIME=%15.15s %4.4s [%d nsec]\n", &p[4], &p[20], printf("\n\tATIME=%15.15s %4.4s [%d nsec]\n", &p[4], &p[20],
dp->di_atimensec); dp->di_atimensec);
if (pw = getpwuid(dp->di_uid)) if ((pw = getpwuid(dp->di_uid)) != NULL)
printf("OWNER=%s ", pw->pw_name); printf("OWNER=%s ", pw->pw_name);
else else
printf("OWNUID=%u ", dp->di_uid); printf("OWNUID=%u ", dp->di_uid);
if (grp = getgrgid(dp->di_gid)) if ((grp = getgrgid(dp->di_gid)) != NULL)
printf("GRP=%s ", grp->gr_name); printf("GRP=%s ", grp->gr_name);
else else
printf("GID=%u ", dp->di_gid); printf("GID=%u ", dp->di_gid);