* KNF-ify

* prefix hex numbers with '0x'
This commit is contained in:
lukem 1997-09-14 14:56:57 +00:00
parent 332c413b75
commit 66a64254b8
3 changed files with 676 additions and 676 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: fsdb.8,v 1.6 1997/07/31 00:21:53 jtc Exp $
.\" $NetBSD: fsdb.8,v 1.7 1997/09/14 14:56:57 lukem Exp $
.\"
.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -51,7 +51,7 @@ opens
(usually a raw disk partition) and runs a command loop
allowing manipulation of the file system's inode data. You are prompted
to enter a command with
.Ic "fsdb (inum X)>"
.Dq "fsdb (inum X)>"
where
.Va X
is the currently selected i-number. The initial selected inode is the
@ -227,7 +227,7 @@ to implement most of the file system manipulation code. The remainder of
first appeared in
.Nx 1.1 .
.Sh WARNING
Use this tool with extreme caution--you can damage an FFS file system
Use this tool with extreme caution -- you can damage an FFS file system
beyond what
.Xr fsck 8
can repair.

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* $NetBSD: fsdbutil.c,v 1.6 1997/07/31 00:21:59 jtc Exp $ */
/* $NetBSD: fsdbutil.c,v 1.7 1997/09/14 14:56:59 lukem Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -36,8 +36,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
static char rcsid[] = "$NetBSD: fsdbutil.c,v 1.6 1997/07/31 00:21:59 jtc Exp $";
__RCSID("$NetBSD: fsdbutil.c,v 1.7 1997/09/14 14:56:59 lukem Exp $");
#endif /* not lint */
#include <sys/types.h>
@ -61,157 +62,159 @@ static char rcsid[] = "$NetBSD: fsdbutil.c,v 1.6 1997/07/31 00:21:59 jtc Exp $";
#include "fsdb.h"
#include "fsck.h"
char **
char **
crack(line, argc)
char *line;
int *argc;
char *line;
int *argc;
{
static char *argv[8];
int i;
char *p, *val;
for (p = line, i = 0; p != NULL && i < 8; i++) {
while ((val = strsep(&p, " \t\n")) != NULL && *val == '\0')
/**/;
if (val)
argv[i] = val;
else
break;
}
*argc = i;
return argv;
static char *argv[8];
int i;
char *p, *val;
for (p = line, i = 0; p != NULL && i < 8; i++) {
while ((val = strsep(&p, " \t\n")) != NULL && *val == '\0')
/**/ ;
if (val)
argv[i] = val;
else
break;
}
*argc = i;
return argv;
}
int
argcount(cmdp, argc, argv)
struct cmdtable *cmdp;
int argc;
char *argv[];
int argc;
char *argv[];
{
if (cmdp->minargc == cmdp->maxargc)
warnx("command `%s' takes %u arguments", cmdp->cmd, cmdp->minargc-1);
else
warnx("command `%s' takes from %u to %u arguments",
cmdp->cmd, cmdp->minargc-1, cmdp->maxargc-1);
warnx("usage: %s: %s", cmdp->cmd, cmdp->helptxt);
return 1;
if (cmdp->minargc == cmdp->maxargc)
warnx("command `%s' takes %u arguments", cmdp->cmd,
cmdp->minargc - 1);
else
warnx("command `%s' takes from %u to %u arguments",
cmdp->cmd, cmdp->minargc - 1, cmdp->maxargc - 1);
warnx("usage: %s: %s", cmdp->cmd, cmdp->helptxt);
return 1;
}
void
printstat(cp, inum, dp)
const char *cp;
ino_t inum;
ino_t inum;
struct dinode *dp;
{
struct group *grp;
struct passwd *pw;
time_t t;
char *p;
struct group *grp;
struct passwd *pw;
time_t t;
char *p;
printf("%s: ", cp);
switch (dp->di_mode & IFMT) {
case IFDIR:
puts("directory");
break;
case IFREG:
puts("regular file");
break;
case IFBLK:
printf("block special (%d,%d)",
major(dp->di_rdev), minor(dp->di_rdev));
break;
case IFCHR:
printf("character special (%d,%d)",
major(dp->di_rdev), minor(dp->di_rdev));
break;
case IFLNK:
fputs("symlink",stdout);
if (dp->di_size > 0 && dp->di_size < MAXSYMLINKLEN &&
dp->di_blocks == 0)
printf(" to `%.*s'\n", (int) dp->di_size, (char *)dp->di_shortlink);
printf("%s: ", cp);
switch (dp->di_mode & IFMT) {
case IFDIR:
puts("directory");
break;
case IFREG:
puts("regular file");
break;
case IFBLK:
printf("block special (%d,%d)",
major(dp->di_rdev), minor(dp->di_rdev));
break;
case IFCHR:
printf("character special (%d,%d)",
major(dp->di_rdev), minor(dp->di_rdev));
break;
case IFLNK:
fputs("symlink", stdout);
if (dp->di_size > 0 && dp->di_size < MAXSYMLINKLEN &&
dp->di_blocks == 0)
printf(" to `%.*s'\n", (int)dp->di_size,
(char *)dp->di_shortlink);
else
putchar('\n');
break;
case IFSOCK:
puts("socket");
break;
case IFIFO:
puts("fifo");
break;
}
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],
dp->di_mtimensec);
t = dp->di_ctime;
p = ctime(&t);
printf("\n\tCTIME=%15.15s %4.4s [%d nsec]", &p[4], &p[20],
dp->di_ctimensec);
t = dp->di_atime;
p = ctime(&t);
printf("\n\tATIME=%15.15s %4.4s [%d nsec]\n", &p[4], &p[20],
dp->di_atimensec);
if ((pw = getpwuid(dp->di_uid)) != NULL)
printf("OWNER=%s ", pw->pw_name);
else
putchar('\n');
break;
case IFSOCK:
puts("socket");
break;
case IFIFO:
puts("fifo");
break;
}
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],
dp->di_mtimensec);
t = dp->di_ctime;
p = ctime(&t);
printf("\n\tCTIME=%15.15s %4.4s [%d nsec]", &p[4], &p[20],
dp->di_ctimensec);
t = dp->di_atime;
p = ctime(&t);
printf("\n\tATIME=%15.15s %4.4s [%d nsec]\n", &p[4], &p[20],
dp->di_atimensec);
printf("OWNUID=%u ", dp->di_uid);
if ((grp = getgrgid(dp->di_gid)) != NULL)
printf("GRP=%s ", grp->gr_name);
else
printf("GID=%u ", dp->di_gid);
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)) != NULL)
printf("GRP=%s ", grp->gr_name);
else
printf("GID=%u ", dp->di_gid);
printf("LINKCNT=%hd FLAGS=%#x BLKCNT=%x GEN=%x\n", dp->di_nlink, dp->di_flags,
dp->di_blocks, dp->di_gen);
printf("LINKCNT=%hd FLAGS=0x%#x BLKCNT=0x%x GEN=0x%x\n", dp->di_nlink,
dp->di_flags, dp->di_blocks, dp->di_gen);
}
int
checkactive()
{
if (!curinode) {
warnx("no current inode\n");
return 0;
}
return 1;
if (!curinode) {
warnx("no current inode\n");
return 0;
}
return 1;
}
int
checkactivedir()
{
if (!curinode) {
warnx("no current inode\n");
return 0;
}
if ((curinode->di_mode & IFMT) != IFDIR) {
warnx("inode %d not a directory", curinum);
return 0;
}
return 1;
if (!curinode) {
warnx("no current inode\n");
return 0;
}
if ((curinode->di_mode & IFMT) != IFDIR) {
warnx("inode %d not a directory", curinum);
return 0;
}
return 1;
}
int
printactive()
{
if (!checkactive())
return 1;
switch (curinode->di_mode & IFMT) {
case IFDIR:
case IFREG:
case IFBLK:
case IFCHR:
case IFLNK:
case IFSOCK:
case IFIFO:
printstat("current inode", curinum, curinode);
break;
case 0:
printf("current inode %d: unallocated inode\n", curinum);
break;
default:
printf("current inode %d: screwy itype 0%o (mode 0%o)?\n",
curinum, curinode->di_mode & IFMT, curinode->di_mode);
break;
}
return 0;
if (!checkactive())
return 1;
switch (curinode->di_mode & IFMT) {
case IFDIR:
case IFREG:
case IFBLK:
case IFCHR:
case IFLNK:
case IFSOCK:
case IFIFO:
printstat("current inode", curinum, curinode);
break;
case 0:
printf("current inode %d: unallocated inode\n", curinum);
break;
default:
printf("current inode %d: screwy itype 0%o (mode 0%o)?\n",
curinum, curinode->di_mode & IFMT, curinode->di_mode);
break;
}
return 0;
}