summaryrefslogtreecommitdiff
path: root/sbin/fsdb/fsdbutil.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-06-11 06:22:16 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-06-11 06:22:16 +0000
commit4e11c004395b80e095e2512274ee143f75b923f2 (patch)
tree7dd90385c7fc68e56457d473631e3db8896270d2 /sbin/fsdb/fsdbutil.c
parent5dd7b59250a41ff74475db0fc6290dc6b029d96d (diff)
ansification
Diffstat (limited to 'sbin/fsdb/fsdbutil.c')
-rw-r--r--sbin/fsdb/fsdbutil.c258
1 files changed, 126 insertions, 132 deletions
diff --git a/sbin/fsdb/fsdbutil.c b/sbin/fsdb/fsdbutil.c
index 592b61a5977..2212df43368 100644
--- a/sbin/fsdb/fsdbutil.c
+++ b/sbin/fsdb/fsdbutil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fsdbutil.c,v 1.8 2002/06/09 08:13:06 todd Exp $ */
+/* $OpenBSD: fsdbutil.c,v 1.9 2003/06/11 06:22:13 deraadt Exp $ */
/* $NetBSD: fsdbutil.c,v 1.5 1996/09/28 19:30:37 christos Exp $ */
/*-
@@ -38,7 +38,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: fsdbutil.c,v 1.8 2002/06/09 08:13:06 todd Exp $";
+static char rcsid[] = "$OpenBSD: fsdbutil.c,v 1.9 2003/06/11 06:22:13 deraadt Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -63,156 +63,150 @@ static char rcsid[] = "$OpenBSD: fsdbutil.c,v 1.8 2002/06/09 08:13:06 todd Exp $
#include "fsck.h"
char **
-crack(line, argc)
- char *line;
- int *argc;
+crack(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[];
+argcount(struct cmdtable *cmdp, 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;
- struct dinode *dp;
+printstat(const char *cp, ino_t inum, struct dinode *dp)
{
- 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);
+ 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);
+ else
+ putchar('\n');
+ break;
+ case IFSOCK:
+ puts("socket");
+ break;
+ case IFIFO:
+ puts("fifo");
+ break;
+ }
+
+ printf("I=%u MODE=%o SIZE=%llu", 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)))
+ printf("OWNER=%s ", pw->pw_name);
+ else
+ printf("OWNUID=%u ", dp->di_uid);
+ if ((grp = getgrgid(dp->di_gid)))
+ printf("GRP=%s ", grp->gr_name);
else
- putchar('\n');
- break;
- case IFSOCK:
- puts("socket");
- break;
- case IFIFO:
- puts("fifo");
- break;
- }
- printf("I=%u MODE=%o SIZE=%llu", 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)))
- printf("OWNER=%s ", pw->pw_name);
- else
- printf("OWNUID=%u ", dp->di_uid);
- if ((grp = getgrgid(dp->di_gid)))
- 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("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);
}
int
-checkactive()
+checkactive(void)
{
- if (!curinode) {
- warnx("no current inode");
- return 0;
- }
- return 1;
+ if (!curinode) {
+ warnx("no current inode");
+ return 0;
+ }
+ return 1;
}
int
-checkactivedir()
+checkactivedir(void)
{
- if (!curinode) {
- warnx("no current inode");
- 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");
+ return 0;
+ }
+ if ((curinode->di_mode & IFMT) != IFDIR) {
+ warnx("inode %d not a directory", curinum);
+ return 0;
+ }
+ return 1;
}
int
-printactive()
+printactive(void)
{
- 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;
}