Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/fsck_lfs Convert to NetBSD source code style
details: https://anonhg.NetBSD.org/src/rev/a3b4fa1399f7
branches: trunk
changeset: 486474:a3b4fa1399f7
user: perseant <perseant%NetBSD.org@localhost>
date: Tue May 23 01:48:52 2000 +0000
description:
Convert to NetBSD source code style
diffstat:
sbin/fsck_lfs/dir.c | 243 ++++-----
sbin/fsck_lfs/extern.h | 100 ++--
sbin/fsck_lfs/fsck.h | 163 +++---
sbin/fsck_lfs/fsck_vars.h | 75 +-
sbin/fsck_lfs/inode.c | 1063 ++++++++++++++++++++++----------------------
sbin/fsck_lfs/main.c | 99 +--
sbin/fsck_lfs/pass0.c | 464 +++++++++---------
sbin/fsck_lfs/pass1.c | 175 +++---
sbin/fsck_lfs/pass2.c | 100 ++--
sbin/fsck_lfs/pass3.c | 10 +-
sbin/fsck_lfs/pass4.c | 19 +-
sbin/fsck_lfs/pass5.c | 56 +-
sbin/fsck_lfs/setup.c | 420 ++++++++--------
sbin/fsck_lfs/utilities.c | 191 +++----
sbin/fsck_lfs/vars.c | 89 +-
15 files changed, 1590 insertions(+), 1677 deletions(-)
diffs (truncated from 5078 to 300 lines):
diff -r a886a27b2a3c -r a3b4fa1399f7 sbin/fsck_lfs/dir.c
--- a/sbin/fsck_lfs/dir.c Tue May 23 01:03:05 2000 +0000
+++ b/sbin/fsck_lfs/dir.c Tue May 23 01:48:52 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.2 1999/07/03 19:55:03 kleink Exp $ */
+/* $NetBSD: dir.c,v 1.3 2000/05/23 01:48:52 perseant Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -37,7 +37,7 @@
#include <sys/time.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ufs/dir.h>
-#include <sys/mount.h> /* XXX */
+#include <sys/mount.h> /* XXX */
#include <ufs/lfs/lfs.h>
#include <stdio.h>
@@ -48,25 +48,25 @@
#include "fsutil.h"
#include "extern.h"
-char *lfname = "lost+found";
-int lfmode = 01700;
-struct dirtemplate emptydir = { 0, DIRBLKSIZ };
-struct dirtemplate dirhead = {
+char *lfname = "lost+found";
+int lfmode = 01700;
+struct dirtemplate emptydir = {0, DIRBLKSIZ};
+struct dirtemplate dirhead = {
0, 12, DT_DIR, 1, ".",
0, DIRBLKSIZ - 12, DT_DIR, 2, ".."
};
-struct odirtemplate odirhead = {
+struct odirtemplate odirhead = {
0, 12, 1, ".",
0, DIRBLKSIZ - 12, 2, ".."
};
-static int expanddir __P((struct dinode *, char *));
-static void freedir __P((ino_t, ino_t));
-static struct direct *fsck_readdir __P((struct inodesc *));
-static struct bufarea *getdirblk __P((daddr_t, long));
-static int lftempname __P((char *, ino_t));
-static int mkentry __P((struct inodesc *));
-static int chgino __P((struct inodesc *));
+static int expanddir(struct dinode *, char *);
+static void freedir(ino_t, ino_t);
+static struct direct *fsck_readdir(struct inodesc *);
+static struct bufarea *getdirblk(daddr_t, long);
+static int lftempname(char *, ino_t);
+static int mkentry(struct inodesc *);
+static int chgino(struct inodesc *);
/*
* Propagate connected state through the tree.
@@ -108,14 +108,13 @@
* Scan each entry in a directory block.
*/
int
-dirscan(idesc)
- register struct inodesc *idesc;
+dirscan(struct inodesc * idesc)
{
register struct direct *dp;
register struct bufarea *bp;
- int dsize, n;
- long blksiz;
- char dbuf[DIRBLKSIZ];
+ int dsize, n;
+ long blksiz;
+ char dbuf[DIRBLKSIZ];
if (idesc->id_type != DATA)
errexit("wrong type to dirscan %d\n", idesc->id_type);
@@ -133,8 +132,8 @@
memcpy(dbuf, dp, (size_t)dsize);
# if (BYTE_ORDER == LITTLE_ENDIAN)
if (!newinofmt) {
- struct direct *tdp = (struct direct *)dbuf;
- u_char tmp;
+ struct direct *tdp = (struct direct *)dbuf;
+ u_char tmp;
tmp = tdp->d_namlen;
tdp->d_namlen = tdp->d_type;
@@ -145,8 +144,8 @@
if ((n = (*idesc->id_func)(idesc)) & ALTERED) {
# if (BYTE_ORDER == LITTLE_ENDIAN)
if (!newinofmt && !doinglevel2) {
- struct direct *tdp;
- u_char tmp;
+ struct direct *tdp;
+ u_char tmp;
tdp = (struct direct *)dbuf;
tmp = tdp->d_namlen;
@@ -156,11 +155,11 @@
# endif
bp = getdirblk(idesc->id_blkno, blksiz);
memcpy(bp->b_un.b_buf + idesc->id_loc - dsize, dbuf,
- (size_t)dsize);
+ (size_t)dsize);
dirty(bp);
sbdirty();
}
- if (n & STOP)
+ if (n & STOP)
return (n);
}
return (idesc->id_filesize > 0 ? KEEPON : STOP);
@@ -170,12 +169,11 @@
* get next entry in a directory.
*/
static struct direct *
-fsck_readdir(idesc)
- register struct inodesc *idesc;
+fsck_readdir(struct inodesc * idesc)
{
register struct direct *dp, *ndp;
register struct bufarea *bp;
- long size, blksiz, fix, dploc;
+ long size, blksiz, fix, dploc;
blksiz = idesc->id_numfrags * sblock.lfs_fsize;
bp = getdirblk(idesc->id_blkno, blksiz);
@@ -232,27 +230,24 @@
* This is a superset of the checks made in the kernel.
*/
int
-dircheck(idesc, dp)
- struct inodesc *idesc;
- register struct direct *dp;
+dircheck(struct inodesc * idesc, struct direct * dp)
{
- register int size;
- register char *cp;
- u_char namlen, type;
- int spaceleft;
+ register int size;
+ register char *cp;
+ u_char namlen, type;
+ int spaceleft;
spaceleft = DIRBLKSIZ - (idesc->id_loc % DIRBLKSIZ);
if (dp->d_ino >= maxino ||
dp->d_reclen == 0 ||
dp->d_reclen > spaceleft ||
- (dp->d_reclen & 0x3) != 0)
- {
- pwarn("ino too large, reclen=0, reclen>space, or reclen&3!=0\n");
- pwarn("dp->d_ino = 0x%x\tdp->d_reclen = 0x%x\n",
- dp->d_ino, dp->d_reclen);
- pwarn("maxino = 0x%x\tspaceleft = 0x%x\n", maxino, spaceleft);
- return (0);
- }
+ (dp->d_reclen & 0x3) != 0) {
+ pwarn("ino too large, reclen=0, reclen>space, or reclen&3!=0\n");
+ pwarn("dp->d_ino = 0x%x\tdp->d_reclen = 0x%x\n",
+ dp->d_ino, dp->d_reclen);
+ pwarn("maxino = 0x%x\tspaceleft = 0x%x\n", maxino, spaceleft);
+ return (0);
+ }
if (dp->d_ino == 0)
return (1);
size = DIRSIZ(!newinofmt, dp, 0);
@@ -271,39 +266,34 @@
if (dp->d_reclen < size ||
idesc->id_filesize < size ||
namlen > MAXNAMLEN ||
- type > 15)
- {
- printf("reclen<size, filesize<size, namlen too large, or type>15\n");
+ type > 15) {
+ printf("reclen<size, filesize<size, namlen too large, or type>15\n");
return (0);
- }
+ }
for (cp = dp->d_name, size = 0; size < namlen; size++)
if (*cp == '\0' || (*cp++ == '/')) {
- printf("name contains NUL or /\n");
+ printf("name contains NUL or /\n");
return (0);
- }
+ }
if (*cp != '\0') {
- printf("name size misstated\n");
+ printf("name size misstated\n");
return (0);
- }
+ }
return (1);
}
void
-direrror(ino, errmesg)
- ino_t ino;
- char *errmesg;
+direrror(ino_t ino, char *errmesg)
{
fileerror(ino, ino, errmesg);
}
void
-fileerror(cwd, ino, errmesg)
- ino_t cwd, ino;
- char *errmesg;
+fileerror(ino_t cwd, ino_t ino, char *errmesg)
{
register struct dinode *dp;
- char pathbuf[MAXPATHLEN + 1];
+ char pathbuf[MAXPATHLEN + 1];
pwarn("%s ", errmesg);
pinode(ino);
@@ -314,21 +304,19 @@
return;
}
dp = ginode(ino);
- if(dp==NULL)
- pfatal("INO is NULL\n");
- else {
- if (ftypeok(dp))
- pfatal("%s=%s\n",
- (dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE", pathbuf);
- else
- pfatal("NAME=%s\n", pathbuf);
- }
+ if (dp == NULL)
+ pfatal("INO is NULL\n");
+ else {
+ if (ftypeok(dp))
+ pfatal("%s=%s\n",
+ (dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE", pathbuf);
+ else
+ pfatal("NAME=%s\n", pathbuf);
+ }
}
void
-adjust(idesc, lcnt)
- register struct inodesc *idesc;
- short lcnt;
+adjust(struct inodesc * idesc, short lcnt)
{
register struct dinode *dp;
@@ -338,10 +326,10 @@
clri(idesc, "UNREF", 0);
} else {
pwarn("LINK COUNT %s", (lfdir == idesc->id_number) ? lfname :
- ((dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE"));
+ ((dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE"));
pinode(idesc->id_number);
printf(" COUNT %d SHOULD BE %d",
- dp->di_nlink, dp->di_nlink - lcnt);
+ dp->di_nlink, dp->di_nlink - lcnt);
if (preen) {
if (lcnt < 0) {
printf("\n");
@@ -357,12 +345,11 @@
}
static int
-mkentry(idesc)
- struct inodesc *idesc;
+mkentry(struct inodesc * idesc)
{
register struct direct *dirp = idesc->id_dirp;
- struct direct newent;
- int newlen, oldlen;
+ struct direct newent;
+ int newlen, oldlen;
newent.d_namlen = strlen(idesc->id_name);
newlen = DIRSIZ(0, &newent, 0);
@@ -385,25 +372,24 @@
memcpy(dirp->d_name, idesc->id_name, (size_t)dirp->d_namlen + 1);
# if (BYTE_ORDER == LITTLE_ENDIAN)
/*
- * If the entry was split, dirscan() will only reverse the byte
- * order of the original entry, and not the new one, before
- * writing it back out. So, we reverse the byte order here if
- * necessary.
- */
+ * If the entry was split, dirscan()will only reverse the byte
+ * order of the original entry, and not the new one, before
+ * writing it back out. So, we reverse the byte order here if
+ * necessary.
+ */
if (oldlen != 0 && !newinofmt && !doinglevel2) {
- u_char tmp;
+ u_char tmp;
tmp = dirp->d_namlen;
dirp->d_namlen = dirp->d_type;
dirp->d_type = tmp;
}
# endif
Home |
Main Index |
Thread Index |
Old Index