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
PROG= fsdb
MAN= fsdb.8
SRCS= fsdb.c fsdbutil.c \
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
CFLAGS+= -I${.CURDIR}/../../sbin/fsck_ffs
SRCS= fsdb.c fsdbutil.c
SRCS+= dir.c inode.c pass1.c pass1b.c pass2.c pass3.c pass4.c \
pass5.c setup.c utilities.c
SRCS+= ffs_subr.c ffs_tables.c
SRCS+= preen.c fsutil.o
CFLAGS+= -I${.CURDIR}/../fsck_ffs -I${.CURDIR}/../fsck
LDADD+= -ledit -ltermcap
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>

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.
@ -37,7 +37,7 @@
*/
#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 */
#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 <string.h>
#include <unistd.h>
#include <err.h>
#include <ufs/ufs/dinode.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 "fsck.h"
#include "extern.h"
extern char *__progname; /* from crt0.o */
void usage __P((void));
int cmdloop __P((void));
int main __P((int, char *[]));
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()
{
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.
*
@ -89,7 +101,6 @@ main(argc, argv)
{
int ch, rval;
char *fsys = NULL;
struct stat stb;
while (-1 != (ch = getopt(argc, argv, "f:d"))) {
switch (ch) {
@ -119,9 +130,9 @@ main(argc, argv)
exit(rval);
}
#define CMDFUNC(func) int func __P((int argc, char *argv[]))
#define CMDFUNCSTART(func) int func(argc, argv) \
int argc; \
#define CMDFUNC(func) static int func __P((int argc, char *argv[]))
#define CMDFUNCSTART(func) static int func(argc, argv) \
int argc; \
char *argv[];
CMDFUNC(helpfn);
@ -149,7 +160,7 @@ CMDFUNC(chatime); /* Change atime */
CMDFUNC(chinum); /* Change inode # of dirent */
CMDFUNC(chname); /* Change dirname of dirent */
struct cmdtable cmds[] = {
static struct cmdtable cmds[] = {
{ "help", "Print out help", 1, 1, helpfn },
{ "?", "Print out help", 1, 1, helpfn },
{ "inode", "Set active inode to INUM", 2, 2, focus },
@ -183,7 +194,7 @@ struct cmdtable cmds[] = {
{ NULL, 0, 0, 0 },
};
int
static int
helpfn(argc, argv)
int argc;
char *argv[];
@ -199,7 +210,7 @@ helpfn(argc, argv)
return 0;
}
char *
static char *
prompt(el)
EditLine *el;
{
@ -209,7 +220,7 @@ prompt(el)
}
int
static int
cmdloop()
{
char *line;
@ -276,8 +287,7 @@ cmdloop()
return rval;
}
struct dinode *curinode;
ino_t curinum, ocurrent;
static ino_t ocurrent;
#define GETINUM(ac,inum) inum = strtoul(argv[ac], &cp, 0); \
if (inum < ROOTINO || inum > maxino || cp == argv[ac] || *cp != '\0' ) { \
@ -355,7 +365,7 @@ CMDFUNCSTART(downlink)
return 0;
}
const char *typename[] = {
static const char *typename[] = {
"unknown",
"fifo",
"char special",
@ -373,9 +383,9 @@ const char *typename[] = {
"whiteout",
};
int slot;
static int slot;
int
static int
scannames(idesc)
struct inodesc *idesc;
{
@ -403,9 +413,6 @@ CMDFUNCSTART(ls)
return 0;
}
int findino __P((struct inodesc *idesc)); /* from fsck */
static int dolookup __P((char *name));
static int
dolookup(name)
char *name;
@ -463,7 +470,6 @@ CMDFUNCSTART(focusname)
CMDFUNCSTART(ln)
{
ino_t inum;
struct dinode *dp;
int rval;
char *cp;
@ -496,9 +502,9 @@ CMDFUNCSTART(rm)
}
}
long slotcount, desired;
static long slotcount, desired;
int
static int
chinumfunc(idesc)
struct inodesc *idesc;
{
@ -513,7 +519,6 @@ chinumfunc(idesc)
CMDFUNCSTART(chinum)
{
int rval;
char *cp;
ino_t inum;
struct inodesc idesc;
@ -543,31 +548,30 @@ CMDFUNCSTART(chinum)
}
}
int
static int
chnamefunc(idesc)
struct inodesc *idesc;
{
register struct direct *dirp = idesc->id_dirp;
struct direct testdir;
register struct direct *dirp = idesc->id_dirp;
struct direct testdir;
if (slotcount++ == desired) {
/* will name fit? */
testdir.d_namlen = strlen(idesc->id_name);
if (DIRSIZ(NEWDIRFMT, &testdir) <= dirp->d_reclen) {
dirp->d_namlen = testdir.d_namlen;
strcpy(dirp->d_name, idesc->id_name);
return STOP|ALTERED|FOUND;
} else
return STOP|FOUND; /* won't fit, so give up */
}
return KEEPON;
if (slotcount++ == desired) {
/* will name fit? */
testdir.d_namlen = strlen(idesc->id_name);
if (DIRSIZ(NEWDIRFMT, &testdir) <= dirp->d_reclen) {
dirp->d_namlen = testdir.d_namlen;
strcpy(dirp->d_name, idesc->id_name);
return STOP|ALTERED|FOUND;
} else
return STOP|FOUND; /* won't fit, so give up */
}
return KEEPON;
}
CMDFUNCSTART(chname)
{
int rval;
char *cp;
ino_t inum;
struct inodesc idesc;
slotcount = 0;
@ -598,7 +602,7 @@ CMDFUNCSTART(chname)
}
}
struct typemap {
static struct typemap {
const char *typename;
int typebits;
} typenamemap[] = {
@ -610,7 +614,6 @@ struct typemap {
CMDFUNCSTART(newtype)
{
int rval = 1;
int type;
struct typemap *tp;
@ -748,7 +751,7 @@ CMDFUNCSTART(chowner)
uid = strtoul(argv[1], &cp, 0);
if (cp == argv[1] || *cp != '\0' ) {
/* try looking up name */
if (pwd = getpwnam(argv[1])) {
if ((pwd = getpwnam(argv[1])) != 0) {
uid = pwd->pw_uid;
} else {
warnx("bad uid `%s'", argv[1]);
@ -774,7 +777,7 @@ CMDFUNCSTART(chgroup)
gid = strtoul(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;
} else {
warnx("bad gid `%s'", argv[1]);
@ -788,7 +791,7 @@ CMDFUNCSTART(chgroup)
return rval;
}
int
static int
dotime(name, rsec, rnsec)
char *name;
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.
@ -56,9 +56,9 @@ struct cmdtable {
extern struct dinode *curinode;
extern ino_t curinum;
int argcount __P((struct cmdtable *cmdp, int argc, char *argv[]));
char **crack __P((char *line, int *argc));
void printstat __P((const char *cp, ino_t inum, struct dinode *dp));
int printactive __P((void));
char **crack __P((char *, int *));
int argcount __P((struct cmdtable *, int, char *[]));
void printstat __P((const char *, ino_t, struct dinode *));
int checkactive __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.
@ -37,7 +37,7 @@
*/
#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 */
#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 <string.h>
#include <unistd.h>
#include <err.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
@ -138,7 +139,7 @@ printstat(cp, inum, dp)
puts("fifo");
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;
p = ctime(&t);
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],
dp->di_atimensec);
if (pw = getpwuid(dp->di_uid))
if ((pw = getpwuid(dp->di_uid)) != NULL)
printf("OWNER=%s ", pw->pw_name);
else
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);
else
printf("GID=%u ", dp->di_gid);