diff options
Diffstat (limited to 'sbin/fsck_ffs')
-rw-r--r-- | sbin/fsck_ffs/dir.c | 71 | ||||
-rw-r--r-- | sbin/fsck_ffs/inode.c | 88 | ||||
-rw-r--r-- | sbin/fsck_ffs/main.c | 27 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass1.c | 24 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass1b.c | 15 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass2.c | 28 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass3.c | 10 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass4.c | 15 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass5.c | 10 | ||||
-rw-r--r-- | sbin/fsck_ffs/setup.c | 37 | ||||
-rw-r--r-- | sbin/fsck_ffs/utilities.c | 76 |
11 files changed, 137 insertions, 264 deletions
diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c index bdb8ba7cabf..7788c9a1bb9 100644 --- a/sbin/fsck_ffs/dir.c +++ b/sbin/fsck_ffs/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.12 2002/06/09 08:13:05 todd Exp $ */ +/* $OpenBSD: dir.c,v 1.13 2002/08/23 09:09:04 gluk Exp $ */ /* $NetBSD: dir.c,v 1.20 1996/09/27 22:45:11 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)dir.c 8.5 (Berkeley) 12/8/94"; #else -static char rcsid[] = "$OpenBSD: dir.c,v 1.12 2002/06/09 08:13:05 todd Exp $"; +static const char rcsid[] = "$OpenBSD: dir.c,v 1.13 2002/08/23 09:09:04 gluk Exp $"; #endif #endif /* not lint */ @@ -80,8 +80,7 @@ static int chgino(struct inodesc *); * Propagate connected state through the tree. */ void -propagate(inumber) - ino_t inumber; +propagate(ino_t inumber) { struct inoinfo *inp; char state; @@ -106,8 +105,7 @@ propagate(inumber) * Scan each entry in a directory block. */ int -dirscan(idesc) - struct inodesc *idesc; +dirscan(struct inodesc *idesc) { struct direct *dp; struct bufarea *bp; @@ -168,8 +166,7 @@ dirscan(idesc) * get next entry in a directory. */ static struct direct * -fsck_readdir(idesc) - struct inodesc *idesc; +fsck_readdir(struct inodesc *idesc) { struct direct *dp, *ndp; struct bufarea *bp; @@ -230,9 +227,7 @@ dpok: * This is a superset of the checks made in the kernel. */ int -dircheck(idesc, dp) - struct inodesc *idesc; - struct direct *dp; +dircheck(struct inodesc *idesc, struct direct *dp) { int size; char *cp; @@ -274,18 +269,13 @@ dircheck(idesc, dp) } 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) { struct dinode *dp; char pathbuf[MAXPATHLEN + 1]; @@ -307,15 +297,13 @@ fileerror(cwd, ino, errmesg) } void -adjust(idesc, lcnt) - struct inodesc *idesc; - short lcnt; +adjust(struct inodesc *idesc, short lcnt) { struct dinode *dp; dp = ginode(idesc->id_number); if (dp->di_nlink == lcnt) { - if (linkup(idesc->id_number, (ino_t)0) == 0) + if (linkup(idesc->id_number, 0) == 0) clri(idesc, "UNREF", 0); } else { pwarn("LINK COUNT %s", (lfdir == idesc->id_number) ? lfname : @@ -339,8 +327,7 @@ adjust(idesc, lcnt) } static int -mkentry(idesc) - struct inodesc *idesc; +mkentry(struct inodesc *idesc) { struct direct *dirp = idesc->id_dirp; struct direct newent; @@ -384,8 +371,7 @@ mkentry(idesc) } static int -chgino(idesc) - struct inodesc *idesc; +chgino(struct inodesc *idesc) { struct direct *dirp = idesc->id_dirp; @@ -400,9 +386,7 @@ chgino(idesc) } int -linkup(orphan, parentdir) - ino_t orphan; - ino_t parentdir; +linkup(ino_t orphan, ino_t parentdir) { struct dinode *dp; int lostdir; @@ -433,7 +417,7 @@ linkup(orphan, parentdir) } else { pwarn("NO lost+found DIRECTORY"); if (preen || reply("CREATE")) { - lfdir = allocdir(ROOTINO, (ino_t)0, lfmode); + lfdir = allocdir(ROOTINO, 0, lfmode); if (lfdir != 0) { if (makeentry(ROOTINO, lfdir, lfname) != 0) { if (preen) @@ -459,7 +443,7 @@ linkup(orphan, parentdir) if (reply("REALLOCATE") == 0) return (0); oldlfdir = lfdir; - if ((lfdir = allocdir(ROOTINO, (ino_t)0, lfmode)) == 0) { + if ((lfdir = allocdir(ROOTINO, 0, lfmode)) == 0) { pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY\n\n"); return (0); } @@ -537,14 +521,12 @@ changeino(dir, name, newnum) * make an entry in a directory */ int -makeentry(parent, ino, name) - ino_t parent, ino; - char *name; +makeentry(ino_t parent, ino_t ino, char *name) { struct dinode *dp; struct inodesc idesc; char pathbuf[MAXPATHLEN + 1]; - + if (parent < ROOTINO || parent >= maxino || ino < ROOTINO || ino >= maxino) return (0); @@ -573,9 +555,7 @@ makeentry(parent, ino, name) * Attempt to expand the size of a directory */ static int -expanddir(dp, name) - struct dinode *dp; - char *name; +expanddir(struct dinode *dp, char *name) { daddr_t lastbn, newblk; struct bufarea *bp; @@ -630,9 +610,7 @@ bad: * allocate a new directory */ int -allocdir(parent, request, mode) - ino_t parent, request; - int mode; +allocdir(ino_t parent, ino_t request, int mode) { ino_t ino; char *cp; @@ -690,8 +668,7 @@ allocdir(parent, request, mode) * free a directory inode */ static void -freedir(ino, parent) - ino_t ino, parent; +freedir(ino_t ino, ino_t parent) { struct dinode *dp; @@ -707,9 +684,7 @@ freedir(ino, parent) * generate a temporary name for the lost+found directory. */ static int -lftempname(bufp, ino) - char *bufp; - ino_t ino; +lftempname(char *bufp, ino_t ino) { ino_t in; char *cp; @@ -734,9 +709,7 @@ lftempname(bufp, ino) * Insure that it is held until another is requested. */ static struct bufarea * -getdirblk(blkno, size) - daddr_t blkno; - long size; +getdirblk(daddr_t blkno, long size) { if (pdirbp != 0) diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c index 0e6f211f6a1..77fd1615f77 100644 --- a/sbin/fsck_ffs/inode.c +++ b/sbin/fsck_ffs/inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inode.c,v 1.20 2002/05/22 08:21:02 deraadt Exp $ */ +/* $OpenBSD: inode.c,v 1.21 2002/08/23 09:09:04 gluk Exp $ */ /* $NetBSD: inode.c,v 1.23 1996/10/11 20:15:47 thorpej Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)inode.c 8.5 (Berkeley) 2/8/95"; #else -static char rcsid[] = "$OpenBSD: inode.c,v 1.20 2002/05/22 08:21:02 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: inode.c,v 1.21 2002/08/23 09:09:04 gluk Exp $"; #endif #endif /* not lint */ @@ -63,9 +63,7 @@ static ino_t startinum; static int iblock(struct inodesc *, long, u_int64_t); int -ckinode(dp, idesc) - struct dinode *dp; - struct inodesc *idesc; +ckinode(struct dinode *dp, struct inodesc *idesc) { ufs_daddr_t *ap; long ret, n, ndb, offset; @@ -153,10 +151,7 @@ ckinode(dp, idesc) } static int -iblock(idesc, ilevel, isize) - struct inodesc *idesc; - long ilevel; - u_int64_t isize; +iblock(struct inodesc *idesc, long ilevel, u_int64_t isize) { daddr_t *ap; daddr_t *aplim; @@ -241,9 +236,7 @@ iblock(idesc, ilevel, isize) * Return 0 if in range, 1 if out of range. */ int -chkrange(blk, cnt) - daddr_t blk; - int cnt; +chkrange(daddr_t blk, int cnt) { int c; @@ -278,8 +271,7 @@ chkrange(blk, cnt) * General purpose interface for reading inodes. */ struct dinode * -ginode(inumber) - ino_t inumber; +ginode(ino_t inumber) { daddr_t iblk; @@ -305,8 +297,7 @@ long readcnt, readpercg, fullcnt, inobufsize, partialcnt, partialsize; struct dinode *inodebuf; struct dinode * -getnextinode(inumber) - ino_t inumber; +getnextinode(ino_t inumber) { long size; daddr_t dblk; @@ -331,7 +322,7 @@ getnextinode(inumber) } void -resetinodebuf() +resetinodebuf(void) { startinum = 0; @@ -350,18 +341,18 @@ resetinodebuf() partialsize = inobufsize; } if (inodebuf == NULL && - (inodebuf = (struct dinode *)malloc((unsigned)inobufsize)) == NULL) + (inodebuf = malloc((unsigned)inobufsize)) == NULL) errexit("Cannot allocate space for inode buffer\n"); while (nextino < ROOTINO) (void)getnextinode(nextino); } void -freeinodebuf() +freeinodebuf(void) { if (inodebuf != NULL) - free((char *)inodebuf); + free(inodebuf); inodebuf = NULL; } @@ -373,9 +364,7 @@ freeinodebuf() * Enter inodes into the cache. */ void -cacheino(dp, inumber) - struct dinode *dp; - ino_t inumber; +cacheino(struct dinode *dp, ino_t inumber) { struct inoinfo *inp; struct inoinfo **inpp; @@ -384,8 +373,7 @@ cacheino(dp, inumber) blks = howmany(dp->di_size, sblock.fs_bsize); if (blks > NDADDR) blks = NDADDR + NIADDR; - inp = (struct inoinfo *) - malloc(sizeof(*inp) + (blks ? blks - 1 : 0) * sizeof(daddr_t)); + inp = malloc(sizeof(*inp) + (blks ? blks - 1 : 0) * sizeof(daddr_t)); if (inp == NULL) errexit("cannot allocate memory for inode cache"); inpp = &inphead[inumber % numdirs]; @@ -395,15 +383,15 @@ cacheino(dp, inumber) if (inumber == ROOTINO) inp->i_parent = ROOTINO; else - inp->i_parent = (ino_t)0; - inp->i_dotdot = (ino_t)0; + inp->i_parent = 0; + inp->i_dotdot = 0; inp->i_number = inumber; inp->i_isize = dp->di_size; inp->i_numblks = blks * sizeof(daddr_t); memcpy(&inp->i_blks[0], &dp->di_db[0], (size_t)inp->i_numblks); if (inplast == listmax) { listmax += 100; - inpsort = (struct inoinfo **)realloc((char *)inpsort, + inpsort = realloc(inpsort, (unsigned)listmax * sizeof(struct inoinfo *)); if (inpsort == NULL) errexit("cannot increase directory list"); @@ -415,8 +403,7 @@ cacheino(dp, inumber) * Look up an inode cache structure. */ struct inoinfo * -getinoinfo(inumber) - ino_t inumber; +getinoinfo(ino_t inumber) { struct inoinfo *inp; @@ -433,31 +420,27 @@ getinoinfo(inumber) * Clean up all the inode cache structure. */ void -inocleanup() +inocleanup(void) { struct inoinfo **inpp; if (inphead == NULL) return; for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--) - free((char *)(*inpp)); - free((char *)inphead); - free((char *)inpsort); + free(*inpp); + free(inphead); + free(inpsort); inphead = inpsort = NULL; } - + void -inodirty() +inodirty(void) { - dirty(pbp); } void -clri(idesc, type, flag) - struct inodesc *idesc; - char *type; - int flag; +clri(struct inodesc *idesc, char *type, int flag) { struct dinode *dp; @@ -479,8 +462,7 @@ clri(idesc, type, flag) } int -findname(idesc) - struct inodesc *idesc; +findname(struct inodesc *idesc) { struct direct *dirp = idesc->id_dirp; @@ -491,8 +473,7 @@ findname(idesc) } int -findino(idesc) - struct inodesc *idesc; +findino(struct inodesc *idesc) { struct direct *dirp = idesc->id_dirp; @@ -507,8 +488,7 @@ findino(idesc) } void -pinode(ino) - ino_t ino; +pinode(ino_t ino) { struct dinode *dp; char *p; @@ -536,10 +516,7 @@ pinode(ino) } void -blkerror(ino, type, blk) - ino_t ino; - char *type; - daddr_t blk; +blkerror(ino_t ino, char *type, daddr_t blk) { pfatal("%d %s I=%u", blk, type, ino); @@ -568,9 +545,7 @@ blkerror(ino, type, blk) * allocate an unused inode */ ino_t -allocino(request, type) - ino_t request; - int type; +allocino(ino_t request, int type) { ino_t ino; struct dinode *dp; @@ -608,7 +583,7 @@ allocino(request, type) } cgdirty(); dp = ginode(ino); - dp->di_db[0] = allocblk((long)1); + dp->di_db[0] = allocblk(1); if (dp->di_db[0] == 0) { statemap[ino] = USTATE; return (0); @@ -631,8 +606,7 @@ allocino(request, type) * deallocate an inode */ void -freeino(ino) - ino_t ino; +freeino(ino_t ino) { struct inodesc idesc; struct dinode *dp; diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index bd9d210cb35..f69072c9d32 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.23 2002/08/20 21:57:56 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.24 2002/08/23 09:09:04 gluk Exp $ */ /* $NetBSD: main.c,v 1.22 1996/10/11 20:15:48 thorpej Exp $ */ /* @@ -35,7 +35,7 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1980, 1986, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94"; #else -static char rcsid[] = "$OpenBSD: main.c,v 1.23 2002/08/20 21:57:56 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: main.c,v 1.24 2002/08/23 09:09:04 gluk Exp $"; #endif #endif /* not lint */ @@ -74,9 +74,7 @@ int main(int, char *[]); extern char *__progname; int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { int ch; int ret = 0; @@ -99,7 +97,7 @@ main(argc, argv) skipclean = 0; cvtlevel = argtoi('c', "conversion level", optarg, 10); break; - + case 'd': debug++; break; @@ -150,10 +148,7 @@ main(argc, argv) } int -argtoi(flag, req, str, base) - int flag; - char *req, *str; - int base; +argtoi(int flag, char *req, char *str, int base) { char *cp; int ret; @@ -168,8 +163,7 @@ argtoi(flag, req, str, base) * Determine whether a filesystem should be checked. */ int -docheck(fsp) - struct fstab *fsp; +docheck(struct fstab *fsp) { if ((strcmp(fsp->fs_vfstype, "ufs") && @@ -186,10 +180,7 @@ docheck(fsp) */ /* ARGSUSED */ int -checkfilesys(filesys, mntpt, auxdata, child) - char *filesys, *mntpt; - long auxdata; - int child; +checkfilesys(char *filesys, char *mntpt, long auxdata, int child) { daddr_t n_ffree, n_bfree; struct dups *dp; @@ -321,7 +312,7 @@ checkfilesys(filesys, mntpt, auxdata, child) blockmap = NULL; free(statemap); statemap = NULL; - free((char *)lncntp); + free(lncntp); lncntp = NULL; if (!fsmodified) return (0); diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c index 0f8802abeed..9ee98da560b 100644 --- a/sbin/fsck_ffs/pass1.c +++ b/sbin/fsck_ffs/pass1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass1.c,v 1.11 2002/02/16 21:27:34 millert Exp $ */ +/* $OpenBSD: pass1.c,v 1.12 2002/08/23 09:09:04 gluk Exp $ */ /* $NetBSD: pass1.c,v 1.16 1996/09/27 22:45:15 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)pass1.c 8.1 (Berkeley) 6/5/93"; #else -static char rcsid[] = "$OpenBSD: pass1.c,v 1.11 2002/02/16 21:27:34 millert Exp $"; +static const char rcsid[] = "$OpenBSD: pass1.c,v 1.12 2002/08/23 09:09:04 gluk Exp $"; #endif #endif /* not lint */ @@ -63,16 +63,14 @@ static void checkinode(ino_t, struct inodesc *); static ino_t info_inumber; static int -pass1_info(buf, buflen) - char * buf; - int buflen; +pass1_info(char *buf, int buflen) { return snprintf(buf, buflen, "phase 1, inode %d/%d", info_inumber, sblock.fs_ipg * sblock.fs_ncg); } void -pass1() +pass1(void) { struct inodesc idesc; ino_t inumber; @@ -118,9 +116,7 @@ pass1() } static void -checkinode(inumber, idesc) - ino_t inumber; - struct inodesc *idesc; +checkinode(ino_t inumber, struct inodesc *idesc) { struct dinode *dp; struct zlncnt *zlnp; @@ -228,7 +224,7 @@ checkinode(inumber, idesc) n_files++; lncntp[inumber] = dp->di_nlink; if (dp->di_nlink <= 0) { - zlnp = (struct zlncnt *)malloc(sizeof *zlnp); + zlnp = malloc(sizeof *zlnp); if (zlnp == NULL) { pfatal("LINK COUNT TABLE OVERFLOW"); if (reply("CONTINUE") == 0) { @@ -250,8 +246,7 @@ checkinode(inumber, idesc) } else statemap[inumber] = FSTATE; typemap[inumber] = IFTODT(mode); - if (doinglevel2 && - (dp->di_ouid != (u_short)-1 || dp->di_ogid != (u_short)-1)) { + if (doinglevel2 && (dp->di_ouid != (u_short)-1 || dp->di_ogid != (u_short)-1)) { dp = ginode(inumber); dp->di_uid = dp->di_ouid; dp->di_ouid = -1; @@ -287,8 +282,7 @@ unknown: } int -pass1check(idesc) - struct inodesc *idesc; +pass1check(struct inodesc *idesc) { int res = KEEPON; int anyout, nfrags; @@ -329,7 +323,7 @@ pass1check(idesc) } return (STOP); } - new = (struct dups *)malloc(sizeof(struct dups)); + new = malloc(sizeof(struct dups)); if (new == NULL) { pfatal("DUP TABLE OVERFLOW."); if (reply("CONTINUE") == 0) { diff --git a/sbin/fsck_ffs/pass1b.c b/sbin/fsck_ffs/pass1b.c index 5586c60dca5..849904fab18 100644 --- a/sbin/fsck_ffs/pass1b.c +++ b/sbin/fsck_ffs/pass1b.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass1b.c,v 1.6 2002/02/16 21:27:34 millert Exp $ */ +/* $OpenBSD: pass1b.c,v 1.7 2002/08/23 09:09:04 gluk Exp $ */ /* $NetBSD: pass1b.c,v 1.10 1996/09/23 16:18:37 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)pass1b.c 8.1 (Berkeley) 6/5/93"; #else -static char rcsid[] = "$OpenBSD: pass1b.c,v 1.6 2002/02/16 21:27:34 millert Exp $"; +static const char rcsid[] = "$OpenBSD: pass1b.c,v 1.7 2002/08/23 09:09:04 gluk Exp $"; #endif #endif /* not lint */ @@ -53,21 +53,19 @@ static char rcsid[] = "$OpenBSD: pass1b.c,v 1.6 2002/02/16 21:27:34 millert Exp #include "extern.h" static int pass1bcheck(struct inodesc *); -static struct dups *duphead; +static struct dups *duphead; static ino_t info_inumber; static int -pass1b_info(buf, buflen) - char * buf; - int buflen; +pass1b_info(char *buf, int buflen) { return snprintf(buf, buflen, "phase 1b, inode %d/%d", info_inumber, sblock.fs_ipg * sblock.fs_ncg); } void -pass1b() +pass1b(void) { int c, i; struct dinode *dp; @@ -98,8 +96,7 @@ pass1b() } static int -pass1bcheck(idesc) - struct inodesc *idesc; +pass1bcheck(struct inodesc *idesc) { struct dups *dlp; int nfrags, res = KEEPON; diff --git a/sbin/fsck_ffs/pass2.c b/sbin/fsck_ffs/pass2.c index 78130c0080e..f1df5b9b797 100644 --- a/sbin/fsck_ffs/pass2.c +++ b/sbin/fsck_ffs/pass2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass2.c,v 1.13 2002/06/09 08:13:05 todd Exp $ */ +/* $OpenBSD: pass2.c,v 1.14 2002/08/23 09:09:04 gluk Exp $ */ /* $NetBSD: pass2.c,v 1.17 1996/09/27 22:45:15 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)pass2.c 8.6 (Berkeley) 10/27/94"; #else -static char rcsid[] = "$OpenBSD: pass2.c,v 1.13 2002/06/09 08:13:05 todd Exp $"; +static const char rcsid[] = "$OpenBSD: pass2.c,v 1.14 2002/08/23 09:09:04 gluk Exp $"; #endif #endif /* not lint */ @@ -56,7 +56,7 @@ static char rcsid[] = "$OpenBSD: pass2.c,v 1.13 2002/06/09 08:13:05 todd Exp $"; #include "fsutil.h" #include "extern.h" -#define MINDIRSIZE (sizeof (struct dirtemplate)) +#define MINDIRSIZE (sizeof(struct dirtemplate)) static int pass2check(struct inodesc *); static int blksort(const void *, const void *); @@ -65,25 +65,21 @@ static int info_max; static int info_pos; static int -pass2_info1(buf, buflen) - char *buf; - int buflen; +pass2_info1(char *buf, int buflen) { return snprintf(buf, buflen, "phase 2, directory %d/%d", info_pos, info_max); } static int -pass2_info2(buf, buflen) - char *buf; - int buflen; +pass2_info2(char *buf, int buflen) { return snprintf(buf, buflen, "phase 2, parent directory %d/%d", info_pos, info_max); } void -pass2() +pass2(void) { struct dinode *dp; struct inoinfo **inpp, *inp, *pinp; @@ -151,7 +147,7 @@ pass2() /* * Sort the directory list into disk block order. */ - qsort((char *)inpsort, (size_t)inplast, sizeof *inpsort, blksort); + qsort(inpsort, (size_t)inplast, sizeof *inpsort, blksort); /* * Check the integrity of each directory. */ @@ -256,8 +252,7 @@ pass2() } static int -pass2check(idesc) - struct inodesc *idesc; +pass2check(struct inodesc *idesc) { struct direct *dirp = idesc->id_dirp; struct inoinfo *inp; @@ -382,11 +377,11 @@ chk1: fileerror(inp->i_parent, idesc->id_number, "MISSING '..'"); pfatal("CANNOT FIX, SECOND ENTRY IN DIRECTORY CONTAINS %s\n", dirp->d_name); - inp->i_dotdot = (ino_t)-1; + inp->i_dotdot = -1; } else if (dirp->d_reclen < entrysize) { fileerror(inp->i_parent, idesc->id_number, "MISSING '..'"); pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '..'\n"); - inp->i_dotdot = (ino_t)-1; + inp->i_dotdot = -1; } else if (inp->i_parent != 0) { /* * We know the parent, so fix now. @@ -515,8 +510,7 @@ again: * Routine to sort disk blocks. */ static int -blksort(inpp1, inpp2) - const void *inpp1, *inpp2; +blksort(const void *inpp1, const void *inpp2) { return ((* (struct inoinfo **) inpp1)->i_blks[0] - (* (struct inoinfo **) inpp2)->i_blks[0]); diff --git a/sbin/fsck_ffs/pass3.c b/sbin/fsck_ffs/pass3.c index 6bc85f4be26..33451ce0ade 100644 --- a/sbin/fsck_ffs/pass3.c +++ b/sbin/fsck_ffs/pass3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass3.c,v 1.6 2001/11/05 07:39:16 mpech Exp $ */ +/* $OpenBSD: pass3.c,v 1.7 2002/08/23 09:09:04 gluk Exp $ */ /* $NetBSD: pass3.c,v 1.8 1995/03/18 14:55:54 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)pass3.c 8.1 (Berkeley) 6/5/93"; #else -static char rcsid[] = "$OpenBSD: pass3.c,v 1.6 2001/11/05 07:39:16 mpech Exp $"; +static const char rcsid[] = "$OpenBSD: pass3.c,v 1.7 2002/08/23 09:09:04 gluk Exp $"; #endif #endif /* not lint */ @@ -53,16 +53,14 @@ static char rcsid[] = "$OpenBSD: pass3.c,v 1.6 2001/11/05 07:39:16 mpech Exp $"; static int info_pos; static int -pass3_info(buf, buflen) - char *buf; - int buflen; +pass3_info(char *buf, int buflen) { return snprintf(buf, buflen, "phase 3, directory %d/%ld", info_pos, inplast); } void -pass3() +pass3(void) { struct inoinfo **inpp, *inp, *pinp; ino_t orphan; diff --git a/sbin/fsck_ffs/pass4.c b/sbin/fsck_ffs/pass4.c index e3dc277247b..69f91c21d20 100644 --- a/sbin/fsck_ffs/pass4.c +++ b/sbin/fsck_ffs/pass4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass4.c,v 1.6 2002/06/09 08:13:05 todd Exp $ */ +/* $OpenBSD: pass4.c,v 1.7 2002/08/23 09:09:04 gluk Exp $ */ /* $NetBSD: pass4.c,v 1.11 1996/09/27 22:45:17 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)pass4.c 8.1 (Berkeley) 6/5/93"; #else -static char rcsid[] = "$OpenBSD: pass4.c,v 1.6 2002/06/09 08:13:05 todd Exp $"; +static const char rcsid[] = "$OpenBSD: pass4.c,v 1.7 2002/08/23 09:09:04 gluk Exp $"; #endif #endif /* not lint */ @@ -57,16 +57,14 @@ static char rcsid[] = "$OpenBSD: pass4.c,v 1.6 2002/06/09 08:13:05 todd Exp $"; static ino_t info_inumber; static int -pass4_info(buf, buflen) - char * buf; - int buflen; +pass4_info(char *buf, int buflen) { return snprintf(buf, buflen, "phase 4, inode %d/%d", info_inumber, lastino); } void -pass4() +pass4(void) { ino_t inumber; struct zlncnt *zlnp; @@ -128,8 +126,7 @@ pass4() } int -pass4check(idesc) - struct inodesc *idesc; +pass4check(struct inodesc *idesc) { struct dups *dlp; int nfrags, res = KEEPON; @@ -145,7 +142,7 @@ pass4check(idesc) dlp->dup = duplist->dup; dlp = duplist; duplist = duplist->next; - free((char *)dlp); + free(dlp); break; } if (dlp == 0) { diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c index c86577b6f6d..41f332baa9f 100644 --- a/sbin/fsck_ffs/pass5.c +++ b/sbin/fsck_ffs/pass5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass5.c,v 1.14 2001/12/01 19:04:41 deraadt Exp $ */ +/* $OpenBSD: pass5.c,v 1.15 2002/08/23 09:09:04 gluk Exp $ */ /* $NetBSD: pass5.c,v 1.16 1996/09/27 22:45:18 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)pass5.c 8.6 (Berkeley) 11/30/94"; #else -static char rcsid[] = "$OpenBSD: pass5.c,v 1.14 2001/12/01 19:04:41 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: pass5.c,v 1.15 2002/08/23 09:09:04 gluk Exp $"; #endif #endif /* not lint */ @@ -62,15 +62,13 @@ static int info_cg; static int info_maxcg; static int -pass5_info(buf, buflen) - char *buf; - int buflen; +pass5_info(char *buf, int buflen) { return snprintf(buf, buflen, "phase 5, cg %d/%d", info_cg, info_maxcg); } void -pass5() +pass5(void) { int c, blk, frags, basesize, sumsize, mapsize, savednrpos=0; int inomapsize, blkmapsize; diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index a144f8a8f34..1d8e833aeb3 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.16 2002/06/09 08:13:05 todd Exp $ */ +/* $OpenBSD: setup.c,v 1.17 2002/08/23 09:09:04 gluk Exp $ */ /* $NetBSD: setup.c,v 1.27 1996/09/27 22:45:19 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)setup.c 8.5 (Berkeley) 11/23/94"; #else -static char rcsid[] = "$OpenBSD: setup.c,v 1.16 2002/06/09 08:13:05 todd Exp $"; +static char rcsid[] = "$OpenBSD: setup.c,v 1.17 2002/08/23 09:09:04 gluk Exp $"; #endif #endif /* not lint */ @@ -72,8 +72,7 @@ static struct disklabel *getdisklabel(char *, int); static int readsb(int); int -setup(dev) - char *dev; +setup(char *dev) { long cg, size, asked, i, j; long bmapsize; @@ -118,7 +117,7 @@ setup(dev) asblk.b_un.b_buf = malloc(SBSIZE); if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL) errexit("cannot allocate space for superblock\n"); - if ((lp = getdisklabel((char *)NULL, fsreadfd)) != NULL) + if ((lp = getdisklabel(NULL, fsreadfd)) != NULL) dev_bsize = secsize = lp->d_secsize; else dev_bsize = secsize = DEV_BSIZE; @@ -352,7 +351,7 @@ setup(dev) * allocate and initialize the necessary maps */ bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(int16_t)); - blockmap = calloc((unsigned)bmapsize, sizeof (char)); + blockmap = calloc((unsigned)bmapsize, sizeof(char)); if (blockmap == NULL) { printf("cannot alloc %u bytes for blockmap\n", (unsigned)bmapsize); @@ -370,7 +369,7 @@ setup(dev) (unsigned)(maxino + 1)); goto badsblabel; } - lncntp = (int16_t *)calloc((unsigned)(maxino + 1), sizeof(int16_t)); + lncntp = calloc((unsigned)(maxino + 1), sizeof(int16_t)); if (lncntp == NULL) { printf("cannot alloc %lu bytes for lncntp\n", (unsigned long)(maxino + 1) * sizeof(int16_t)); @@ -379,10 +378,8 @@ setup(dev) numdirs = sblock.fs_cstotal.cs_ndir; inplast = 0; listmax = numdirs + 10; - inpsort = (struct inoinfo **)calloc((unsigned)listmax, - sizeof(struct inoinfo *)); - inphead = (struct inoinfo **)calloc((unsigned)numdirs, - sizeof(struct inoinfo *)); + inpsort = calloc((unsigned)listmax, sizeof(struct inoinfo *)); + inphead = calloc((unsigned)numdirs, sizeof(struct inoinfo *)); if (inpsort == NULL || inphead == NULL) { printf("cannot alloc %lu bytes for inphead\n", (unsigned long)numdirs * sizeof(struct inoinfo *)); @@ -404,8 +401,7 @@ badsblabel: * Read in the super block and its summary info. */ static int -readsb(listerr) - int listerr; +readsb(int listerr) { daddr_t super = bflag ? bflag : SBOFF / dev_bsize; @@ -509,9 +505,7 @@ readsb(listerr) } void -badsb(listerr, s) - int listerr; - char *s; +badsb(int listerr, char *s) { if (!listerr) @@ -528,10 +522,7 @@ badsb(listerr, s) * their needed information is available! */ int -calcsb(dev, devfd, fs) - char *dev; - int devfd; - struct fs *fs; +calcsb(char *dev, int devfd, struct fs *fs) { struct disklabel *lp; struct partition *pp; @@ -582,15 +573,13 @@ calcsb(dev, devfd, fs) } static struct disklabel * -getdisklabel(s, fd) - char *s; - int fd; +getdisklabel(char *s, int fd) { static struct disklabel lab; if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) { if (s == NULL) - return ((struct disklabel *)NULL); + return (NULL); pwarn("ioctl (GCINFO): %s\n", strerror(errno)); errexit("%s: can't read disk label\n", s); } diff --git a/sbin/fsck_ffs/utilities.c b/sbin/fsck_ffs/utilities.c index f3dcf5cec57..0bf21ce3e91 100644 --- a/sbin/fsck_ffs/utilities.c +++ b/sbin/fsck_ffs/utilities.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utilities.c,v 1.16 2002/08/20 21:57:56 deraadt Exp $ */ +/* $OpenBSD: utilities.c,v 1.17 2002/08/23 09:09:04 gluk Exp $ */ /* $NetBSD: utilities.c,v 1.18 1996/09/27 22:45:20 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)utilities.c 8.1 (Berkeley) 6/5/93"; #else -static char rcsid[] = "$OpenBSD: utilities.c,v 1.16 2002/08/20 21:57:56 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: utilities.c,v 1.17 2002/08/23 09:09:04 gluk Exp $"; #endif #endif /* not lint */ @@ -67,8 +67,7 @@ long diskreads, totalreads; /* Disk cache statistics */ static void rwerror(char *, daddr_t); int -ftypeok(dp) - struct dinode *dp; +ftypeok(struct dinode *dp) { switch (dp->di_mode & IFMT) { @@ -89,8 +88,7 @@ ftypeok(dp) } int -reply(question) - char *question; +reply(char *question) { int persevere; int c; @@ -130,7 +128,7 @@ reply(question) * Malloc buffers and set up cache. */ void -bufinit() +bufinit(void) { struct bufarea *bp; long bufcnt, i; @@ -147,7 +145,7 @@ bufinit() if (bufcnt < MINBUFS) bufcnt = MINBUFS; for (i = 0; i < bufcnt; i++) { - bp = (struct bufarea *)malloc(sizeof(struct bufarea)); + bp = malloc(sizeof(struct bufarea)); bufp = malloc((unsigned int)sblock.fs_bsize); if (bp == NULL || bufp == NULL) { if (i >= MINBUFS) @@ -168,9 +166,7 @@ bufinit() * Manage a cache of directory blocks. */ struct bufarea * -getdatablk(blkno, size) - daddr_t blkno; - long size; +getdatablk(daddr_t blkno, long size) { struct bufarea *bp; @@ -197,10 +193,7 @@ foundit: } void -getblk(bp, blk, size) - struct bufarea *bp; - daddr_t blk; - long size; +getblk(struct bufarea *bp, daddr_t blk, long size) { daddr_t dblk; @@ -215,9 +208,7 @@ getblk(bp, blk, size) } void -flush(fd, bp) - int fd; - struct bufarea *bp; +flush(int fd, struct bufarea *bp) { int i, j; @@ -241,9 +232,7 @@ flush(fd, bp) } static void -rwerror(mesg, blk) - char *mesg; - daddr_t blk; +rwerror(char *mesg, daddr_t blk) { if (preen == 0) @@ -254,8 +243,7 @@ rwerror(mesg, blk) } void -ckfini(markclean) - int markclean; +ckfini(int markclean) { struct bufarea *bp, *nbp; int cnt = 0; @@ -278,7 +266,7 @@ ckfini(markclean) flush(fswritefd, bp); nbp = bp->b_prev; free(bp->b_un.b_buf); - free((char *)bp); + free(bp); } if (bufhead.b_size != cnt) errexit("Panic: lost %d buffers\n", bufhead.b_size - cnt); @@ -305,11 +293,7 @@ ckfini(markclean) } int -bread(fd, buf, blk, size) - int fd; - char *buf; - daddr_t blk; - long size; +bread(int fd, char *buf, daddr_t blk, long size) { char *cp; int i, errs; @@ -344,11 +328,7 @@ bread(fd, buf, blk, size) } void -bwrite(fd, buf, blk, size) - int fd; - char *buf; - daddr_t blk; - long size; +bwrite(int fd, char *buf, daddr_t blk, long size) { int i; char *cp; @@ -381,8 +361,7 @@ bwrite(fd, buf, blk, size) * allocate a data block with the specified number of fragments */ int -allocblk(frags) - long frags; +allocblk(long frags) { int i, j, k, cg, baseblk; struct cg *cgp = &cgrp; @@ -425,9 +404,7 @@ allocblk(frags) * Free a previously allocated block */ void -freeblk(blkno, frags) - daddr_t blkno; - long frags; +freeblk(daddr_t blkno, long frags) { struct inodesc idesc; @@ -440,9 +417,7 @@ freeblk(blkno, frags) * Find a pathname */ void -getpathname(namebuf, curdir, ino) - char *namebuf; - ino_t curdir, ino; +getpathname(char *namebuf, ino_t curdir, ino_t ino) { int len; char *cp; @@ -496,8 +471,7 @@ getpathname(namebuf, curdir, ino) } void -catch(n) - int n; +catch(int n) { /* XXX signal race */ if (!doinglevel2) @@ -511,8 +485,7 @@ catch(n) * so that reboot sequence may be interrupted. */ void -catchquit(n) - int n; +catchquit(int n) { extern volatile sig_atomic_t returntosingle; char buf[1024]; @@ -529,8 +502,7 @@ catchquit(n) * Used by child processes in preen. */ void -voidquit(n) - int n; +voidquit(int n) { sleep(1); @@ -542,11 +514,8 @@ voidquit(n) * determine whether an inode should be fixed. */ int -dofix(idesc, msg) - struct inodesc *idesc; - char *msg; +dofix(struct inodesc *idesc, char *msg) { - switch (idesc->id_fix) { case DONTKNOW: @@ -583,8 +552,7 @@ int (* info_fn)(char *, int) = NULL; char *info_filesys = "?"; void -catchinfo(n) - int n; +catchinfo(int n) { int save_errno = errno; char buf[1024]; |