Submitted by: phk, added to by bde
Fix all the warnings from `gcc -Wall'.
This commit is contained in:
parent
15519b2f58
commit
31f4ab50bc
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=7585
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -40,6 +40,7 @@ static char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 6/5/93";
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ufs/dir.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "fsck.h"
|
||||
@ -56,12 +57,20 @@ struct odirtemplate odirhead = {
|
||||
0, DIRBLKSIZ - 12, 2, ".."
|
||||
};
|
||||
|
||||
struct direct *fsck_readdir();
|
||||
struct bufarea *getdirblk();
|
||||
|
||||
static int chgino __P((struct inodesc *idesc));
|
||||
static int dircheck __P((struct inodesc *idesc, struct direct *dp));
|
||||
static int expanddir __P((struct dinode *dp, char *name));
|
||||
static void freedir __P((ino_t ino, ino_t parent));
|
||||
static struct direct * fsck_readdir __P((struct inodesc *idesc));
|
||||
static struct bufarea * getdirblk __P((daddr_t blkno, long size));
|
||||
static int lftempname __P((char *bufp, ino_t ino));
|
||||
static int mkentry __P((struct inodesc *idesc));
|
||||
|
||||
/*
|
||||
* Propagate connected state through the tree.
|
||||
*/
|
||||
void
|
||||
propagate()
|
||||
{
|
||||
register struct inoinfo **inpp, *inp;
|
||||
@ -87,6 +96,7 @@ propagate()
|
||||
/*
|
||||
* Scan each entry in a directory block.
|
||||
*/
|
||||
int
|
||||
dirscan(idesc)
|
||||
register struct inodesc *idesc;
|
||||
{
|
||||
@ -206,6 +216,7 @@ fsck_readdir(idesc)
|
||||
* Verify that a directory entry is valid.
|
||||
* This is a superset of the checks made in the kernel.
|
||||
*/
|
||||
int
|
||||
dircheck(idesc, dp)
|
||||
struct inodesc *idesc;
|
||||
register struct direct *dp;
|
||||
@ -248,6 +259,7 @@ dircheck(idesc, dp)
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
direrror(ino, errmesg)
|
||||
ino_t ino;
|
||||
char *errmesg;
|
||||
@ -256,6 +268,7 @@ direrror(ino, errmesg)
|
||||
fileerror(ino, ino, errmesg);
|
||||
}
|
||||
|
||||
void
|
||||
fileerror(cwd, ino, errmesg)
|
||||
ino_t cwd, ino;
|
||||
char *errmesg;
|
||||
@ -279,6 +292,7 @@ fileerror(cwd, ino, errmesg)
|
||||
pfatal("NAME=%s\n", pathbuf);
|
||||
}
|
||||
|
||||
void
|
||||
adjust(idesc, lcnt)
|
||||
register struct inodesc *idesc;
|
||||
short lcnt;
|
||||
@ -309,6 +323,7 @@ adjust(idesc, lcnt)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
mkentry(idesc)
|
||||
struct inodesc *idesc;
|
||||
{
|
||||
@ -345,6 +360,7 @@ mkentry(idesc)
|
||||
return (ALTERED|STOP);
|
||||
}
|
||||
|
||||
int
|
||||
chgino(idesc)
|
||||
struct inodesc *idesc;
|
||||
{
|
||||
@ -360,6 +376,7 @@ chgino(idesc)
|
||||
return (ALTERED|STOP);
|
||||
}
|
||||
|
||||
int
|
||||
linkup(orphan, parentdir)
|
||||
ino_t orphan;
|
||||
ino_t parentdir;
|
||||
@ -369,7 +386,6 @@ linkup(orphan, parentdir)
|
||||
ino_t oldlfdir;
|
||||
struct inodesc idesc;
|
||||
char tempname[BUFSIZ];
|
||||
extern int pass4check();
|
||||
|
||||
bzero((char *)&idesc, sizeof(struct inodesc));
|
||||
dp = ginode(orphan);
|
||||
@ -467,6 +483,7 @@ linkup(orphan, parentdir)
|
||||
/*
|
||||
* fix an entry in a directory.
|
||||
*/
|
||||
int
|
||||
changeino(dir, name, newnum)
|
||||
ino_t dir;
|
||||
char *name;
|
||||
@ -487,6 +504,7 @@ changeino(dir, name, newnum)
|
||||
/*
|
||||
* make an entry in a directory
|
||||
*/
|
||||
int
|
||||
makeentry(parent, ino, name)
|
||||
ino_t parent, ino;
|
||||
char *name;
|
||||
@ -522,6 +540,7 @@ makeentry(parent, ino, name)
|
||||
/*
|
||||
* Attempt to expand the size of a directory
|
||||
*/
|
||||
int
|
||||
expanddir(dp, name)
|
||||
register struct dinode *dp;
|
||||
char *name;
|
||||
@ -578,6 +597,7 @@ expanddir(dp, name)
|
||||
/*
|
||||
* allocate a new directory
|
||||
*/
|
||||
int
|
||||
allocdir(parent, request, mode)
|
||||
ino_t parent, request;
|
||||
int mode;
|
||||
@ -633,6 +653,7 @@ allocdir(parent, request, mode)
|
||||
/*
|
||||
* free a directory inode
|
||||
*/
|
||||
static void
|
||||
freedir(ino, parent)
|
||||
ino_t ino, parent;
|
||||
{
|
||||
@ -649,6 +670,7 @@ freedir(ino, parent)
|
||||
/*
|
||||
* generate a temporary name for the lost+found directory.
|
||||
*/
|
||||
int
|
||||
lftempname(bufp, ino)
|
||||
char *bufp;
|
||||
ino_t ino;
|
||||
|
@ -179,13 +179,14 @@ char havesb; /* superblock has been read */
|
||||
int fsmodified; /* 1 => write done to file system */
|
||||
int fsreadfd; /* file descriptor for reading file system */
|
||||
int fswritefd; /* file descriptor for writing file system */
|
||||
int returntosingle; /* return to single user mode */
|
||||
|
||||
daddr_t maxfsblock; /* number of blocks in the file system */
|
||||
char *blockmap; /* ptr to primary blk allocation map */
|
||||
ino_t maxino; /* number of inodes in file system */
|
||||
ino_t lastino; /* last inode in use */
|
||||
char *statemap; /* ptr to inode state table */
|
||||
char *typemap; /* ptr to inode type table */
|
||||
unsigned char *typemap; /* ptr to inode type table */
|
||||
short *lncntp; /* ptr to link count table */
|
||||
|
||||
ino_t lfdir; /* lost & found directory inode number */
|
||||
@ -208,9 +209,84 @@ struct dinode zino;
|
||||
#define ALTERED 0x08
|
||||
#define FOUND 0x10
|
||||
|
||||
time_t time();
|
||||
struct dinode *ginode();
|
||||
struct inoinfo *getinoinfo();
|
||||
void getblk();
|
||||
ino_t allocino();
|
||||
int findino();
|
||||
/* dir.c */
|
||||
void adjust __P((struct inodesc *idesc, short lcnt));
|
||||
int allocdir __P((ino_t parent, ino_t request, int mode));
|
||||
int changeino __P((ino_t dir, char *name, ino_t newnum));
|
||||
void direrror __P((ino_t ino, char *errmesg));
|
||||
int dirscan __P((struct inodesc *idesc));
|
||||
void fileerror __P((ino_t cwd, ino_t ino, char *errmesg));
|
||||
int linkup __P((ino_t orphan, ino_t parentdir));
|
||||
int makeentry __P((ino_t parent, ino_t ino, char *name));
|
||||
void propagate __P((void));
|
||||
|
||||
/* ffs_subr.c */
|
||||
void ffs_fragacct __P((struct fs *fs, int fragmap, long *fraglist, int cnt));
|
||||
|
||||
/* inode.c */
|
||||
ino_t allocino __P((ino_t request, int type));
|
||||
void blkerror __P((ino_t ino, char *type, daddr_t blk));
|
||||
void cacheino __P((struct dinode *dp, ino_t inumber));
|
||||
int chkrange __P((daddr_t blk, int cnt));
|
||||
int ckinode __P((struct dinode *dp, struct inodesc *idesc));
|
||||
void clri __P((struct inodesc *idesc, char *type, int flag));
|
||||
int findino __P((struct inodesc *idesc));
|
||||
void freeino __P((ino_t ino));
|
||||
void freeinodebuf __P((void));
|
||||
struct dinode * ginode __P((ino_t inumber));
|
||||
struct inoinfo * getinoinfo __P((ino_t inumber));
|
||||
struct dinode * getnextinode __P((ino_t inumber));
|
||||
void inodirty __P((void));
|
||||
void inocleanup __P((void));
|
||||
void pinode __P((ino_t ino));
|
||||
void resetinodebuf __P((void));
|
||||
int findname __P((struct inodesc *idesc));
|
||||
|
||||
/* pass1.c */
|
||||
void pass1 __P((void));
|
||||
int pass1check __P((struct inodesc *idesc));
|
||||
|
||||
/* pass1b.c */
|
||||
void pass1b __P((void));
|
||||
|
||||
/* pass2.c */
|
||||
void pass2 __P((void));
|
||||
|
||||
/* pass3.c */
|
||||
void pass3 __P((void));
|
||||
|
||||
/* pass4.c */
|
||||
void pass4 __P((void));
|
||||
int pass4check __P((struct inodesc *idesc));
|
||||
|
||||
/* pass5.c */
|
||||
void pass5 __P((void));
|
||||
|
||||
/* preen.c */
|
||||
char *blockcheck __P((char *name));
|
||||
int checkfstab __P((int preen, int maxrun,int (*docheck)(), int (*chkit)()));
|
||||
|
||||
/* setup.c */
|
||||
int setup __P((char *dev));
|
||||
|
||||
/* utilities.c */
|
||||
int allocblk __P((long frags));
|
||||
int bread __P((int fd, char *buf, daddr_t blk, long size));
|
||||
void bufinit __P((void));
|
||||
void bwrite __P((int fd, char *buf, daddr_t blk, long size));
|
||||
void catch __P((int));
|
||||
void catchquit __P((int));
|
||||
void ckfini __P((void));
|
||||
int dofix __P((struct inodesc *idesc, char *msg));
|
||||
__dead void errexit __P((const char *s1, ...)) __dead2;
|
||||
void flush __P((int fd, struct bufarea *bp));
|
||||
void freeblk __P((daddr_t blkno, long frags));
|
||||
int ftypeok __P((struct dinode *dp));
|
||||
void getblk __P((struct bufarea *bp, daddr_t blk, long size));
|
||||
struct bufarea * getdatablk __P((daddr_t blkno, long size));
|
||||
void getpathname __P((char *namebuf, ino_t curdir, ino_t ino));
|
||||
__dead void panic __P((const char *, ...)) __dead2;
|
||||
void pfatal __P((const char *s1, ...));
|
||||
void pwarn __P((const char *s1, ...));
|
||||
int reply __P((char *question));
|
||||
void voidquit __P((int));
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)inode.c 8.5 (Berkeley) 2/8/95";
|
||||
static const char sccsid[] = "@(#)inode.c 8.5 (Berkeley) 2/8/95";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -41,12 +41,16 @@ static char sccsid[] = "@(#)inode.c 8.5 (Berkeley) 2/8/95";
|
||||
#include <ufs/ufs/dir.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "fsck.h"
|
||||
|
||||
static ino_t startinum;
|
||||
|
||||
static int iblock __P((struct inodesc *idesc, long ilevel, quad_t isize));
|
||||
|
||||
int
|
||||
ckinode(dp, idesc)
|
||||
struct dinode *dp;
|
||||
register struct inodesc *idesc;
|
||||
@ -99,6 +103,7 @@ ckinode(dp, idesc)
|
||||
return (KEEPON);
|
||||
}
|
||||
|
||||
static int
|
||||
iblock(idesc, ilevel, isize)
|
||||
struct inodesc *idesc;
|
||||
long ilevel;
|
||||
@ -110,7 +115,6 @@ iblock(idesc, ilevel, isize)
|
||||
int i, n, (*func)(), nif;
|
||||
quad_t sizepb;
|
||||
char buf[BUFSIZ];
|
||||
extern int dirscan(), pass1check();
|
||||
|
||||
if (idesc->id_type == ADDR) {
|
||||
func = idesc->id_func;
|
||||
@ -164,6 +168,7 @@ iblock(idesc, ilevel, isize)
|
||||
* Check that a block in a legal block number.
|
||||
* Return 0 if in range, 1 if out of range.
|
||||
*/
|
||||
int
|
||||
chkrange(blk, cnt)
|
||||
daddr_t blk;
|
||||
int cnt;
|
||||
@ -253,6 +258,7 @@ getnextinode(inumber)
|
||||
return (dp++);
|
||||
}
|
||||
|
||||
void
|
||||
resetinodebuf()
|
||||
{
|
||||
|
||||
@ -278,6 +284,7 @@ resetinodebuf()
|
||||
(void)getnextinode(nextino);
|
||||
}
|
||||
|
||||
void
|
||||
freeinodebuf()
|
||||
{
|
||||
|
||||
@ -293,6 +300,7 @@ freeinodebuf()
|
||||
*
|
||||
* Enter inodes into the cache.
|
||||
*/
|
||||
void
|
||||
cacheino(dp, inumber)
|
||||
register struct dinode *dp;
|
||||
ino_t inumber;
|
||||
@ -352,6 +360,7 @@ getinoinfo(inumber)
|
||||
/*
|
||||
* Clean up all the inode cache structure.
|
||||
*/
|
||||
void
|
||||
inocleanup()
|
||||
{
|
||||
register struct inoinfo **inpp;
|
||||
@ -365,12 +374,13 @@ inocleanup()
|
||||
inphead = inpsort = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
inodirty()
|
||||
{
|
||||
|
||||
dirty(pbp);
|
||||
}
|
||||
|
||||
void
|
||||
clri(idesc, type, flag)
|
||||
register struct inodesc *idesc;
|
||||
char *type;
|
||||
@ -395,6 +405,7 @@ clri(idesc, type, flag)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
findname(idesc)
|
||||
struct inodesc *idesc;
|
||||
{
|
||||
@ -406,6 +417,7 @@ findname(idesc)
|
||||
return (STOP|FOUND);
|
||||
}
|
||||
|
||||
int
|
||||
findino(idesc)
|
||||
struct inodesc *idesc;
|
||||
{
|
||||
@ -421,6 +433,7 @@ findino(idesc)
|
||||
return (KEEPON);
|
||||
}
|
||||
|
||||
void
|
||||
pinode(ino)
|
||||
ino_t ino;
|
||||
{
|
||||
@ -446,6 +459,7 @@ pinode(ino)
|
||||
printf("MTIME=%12.12s %4.4s ", &p[4], &p[20]);
|
||||
}
|
||||
|
||||
void
|
||||
blkerror(ino, type, blk)
|
||||
ino_t ino;
|
||||
char *type;
|
||||
@ -526,11 +540,11 @@ allocino(request, type)
|
||||
/*
|
||||
* deallocate an inode
|
||||
*/
|
||||
void
|
||||
freeino(ino)
|
||||
ino_t ino;
|
||||
{
|
||||
struct inodesc idesc;
|
||||
extern int pass4check();
|
||||
struct dinode *dp;
|
||||
|
||||
bzero((char *)&idesc, sizeof(struct inodesc));
|
||||
|
@ -32,13 +32,13 @@
|
||||
*/
|
||||
|
||||
#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 */
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94";
|
||||
static const char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -49,22 +49,24 @@ static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94";
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <fstab.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include "fsck.h"
|
||||
static int argtoi __P((int flag, char *req, char *str, int base));
|
||||
static int docheck __P((struct fstab *fsp));
|
||||
static int checkfilesys __P((char *filesys, char *mntpt, long auxdata,
|
||||
int child));
|
||||
|
||||
void catch(), catchquit(), voidquit();
|
||||
int returntosingle;
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int ch;
|
||||
int ret, maxrun = 0;
|
||||
extern int docheck(), checkfilesys();
|
||||
extern char *optarg, *blockcheck();
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
sync();
|
||||
@ -135,6 +137,7 @@ main(argc, argv)
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
int
|
||||
argtoi(flag, req, str, base)
|
||||
int flag;
|
||||
char *req, *str;
|
||||
@ -152,6 +155,7 @@ argtoi(flag, req, str, base)
|
||||
/*
|
||||
* Determine whether a filesystem should be checked.
|
||||
*/
|
||||
int
|
||||
docheck(fsp)
|
||||
register struct fstab *fsp;
|
||||
{
|
||||
@ -168,9 +172,11 @@ docheck(fsp)
|
||||
* Check the specified filesystem.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
checkfilesys(filesys, mntpt, auxdata, child)
|
||||
char *filesys, *mntpt;
|
||||
long auxdata;
|
||||
int child;
|
||||
{
|
||||
daddr_t n_ffree, n_bfree;
|
||||
struct dups *dp;
|
||||
@ -255,7 +261,7 @@ checkfilesys(filesys, mntpt, auxdata, child)
|
||||
n_bfree = sblock.fs_cstotal.cs_nbfree;
|
||||
pwarn("%ld files, %ld used, %ld free ",
|
||||
n_files, n_blks, n_ffree + sblock.fs_frag * n_bfree);
|
||||
printf("(%ld frags, %ld blocks, %d.%d%% fragmentation)\n",
|
||||
printf("(%ld frags, %ld blocks, %ld.%ld%% fragmentation)\n",
|
||||
n_ffree, n_bfree, (n_ffree * 100) / sblock.fs_dsize,
|
||||
((n_ffree * 1000 + sblock.fs_dsize / 2) / sblock.fs_dsize) % 10);
|
||||
if (debug &&
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)pass1.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)pass1.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -40,15 +40,17 @@ static char sccsid[] = "@(#)pass1.c 8.1 (Berkeley) 6/5/93";
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ufs/dir.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "fsck.h"
|
||||
|
||||
static daddr_t badblk;
|
||||
static daddr_t dupblk;
|
||||
int pass1check();
|
||||
struct dinode *getnextinode();
|
||||
|
||||
static void checkinode __P((ino_t inumber, struct inodesc *idesc));
|
||||
|
||||
void
|
||||
pass1()
|
||||
{
|
||||
ino_t inumber;
|
||||
@ -87,6 +89,7 @@ pass1()
|
||||
freeinodebuf();
|
||||
}
|
||||
|
||||
void
|
||||
checkinode(inumber, idesc)
|
||||
ino_t inumber;
|
||||
register struct inodesc *idesc;
|
||||
@ -148,7 +151,7 @@ checkinode(inumber, idesc)
|
||||
errexit("cannot read symlink");
|
||||
if (debug) {
|
||||
symbuf[dp->di_size] = 0;
|
||||
printf("convert symlink %d(%s) of size %d\n",
|
||||
printf("convert symlink %ld(%s) of size %ld\n",
|
||||
inumber, symbuf, (long)dp->di_size);
|
||||
}
|
||||
dp = ginode(inumber);
|
||||
@ -247,6 +250,7 @@ checkinode(inumber, idesc)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
pass1check(idesc)
|
||||
register struct inodesc *idesc;
|
||||
{
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)pass1b.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)pass1b.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -45,6 +45,7 @@ static char sccsid[] = "@(#)pass1b.c 8.1 (Berkeley) 6/5/93";
|
||||
int pass1bcheck();
|
||||
static struct dups *duphead;
|
||||
|
||||
void
|
||||
pass1b()
|
||||
{
|
||||
register int c, i;
|
||||
@ -72,6 +73,7 @@ pass1b()
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
pass1bcheck(idesc)
|
||||
register struct inodesc *idesc;
|
||||
{
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)pass2.c 8.2 (Berkeley) 2/27/94";
|
||||
static const char sccsid[] = "@(#)pass2.c 8.2 (Berkeley) 2/27/94";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -40,6 +40,7 @@ static char sccsid[] = "@(#)pass2.c 8.2 (Berkeley) 2/27/94";
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ufs/dir.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "fsck.h"
|
||||
@ -48,6 +49,7 @@ static char sccsid[] = "@(#)pass2.c 8.2 (Berkeley) 2/27/94";
|
||||
|
||||
int pass2check(), blksort();
|
||||
|
||||
void
|
||||
pass2()
|
||||
{
|
||||
register struct dinode *dp;
|
||||
@ -189,6 +191,7 @@ pass2()
|
||||
propagate();
|
||||
}
|
||||
|
||||
int
|
||||
pass2check(idesc)
|
||||
struct inodesc *idesc;
|
||||
{
|
||||
@ -422,6 +425,7 @@ pass2check(idesc)
|
||||
/*
|
||||
* Routine to sort disk blocks.
|
||||
*/
|
||||
int
|
||||
blksort(inpp1, inpp2)
|
||||
struct inoinfo **inpp1, **inpp2;
|
||||
{
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)pass3.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)pass3.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -41,6 +41,7 @@ static char sccsid[] = "@(#)pass3.c 8.1 (Berkeley) 6/5/93";
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include "fsck.h"
|
||||
|
||||
void
|
||||
pass3()
|
||||
{
|
||||
register struct inoinfo **inpp, *inp;
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)pass4.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)pass4.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -45,6 +45,7 @@ static char sccsid[] = "@(#)pass4.c 8.1 (Berkeley) 6/5/93";
|
||||
|
||||
int pass4check();
|
||||
|
||||
void
|
||||
pass4()
|
||||
{
|
||||
register ino_t inumber;
|
||||
@ -103,6 +104,7 @@ pass4()
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
pass4check(idesc)
|
||||
register struct inodesc *idesc;
|
||||
{
|
||||
|
@ -32,19 +32,21 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)pass5.c 8.2 (Berkeley) 2/2/94";
|
||||
static const char sccsid[] = "@(#)pass5.c 8.2 (Berkeley) 2/2/94";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "fsck.h"
|
||||
|
||||
void
|
||||
pass5()
|
||||
{
|
||||
int c, blk, frags, basesize, sumsize, mapsize, savednrpos;
|
||||
int c, blk, frags, basesize, sumsize, mapsize, savednrpos = 0;
|
||||
register struct fs *fs = &sblock;
|
||||
register struct cg *cg = &cgrp;
|
||||
daddr_t dbase, dmax;
|
||||
|
@ -32,19 +32,20 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)preen.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)preen.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <fstab.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
char *rawname(), *unrawname(), *blockcheck();
|
||||
#include "fsck.h"
|
||||
|
||||
struct part {
|
||||
struct part *next; /* forward link of partitions on disk */
|
||||
@ -60,9 +61,16 @@ struct disk {
|
||||
int pid; /* If != 0, pid of proc working on */
|
||||
} *disks;
|
||||
|
||||
static void addpart __P((char *name, char *fsname, long auxdata));
|
||||
static int startdisk __P((struct disk *dk, int (*checkit)()));
|
||||
static struct disk *finddisk __P((char *name));
|
||||
static char *unrawname __P((char *name));
|
||||
static char *rawname __P((char *name));
|
||||
|
||||
int nrun, ndisks;
|
||||
char hotroot;
|
||||
|
||||
int
|
||||
checkfstab(preen, maxrun, docheck, chkit)
|
||||
int preen, maxrun;
|
||||
int (*docheck)(), (*chkit)();
|
||||
@ -84,10 +92,12 @@ checkfstab(preen, maxrun, docheck, chkit)
|
||||
while ((fsp = getfsent()) != 0) {
|
||||
if ((auxdata = (*docheck)(fsp)) == 0)
|
||||
continue;
|
||||
if (preen == 0 || passno == 1 && fsp->fs_passno == 1) {
|
||||
if (name = blockcheck(fsp->fs_spec)) {
|
||||
if (sumstatus = (*chkit)(name,
|
||||
fsp->fs_file, auxdata, 0))
|
||||
if (!preen || (passno == 1 && fsp->fs_passno == 1)) {
|
||||
name = blockcheck(fsp->fs_spec);
|
||||
if (name) {
|
||||
sumstatus = (*chkit)(name,
|
||||
fsp->fs_file, auxdata, 0);
|
||||
if (sumstatus)
|
||||
return (sumstatus);
|
||||
} else if (preen)
|
||||
return (8);
|
||||
@ -111,7 +121,8 @@ checkfstab(preen, maxrun, docheck, chkit)
|
||||
maxrun = ndisks;
|
||||
nextdisk = disks;
|
||||
for (passno = 0; passno < maxrun; ++passno) {
|
||||
while (ret = startdisk(nextdisk, chkit) && nrun > 0)
|
||||
while ((ret = startdisk(nextdisk, chkit)) != 0 &&
|
||||
nrun > 0)
|
||||
sleep(10);
|
||||
if (ret)
|
||||
return (ret);
|
||||
@ -150,8 +161,8 @@ checkfstab(preen, maxrun, docheck, chkit)
|
||||
|
||||
if (nextdisk == NULL) {
|
||||
if (dk->part) {
|
||||
while (ret = startdisk(dk, chkit) &&
|
||||
nrun > 0)
|
||||
while ((ret = startdisk(dk, chkit)) != 0
|
||||
&& nrun > 0)
|
||||
sleep(10);
|
||||
if (ret)
|
||||
return (ret);
|
||||
@ -164,8 +175,8 @@ checkfstab(preen, maxrun, docheck, chkit)
|
||||
nextdisk->pid == 0)
|
||||
break;
|
||||
}
|
||||
while (ret = startdisk(nextdisk, chkit) &&
|
||||
nrun > 0)
|
||||
while ((ret = startdisk(nextdisk, chkit)) != 0
|
||||
&& nrun > 0)
|
||||
sleep(10);
|
||||
if (ret)
|
||||
return (ret);
|
||||
@ -192,7 +203,7 @@ finddisk(name)
|
||||
{
|
||||
register struct disk *dk, **dkp;
|
||||
register char *p;
|
||||
size_t len;
|
||||
size_t len = 0;
|
||||
|
||||
for (p = name + strlen(name) - 1; p >= name; --p)
|
||||
if (isdigit(*p)) {
|
||||
@ -225,6 +236,7 @@ finddisk(name)
|
||||
return (dk);
|
||||
}
|
||||
|
||||
void
|
||||
addpart(name, fsname, auxdata)
|
||||
char *name, *fsname;
|
||||
long auxdata;
|
||||
@ -256,6 +268,7 @@ addpart(name, fsname, auxdata)
|
||||
pt->auxdata = auxdata;
|
||||
}
|
||||
|
||||
int
|
||||
startdisk(dk, checkit)
|
||||
register struct disk *dk;
|
||||
int (*checkit)();
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)setup.c 8.2 (Berkeley) 2/21/94";
|
||||
static const char sccsid[] = "@(#)setup.c 8.2 (Berkeley) 2/21/94";
|
||||
#endif /* not lint */
|
||||
|
||||
#define DKTYPENAMES
|
||||
@ -45,6 +45,7 @@ static char sccsid[] = "@(#)setup.c 8.2 (Berkeley) 2/21/94";
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/file.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
@ -54,8 +55,13 @@ struct bufarea asblk;
|
||||
#define altsblock (*asblk.b_un.b_fs)
|
||||
#define POWEROF2(num) (((num) & ((num) - 1)) == 0)
|
||||
|
||||
struct disklabel *getdisklabel();
|
||||
static int readsb __P((int listerr));
|
||||
static void badsb __P((int listerr, char *s));
|
||||
static int calcsb __P((char *dev, int devfd, struct fs *fs));
|
||||
static struct disklabel * getdisklabel __P((char *s, int fd));
|
||||
|
||||
|
||||
int
|
||||
setup(dev)
|
||||
char *dev;
|
||||
{
|
||||
@ -99,7 +105,8 @@ 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))
|
||||
lp = getdisklabel((char *)NULL, fsreadfd);
|
||||
if (lp)
|
||||
dev_bsize = secsize = lp->d_secsize;
|
||||
else
|
||||
dev_bsize = secsize = DEV_BSIZE;
|
||||
@ -297,6 +304,7 @@ setup(dev)
|
||||
/*
|
||||
* Read in the super block and its summary info.
|
||||
*/
|
||||
static int
|
||||
readsb(listerr)
|
||||
int listerr;
|
||||
{
|
||||
@ -380,6 +388,7 @@ readsb(listerr)
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
badsb(listerr, s)
|
||||
int listerr;
|
||||
char *s;
|
||||
@ -398,6 +407,7 @@ badsb(listerr, s)
|
||||
* can be used. Do NOT attempt to use other macros without verifying that
|
||||
* their needed information is available!
|
||||
*/
|
||||
int
|
||||
calcsb(dev, devfd, fs)
|
||||
char *dev;
|
||||
int devfd;
|
||||
@ -409,7 +419,7 @@ calcsb(dev, devfd, fs)
|
||||
int i;
|
||||
|
||||
cp = index(dev, '\0') - 1;
|
||||
if (cp == (char *)-1 || (*cp < 'a' || *cp > 'h') && !isdigit(*cp)) {
|
||||
if (cp == (char *)-1 || ((*cp < 'a' || *cp > 'h') && !isdigit(*cp))) {
|
||||
pfatal("%s: CANNOT FIGURE OUT FILE SYSTEM PARTITION\n", dev);
|
||||
return (0);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)utilities.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)utilities.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -42,12 +42,17 @@ static char sccsid[] = "@(#)utilities.c 8.1 (Berkeley) 6/5/93";
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "fsck.h"
|
||||
|
||||
long diskreads, totalreads; /* Disk cache statistics */
|
||||
|
||||
static void rwerror __P((char *mesg, daddr_t blk));
|
||||
|
||||
int
|
||||
ftypeok(dp)
|
||||
struct dinode *dp;
|
||||
{
|
||||
@ -69,6 +74,7 @@ ftypeok(dp)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
reply(question)
|
||||
char *question;
|
||||
{
|
||||
@ -104,6 +110,7 @@ reply(question)
|
||||
/*
|
||||
* Malloc buffers and set up cache.
|
||||
*/
|
||||
void
|
||||
bufinit()
|
||||
{
|
||||
register struct bufarea *bp;
|
||||
@ -188,6 +195,7 @@ getblk(bp, blk, size)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
flush(fd, bp)
|
||||
int fd;
|
||||
register struct bufarea *bp;
|
||||
@ -213,6 +221,7 @@ flush(fd, bp)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rwerror(mesg, blk)
|
||||
char *mesg;
|
||||
daddr_t blk;
|
||||
@ -225,6 +234,7 @@ rwerror(mesg, blk)
|
||||
errexit("Program terminated\n");
|
||||
}
|
||||
|
||||
void
|
||||
ckfini()
|
||||
{
|
||||
register struct bufarea *bp, *nbp;
|
||||
@ -260,6 +270,7 @@ ckfini()
|
||||
(void)close(fswritefd);
|
||||
}
|
||||
|
||||
int
|
||||
bread(fd, buf, blk, size)
|
||||
int fd;
|
||||
char *buf;
|
||||
@ -298,6 +309,7 @@ bread(fd, buf, blk, size)
|
||||
return (errs);
|
||||
}
|
||||
|
||||
void
|
||||
bwrite(fd, buf, blk, size)
|
||||
int fd;
|
||||
char *buf;
|
||||
@ -334,6 +346,7 @@ bwrite(fd, buf, blk, size)
|
||||
/*
|
||||
* allocate a data block with the specified number of fragments
|
||||
*/
|
||||
int
|
||||
allocblk(frags)
|
||||
long frags;
|
||||
{
|
||||
@ -364,6 +377,7 @@ allocblk(frags)
|
||||
/*
|
||||
* Free a previously allocated block
|
||||
*/
|
||||
void
|
||||
freeblk(blkno, frags)
|
||||
daddr_t blkno;
|
||||
long frags;
|
||||
@ -378,6 +392,7 @@ freeblk(blkno, frags)
|
||||
/*
|
||||
* Find a pathname
|
||||
*/
|
||||
void
|
||||
getpathname(namebuf, curdir, ino)
|
||||
char *namebuf;
|
||||
ino_t curdir, ino;
|
||||
@ -386,7 +401,6 @@ getpathname(namebuf, curdir, ino)
|
||||
register char *cp;
|
||||
struct inodesc idesc;
|
||||
static int busy = 0;
|
||||
extern int findname();
|
||||
|
||||
if (curdir == ino && ino == ROOTINO) {
|
||||
(void)strcpy(namebuf, "/");
|
||||
@ -435,7 +449,8 @@ getpathname(namebuf, curdir, ino)
|
||||
}
|
||||
|
||||
void
|
||||
catch()
|
||||
catch(x)
|
||||
int x;
|
||||
{
|
||||
if (!doinglevel2)
|
||||
ckfini();
|
||||
@ -448,10 +463,9 @@ catch()
|
||||
* so that reboot sequence may be interrupted.
|
||||
*/
|
||||
void
|
||||
catchquit()
|
||||
catchquit(x)
|
||||
int x;
|
||||
{
|
||||
extern returntosingle;
|
||||
|
||||
printf("returning to single-user after filesystem check\n");
|
||||
returntosingle = 1;
|
||||
(void)signal(SIGQUIT, SIG_DFL);
|
||||
@ -462,7 +476,8 @@ catchquit()
|
||||
* Used by child processes in preen.
|
||||
*/
|
||||
void
|
||||
voidquit()
|
||||
voidquit(x)
|
||||
int x;
|
||||
{
|
||||
|
||||
sleep(1);
|
||||
@ -473,6 +488,7 @@ voidquit()
|
||||
/*
|
||||
* determine whether an inode should be fixed.
|
||||
*/
|
||||
int
|
||||
dofix(idesc, msg)
|
||||
register struct inodesc *idesc;
|
||||
char *msg;
|
||||
@ -506,15 +522,19 @@ dofix(idesc, msg)
|
||||
|
||||
default:
|
||||
errexit("UNKNOWN INODESC FIX MODE %d\n", idesc->id_fix);
|
||||
return (0);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/* VARARGS1 */
|
||||
errexit(s1, s2, s3, s4)
|
||||
char *s1;
|
||||
__dead void
|
||||
errexit(const char *s1, ...)
|
||||
{
|
||||
printf(s1, s2, s3, s4);
|
||||
va_list ap;
|
||||
va_start(ap,s1);
|
||||
vfprintf(stdout, s1, ap);
|
||||
va_end(ap);
|
||||
exit(8);
|
||||
}
|
||||
|
||||
@ -523,19 +543,22 @@ errexit(s1, s2, s3, s4)
|
||||
* Die if preening, otherwise just print message and continue.
|
||||
*/
|
||||
/* VARARGS1 */
|
||||
pfatal(s, a1, a2, a3)
|
||||
char *s;
|
||||
void
|
||||
pfatal(const char *s, ...)
|
||||
{
|
||||
|
||||
va_list ap;
|
||||
va_start(ap,s);
|
||||
if (preen) {
|
||||
printf("%s: ", cdevname);
|
||||
printf(s, a1, a2, a3);
|
||||
vfprintf(stdout, s, ap);
|
||||
printf("\n");
|
||||
printf("%s: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.\n",
|
||||
cdevname);
|
||||
exit(8);
|
||||
}
|
||||
printf(s, a1, a2, a3);
|
||||
vfprintf(stdout, s, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -543,24 +566,31 @@ pfatal(s, a1, a2, a3)
|
||||
* or a warning (preceded by filename) when preening.
|
||||
*/
|
||||
/* VARARGS1 */
|
||||
pwarn(s, a1, a2, a3, a4, a5, a6)
|
||||
char *s;
|
||||
void
|
||||
pwarn(const char *s, ...)
|
||||
{
|
||||
|
||||
va_list ap;
|
||||
va_start(ap,s);
|
||||
if (preen)
|
||||
printf("%s: ", cdevname);
|
||||
printf(s, a1, a2, a3, a4, a5, a6);
|
||||
vfprintf(stdout, s, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
#ifndef lint
|
||||
/*
|
||||
* Stub for routines from kernel.
|
||||
*/
|
||||
panic(s)
|
||||
char *s;
|
||||
__dead void
|
||||
#ifdef __STDC__
|
||||
panic(const char *fmt, ...)
|
||||
#else
|
||||
panic(fmt, va_alist)
|
||||
char *fmt;
|
||||
#endif
|
||||
{
|
||||
|
||||
pfatal("INTERNAL INCONSISTENCY:");
|
||||
errexit(s);
|
||||
errexit(fmt);
|
||||
}
|
||||
#endif
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -40,6 +40,7 @@ static char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 6/5/93";
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ufs/dir.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "fsck.h"
|
||||
@ -56,12 +57,20 @@ struct odirtemplate odirhead = {
|
||||
0, DIRBLKSIZ - 12, 2, ".."
|
||||
};
|
||||
|
||||
struct direct *fsck_readdir();
|
||||
struct bufarea *getdirblk();
|
||||
|
||||
static int chgino __P((struct inodesc *idesc));
|
||||
static int dircheck __P((struct inodesc *idesc, struct direct *dp));
|
||||
static int expanddir __P((struct dinode *dp, char *name));
|
||||
static void freedir __P((ino_t ino, ino_t parent));
|
||||
static struct direct * fsck_readdir __P((struct inodesc *idesc));
|
||||
static struct bufarea * getdirblk __P((daddr_t blkno, long size));
|
||||
static int lftempname __P((char *bufp, ino_t ino));
|
||||
static int mkentry __P((struct inodesc *idesc));
|
||||
|
||||
/*
|
||||
* Propagate connected state through the tree.
|
||||
*/
|
||||
void
|
||||
propagate()
|
||||
{
|
||||
register struct inoinfo **inpp, *inp;
|
||||
@ -87,6 +96,7 @@ propagate()
|
||||
/*
|
||||
* Scan each entry in a directory block.
|
||||
*/
|
||||
int
|
||||
dirscan(idesc)
|
||||
register struct inodesc *idesc;
|
||||
{
|
||||
@ -206,6 +216,7 @@ fsck_readdir(idesc)
|
||||
* Verify that a directory entry is valid.
|
||||
* This is a superset of the checks made in the kernel.
|
||||
*/
|
||||
int
|
||||
dircheck(idesc, dp)
|
||||
struct inodesc *idesc;
|
||||
register struct direct *dp;
|
||||
@ -248,6 +259,7 @@ dircheck(idesc, dp)
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
direrror(ino, errmesg)
|
||||
ino_t ino;
|
||||
char *errmesg;
|
||||
@ -256,6 +268,7 @@ direrror(ino, errmesg)
|
||||
fileerror(ino, ino, errmesg);
|
||||
}
|
||||
|
||||
void
|
||||
fileerror(cwd, ino, errmesg)
|
||||
ino_t cwd, ino;
|
||||
char *errmesg;
|
||||
@ -279,6 +292,7 @@ fileerror(cwd, ino, errmesg)
|
||||
pfatal("NAME=%s\n", pathbuf);
|
||||
}
|
||||
|
||||
void
|
||||
adjust(idesc, lcnt)
|
||||
register struct inodesc *idesc;
|
||||
short lcnt;
|
||||
@ -309,6 +323,7 @@ adjust(idesc, lcnt)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
mkentry(idesc)
|
||||
struct inodesc *idesc;
|
||||
{
|
||||
@ -345,6 +360,7 @@ mkentry(idesc)
|
||||
return (ALTERED|STOP);
|
||||
}
|
||||
|
||||
int
|
||||
chgino(idesc)
|
||||
struct inodesc *idesc;
|
||||
{
|
||||
@ -360,6 +376,7 @@ chgino(idesc)
|
||||
return (ALTERED|STOP);
|
||||
}
|
||||
|
||||
int
|
||||
linkup(orphan, parentdir)
|
||||
ino_t orphan;
|
||||
ino_t parentdir;
|
||||
@ -369,7 +386,6 @@ linkup(orphan, parentdir)
|
||||
ino_t oldlfdir;
|
||||
struct inodesc idesc;
|
||||
char tempname[BUFSIZ];
|
||||
extern int pass4check();
|
||||
|
||||
bzero((char *)&idesc, sizeof(struct inodesc));
|
||||
dp = ginode(orphan);
|
||||
@ -467,6 +483,7 @@ linkup(orphan, parentdir)
|
||||
/*
|
||||
* fix an entry in a directory.
|
||||
*/
|
||||
int
|
||||
changeino(dir, name, newnum)
|
||||
ino_t dir;
|
||||
char *name;
|
||||
@ -487,6 +504,7 @@ changeino(dir, name, newnum)
|
||||
/*
|
||||
* make an entry in a directory
|
||||
*/
|
||||
int
|
||||
makeentry(parent, ino, name)
|
||||
ino_t parent, ino;
|
||||
char *name;
|
||||
@ -522,6 +540,7 @@ makeentry(parent, ino, name)
|
||||
/*
|
||||
* Attempt to expand the size of a directory
|
||||
*/
|
||||
int
|
||||
expanddir(dp, name)
|
||||
register struct dinode *dp;
|
||||
char *name;
|
||||
@ -578,6 +597,7 @@ expanddir(dp, name)
|
||||
/*
|
||||
* allocate a new directory
|
||||
*/
|
||||
int
|
||||
allocdir(parent, request, mode)
|
||||
ino_t parent, request;
|
||||
int mode;
|
||||
@ -633,6 +653,7 @@ allocdir(parent, request, mode)
|
||||
/*
|
||||
* free a directory inode
|
||||
*/
|
||||
static void
|
||||
freedir(ino, parent)
|
||||
ino_t ino, parent;
|
||||
{
|
||||
@ -649,6 +670,7 @@ freedir(ino, parent)
|
||||
/*
|
||||
* generate a temporary name for the lost+found directory.
|
||||
*/
|
||||
int
|
||||
lftempname(bufp, ino)
|
||||
char *bufp;
|
||||
ino_t ino;
|
||||
|
@ -179,13 +179,14 @@ char havesb; /* superblock has been read */
|
||||
int fsmodified; /* 1 => write done to file system */
|
||||
int fsreadfd; /* file descriptor for reading file system */
|
||||
int fswritefd; /* file descriptor for writing file system */
|
||||
int returntosingle; /* return to single user mode */
|
||||
|
||||
daddr_t maxfsblock; /* number of blocks in the file system */
|
||||
char *blockmap; /* ptr to primary blk allocation map */
|
||||
ino_t maxino; /* number of inodes in file system */
|
||||
ino_t lastino; /* last inode in use */
|
||||
char *statemap; /* ptr to inode state table */
|
||||
char *typemap; /* ptr to inode type table */
|
||||
unsigned char *typemap; /* ptr to inode type table */
|
||||
short *lncntp; /* ptr to link count table */
|
||||
|
||||
ino_t lfdir; /* lost & found directory inode number */
|
||||
@ -208,9 +209,84 @@ struct dinode zino;
|
||||
#define ALTERED 0x08
|
||||
#define FOUND 0x10
|
||||
|
||||
time_t time();
|
||||
struct dinode *ginode();
|
||||
struct inoinfo *getinoinfo();
|
||||
void getblk();
|
||||
ino_t allocino();
|
||||
int findino();
|
||||
/* dir.c */
|
||||
void adjust __P((struct inodesc *idesc, short lcnt));
|
||||
int allocdir __P((ino_t parent, ino_t request, int mode));
|
||||
int changeino __P((ino_t dir, char *name, ino_t newnum));
|
||||
void direrror __P((ino_t ino, char *errmesg));
|
||||
int dirscan __P((struct inodesc *idesc));
|
||||
void fileerror __P((ino_t cwd, ino_t ino, char *errmesg));
|
||||
int linkup __P((ino_t orphan, ino_t parentdir));
|
||||
int makeentry __P((ino_t parent, ino_t ino, char *name));
|
||||
void propagate __P((void));
|
||||
|
||||
/* ffs_subr.c */
|
||||
void ffs_fragacct __P((struct fs *fs, int fragmap, long *fraglist, int cnt));
|
||||
|
||||
/* inode.c */
|
||||
ino_t allocino __P((ino_t request, int type));
|
||||
void blkerror __P((ino_t ino, char *type, daddr_t blk));
|
||||
void cacheino __P((struct dinode *dp, ino_t inumber));
|
||||
int chkrange __P((daddr_t blk, int cnt));
|
||||
int ckinode __P((struct dinode *dp, struct inodesc *idesc));
|
||||
void clri __P((struct inodesc *idesc, char *type, int flag));
|
||||
int findino __P((struct inodesc *idesc));
|
||||
void freeino __P((ino_t ino));
|
||||
void freeinodebuf __P((void));
|
||||
struct dinode * ginode __P((ino_t inumber));
|
||||
struct inoinfo * getinoinfo __P((ino_t inumber));
|
||||
struct dinode * getnextinode __P((ino_t inumber));
|
||||
void inodirty __P((void));
|
||||
void inocleanup __P((void));
|
||||
void pinode __P((ino_t ino));
|
||||
void resetinodebuf __P((void));
|
||||
int findname __P((struct inodesc *idesc));
|
||||
|
||||
/* pass1.c */
|
||||
void pass1 __P((void));
|
||||
int pass1check __P((struct inodesc *idesc));
|
||||
|
||||
/* pass1b.c */
|
||||
void pass1b __P((void));
|
||||
|
||||
/* pass2.c */
|
||||
void pass2 __P((void));
|
||||
|
||||
/* pass3.c */
|
||||
void pass3 __P((void));
|
||||
|
||||
/* pass4.c */
|
||||
void pass4 __P((void));
|
||||
int pass4check __P((struct inodesc *idesc));
|
||||
|
||||
/* pass5.c */
|
||||
void pass5 __P((void));
|
||||
|
||||
/* preen.c */
|
||||
char *blockcheck __P((char *name));
|
||||
int checkfstab __P((int preen, int maxrun,int (*docheck)(), int (*chkit)()));
|
||||
|
||||
/* setup.c */
|
||||
int setup __P((char *dev));
|
||||
|
||||
/* utilities.c */
|
||||
int allocblk __P((long frags));
|
||||
int bread __P((int fd, char *buf, daddr_t blk, long size));
|
||||
void bufinit __P((void));
|
||||
void bwrite __P((int fd, char *buf, daddr_t blk, long size));
|
||||
void catch __P((int));
|
||||
void catchquit __P((int));
|
||||
void ckfini __P((void));
|
||||
int dofix __P((struct inodesc *idesc, char *msg));
|
||||
__dead void errexit __P((const char *s1, ...)) __dead2;
|
||||
void flush __P((int fd, struct bufarea *bp));
|
||||
void freeblk __P((daddr_t blkno, long frags));
|
||||
int ftypeok __P((struct dinode *dp));
|
||||
void getblk __P((struct bufarea *bp, daddr_t blk, long size));
|
||||
struct bufarea * getdatablk __P((daddr_t blkno, long size));
|
||||
void getpathname __P((char *namebuf, ino_t curdir, ino_t ino));
|
||||
__dead void panic __P((const char *, ...)) __dead2;
|
||||
void pfatal __P((const char *s1, ...));
|
||||
void pwarn __P((const char *s1, ...));
|
||||
int reply __P((char *question));
|
||||
void voidquit __P((int));
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)inode.c 8.5 (Berkeley) 2/8/95";
|
||||
static const char sccsid[] = "@(#)inode.c 8.5 (Berkeley) 2/8/95";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -41,12 +41,16 @@ static char sccsid[] = "@(#)inode.c 8.5 (Berkeley) 2/8/95";
|
||||
#include <ufs/ufs/dir.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "fsck.h"
|
||||
|
||||
static ino_t startinum;
|
||||
|
||||
static int iblock __P((struct inodesc *idesc, long ilevel, quad_t isize));
|
||||
|
||||
int
|
||||
ckinode(dp, idesc)
|
||||
struct dinode *dp;
|
||||
register struct inodesc *idesc;
|
||||
@ -99,6 +103,7 @@ ckinode(dp, idesc)
|
||||
return (KEEPON);
|
||||
}
|
||||
|
||||
static int
|
||||
iblock(idesc, ilevel, isize)
|
||||
struct inodesc *idesc;
|
||||
long ilevel;
|
||||
@ -110,7 +115,6 @@ iblock(idesc, ilevel, isize)
|
||||
int i, n, (*func)(), nif;
|
||||
quad_t sizepb;
|
||||
char buf[BUFSIZ];
|
||||
extern int dirscan(), pass1check();
|
||||
|
||||
if (idesc->id_type == ADDR) {
|
||||
func = idesc->id_func;
|
||||
@ -164,6 +168,7 @@ iblock(idesc, ilevel, isize)
|
||||
* Check that a block in a legal block number.
|
||||
* Return 0 if in range, 1 if out of range.
|
||||
*/
|
||||
int
|
||||
chkrange(blk, cnt)
|
||||
daddr_t blk;
|
||||
int cnt;
|
||||
@ -253,6 +258,7 @@ getnextinode(inumber)
|
||||
return (dp++);
|
||||
}
|
||||
|
||||
void
|
||||
resetinodebuf()
|
||||
{
|
||||
|
||||
@ -278,6 +284,7 @@ resetinodebuf()
|
||||
(void)getnextinode(nextino);
|
||||
}
|
||||
|
||||
void
|
||||
freeinodebuf()
|
||||
{
|
||||
|
||||
@ -293,6 +300,7 @@ freeinodebuf()
|
||||
*
|
||||
* Enter inodes into the cache.
|
||||
*/
|
||||
void
|
||||
cacheino(dp, inumber)
|
||||
register struct dinode *dp;
|
||||
ino_t inumber;
|
||||
@ -352,6 +360,7 @@ getinoinfo(inumber)
|
||||
/*
|
||||
* Clean up all the inode cache structure.
|
||||
*/
|
||||
void
|
||||
inocleanup()
|
||||
{
|
||||
register struct inoinfo **inpp;
|
||||
@ -365,12 +374,13 @@ inocleanup()
|
||||
inphead = inpsort = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
inodirty()
|
||||
{
|
||||
|
||||
dirty(pbp);
|
||||
}
|
||||
|
||||
void
|
||||
clri(idesc, type, flag)
|
||||
register struct inodesc *idesc;
|
||||
char *type;
|
||||
@ -395,6 +405,7 @@ clri(idesc, type, flag)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
findname(idesc)
|
||||
struct inodesc *idesc;
|
||||
{
|
||||
@ -406,6 +417,7 @@ findname(idesc)
|
||||
return (STOP|FOUND);
|
||||
}
|
||||
|
||||
int
|
||||
findino(idesc)
|
||||
struct inodesc *idesc;
|
||||
{
|
||||
@ -421,6 +433,7 @@ findino(idesc)
|
||||
return (KEEPON);
|
||||
}
|
||||
|
||||
void
|
||||
pinode(ino)
|
||||
ino_t ino;
|
||||
{
|
||||
@ -446,6 +459,7 @@ pinode(ino)
|
||||
printf("MTIME=%12.12s %4.4s ", &p[4], &p[20]);
|
||||
}
|
||||
|
||||
void
|
||||
blkerror(ino, type, blk)
|
||||
ino_t ino;
|
||||
char *type;
|
||||
@ -526,11 +540,11 @@ allocino(request, type)
|
||||
/*
|
||||
* deallocate an inode
|
||||
*/
|
||||
void
|
||||
freeino(ino)
|
||||
ino_t ino;
|
||||
{
|
||||
struct inodesc idesc;
|
||||
extern int pass4check();
|
||||
struct dinode *dp;
|
||||
|
||||
bzero((char *)&idesc, sizeof(struct inodesc));
|
||||
|
@ -32,13 +32,13 @@
|
||||
*/
|
||||
|
||||
#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 */
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94";
|
||||
static const char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -49,22 +49,24 @@ static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94";
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <fstab.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include "fsck.h"
|
||||
static int argtoi __P((int flag, char *req, char *str, int base));
|
||||
static int docheck __P((struct fstab *fsp));
|
||||
static int checkfilesys __P((char *filesys, char *mntpt, long auxdata,
|
||||
int child));
|
||||
|
||||
void catch(), catchquit(), voidquit();
|
||||
int returntosingle;
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int ch;
|
||||
int ret, maxrun = 0;
|
||||
extern int docheck(), checkfilesys();
|
||||
extern char *optarg, *blockcheck();
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
sync();
|
||||
@ -135,6 +137,7 @@ main(argc, argv)
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
int
|
||||
argtoi(flag, req, str, base)
|
||||
int flag;
|
||||
char *req, *str;
|
||||
@ -152,6 +155,7 @@ argtoi(flag, req, str, base)
|
||||
/*
|
||||
* Determine whether a filesystem should be checked.
|
||||
*/
|
||||
int
|
||||
docheck(fsp)
|
||||
register struct fstab *fsp;
|
||||
{
|
||||
@ -168,9 +172,11 @@ docheck(fsp)
|
||||
* Check the specified filesystem.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
checkfilesys(filesys, mntpt, auxdata, child)
|
||||
char *filesys, *mntpt;
|
||||
long auxdata;
|
||||
int child;
|
||||
{
|
||||
daddr_t n_ffree, n_bfree;
|
||||
struct dups *dp;
|
||||
@ -255,7 +261,7 @@ checkfilesys(filesys, mntpt, auxdata, child)
|
||||
n_bfree = sblock.fs_cstotal.cs_nbfree;
|
||||
pwarn("%ld files, %ld used, %ld free ",
|
||||
n_files, n_blks, n_ffree + sblock.fs_frag * n_bfree);
|
||||
printf("(%ld frags, %ld blocks, %d.%d%% fragmentation)\n",
|
||||
printf("(%ld frags, %ld blocks, %ld.%ld%% fragmentation)\n",
|
||||
n_ffree, n_bfree, (n_ffree * 100) / sblock.fs_dsize,
|
||||
((n_ffree * 1000 + sblock.fs_dsize / 2) / sblock.fs_dsize) % 10);
|
||||
if (debug &&
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)pass1.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)pass1.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -40,15 +40,17 @@ static char sccsid[] = "@(#)pass1.c 8.1 (Berkeley) 6/5/93";
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ufs/dir.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "fsck.h"
|
||||
|
||||
static daddr_t badblk;
|
||||
static daddr_t dupblk;
|
||||
int pass1check();
|
||||
struct dinode *getnextinode();
|
||||
|
||||
static void checkinode __P((ino_t inumber, struct inodesc *idesc));
|
||||
|
||||
void
|
||||
pass1()
|
||||
{
|
||||
ino_t inumber;
|
||||
@ -87,6 +89,7 @@ pass1()
|
||||
freeinodebuf();
|
||||
}
|
||||
|
||||
void
|
||||
checkinode(inumber, idesc)
|
||||
ino_t inumber;
|
||||
register struct inodesc *idesc;
|
||||
@ -148,7 +151,7 @@ checkinode(inumber, idesc)
|
||||
errexit("cannot read symlink");
|
||||
if (debug) {
|
||||
symbuf[dp->di_size] = 0;
|
||||
printf("convert symlink %d(%s) of size %d\n",
|
||||
printf("convert symlink %ld(%s) of size %ld\n",
|
||||
inumber, symbuf, (long)dp->di_size);
|
||||
}
|
||||
dp = ginode(inumber);
|
||||
@ -247,6 +250,7 @@ checkinode(inumber, idesc)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
pass1check(idesc)
|
||||
register struct inodesc *idesc;
|
||||
{
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)pass1b.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)pass1b.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -45,6 +45,7 @@ static char sccsid[] = "@(#)pass1b.c 8.1 (Berkeley) 6/5/93";
|
||||
int pass1bcheck();
|
||||
static struct dups *duphead;
|
||||
|
||||
void
|
||||
pass1b()
|
||||
{
|
||||
register int c, i;
|
||||
@ -72,6 +73,7 @@ pass1b()
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
pass1bcheck(idesc)
|
||||
register struct inodesc *idesc;
|
||||
{
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)pass2.c 8.2 (Berkeley) 2/27/94";
|
||||
static const char sccsid[] = "@(#)pass2.c 8.2 (Berkeley) 2/27/94";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -40,6 +40,7 @@ static char sccsid[] = "@(#)pass2.c 8.2 (Berkeley) 2/27/94";
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ufs/dir.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "fsck.h"
|
||||
@ -48,6 +49,7 @@ static char sccsid[] = "@(#)pass2.c 8.2 (Berkeley) 2/27/94";
|
||||
|
||||
int pass2check(), blksort();
|
||||
|
||||
void
|
||||
pass2()
|
||||
{
|
||||
register struct dinode *dp;
|
||||
@ -189,6 +191,7 @@ pass2()
|
||||
propagate();
|
||||
}
|
||||
|
||||
int
|
||||
pass2check(idesc)
|
||||
struct inodesc *idesc;
|
||||
{
|
||||
@ -422,6 +425,7 @@ pass2check(idesc)
|
||||
/*
|
||||
* Routine to sort disk blocks.
|
||||
*/
|
||||
int
|
||||
blksort(inpp1, inpp2)
|
||||
struct inoinfo **inpp1, **inpp2;
|
||||
{
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)pass3.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)pass3.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -41,6 +41,7 @@ static char sccsid[] = "@(#)pass3.c 8.1 (Berkeley) 6/5/93";
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include "fsck.h"
|
||||
|
||||
void
|
||||
pass3()
|
||||
{
|
||||
register struct inoinfo **inpp, *inp;
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)pass4.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)pass4.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -45,6 +45,7 @@ static char sccsid[] = "@(#)pass4.c 8.1 (Berkeley) 6/5/93";
|
||||
|
||||
int pass4check();
|
||||
|
||||
void
|
||||
pass4()
|
||||
{
|
||||
register ino_t inumber;
|
||||
@ -103,6 +104,7 @@ pass4()
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
pass4check(idesc)
|
||||
register struct inodesc *idesc;
|
||||
{
|
||||
|
@ -32,19 +32,21 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)pass5.c 8.2 (Berkeley) 2/2/94";
|
||||
static const char sccsid[] = "@(#)pass5.c 8.2 (Berkeley) 2/2/94";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "fsck.h"
|
||||
|
||||
void
|
||||
pass5()
|
||||
{
|
||||
int c, blk, frags, basesize, sumsize, mapsize, savednrpos;
|
||||
int c, blk, frags, basesize, sumsize, mapsize, savednrpos = 0;
|
||||
register struct fs *fs = &sblock;
|
||||
register struct cg *cg = &cgrp;
|
||||
daddr_t dbase, dmax;
|
||||
|
@ -32,19 +32,20 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)preen.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)preen.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <fstab.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
char *rawname(), *unrawname(), *blockcheck();
|
||||
#include "fsck.h"
|
||||
|
||||
struct part {
|
||||
struct part *next; /* forward link of partitions on disk */
|
||||
@ -60,9 +61,16 @@ struct disk {
|
||||
int pid; /* If != 0, pid of proc working on */
|
||||
} *disks;
|
||||
|
||||
static void addpart __P((char *name, char *fsname, long auxdata));
|
||||
static int startdisk __P((struct disk *dk, int (*checkit)()));
|
||||
static struct disk *finddisk __P((char *name));
|
||||
static char *unrawname __P((char *name));
|
||||
static char *rawname __P((char *name));
|
||||
|
||||
int nrun, ndisks;
|
||||
char hotroot;
|
||||
|
||||
int
|
||||
checkfstab(preen, maxrun, docheck, chkit)
|
||||
int preen, maxrun;
|
||||
int (*docheck)(), (*chkit)();
|
||||
@ -84,10 +92,12 @@ checkfstab(preen, maxrun, docheck, chkit)
|
||||
while ((fsp = getfsent()) != 0) {
|
||||
if ((auxdata = (*docheck)(fsp)) == 0)
|
||||
continue;
|
||||
if (preen == 0 || passno == 1 && fsp->fs_passno == 1) {
|
||||
if (name = blockcheck(fsp->fs_spec)) {
|
||||
if (sumstatus = (*chkit)(name,
|
||||
fsp->fs_file, auxdata, 0))
|
||||
if (!preen || (passno == 1 && fsp->fs_passno == 1)) {
|
||||
name = blockcheck(fsp->fs_spec);
|
||||
if (name) {
|
||||
sumstatus = (*chkit)(name,
|
||||
fsp->fs_file, auxdata, 0);
|
||||
if (sumstatus)
|
||||
return (sumstatus);
|
||||
} else if (preen)
|
||||
return (8);
|
||||
@ -111,7 +121,8 @@ checkfstab(preen, maxrun, docheck, chkit)
|
||||
maxrun = ndisks;
|
||||
nextdisk = disks;
|
||||
for (passno = 0; passno < maxrun; ++passno) {
|
||||
while (ret = startdisk(nextdisk, chkit) && nrun > 0)
|
||||
while ((ret = startdisk(nextdisk, chkit)) != 0 &&
|
||||
nrun > 0)
|
||||
sleep(10);
|
||||
if (ret)
|
||||
return (ret);
|
||||
@ -150,8 +161,8 @@ checkfstab(preen, maxrun, docheck, chkit)
|
||||
|
||||
if (nextdisk == NULL) {
|
||||
if (dk->part) {
|
||||
while (ret = startdisk(dk, chkit) &&
|
||||
nrun > 0)
|
||||
while ((ret = startdisk(dk, chkit)) != 0
|
||||
&& nrun > 0)
|
||||
sleep(10);
|
||||
if (ret)
|
||||
return (ret);
|
||||
@ -164,8 +175,8 @@ checkfstab(preen, maxrun, docheck, chkit)
|
||||
nextdisk->pid == 0)
|
||||
break;
|
||||
}
|
||||
while (ret = startdisk(nextdisk, chkit) &&
|
||||
nrun > 0)
|
||||
while ((ret = startdisk(nextdisk, chkit)) != 0
|
||||
&& nrun > 0)
|
||||
sleep(10);
|
||||
if (ret)
|
||||
return (ret);
|
||||
@ -192,7 +203,7 @@ finddisk(name)
|
||||
{
|
||||
register struct disk *dk, **dkp;
|
||||
register char *p;
|
||||
size_t len;
|
||||
size_t len = 0;
|
||||
|
||||
for (p = name + strlen(name) - 1; p >= name; --p)
|
||||
if (isdigit(*p)) {
|
||||
@ -225,6 +236,7 @@ finddisk(name)
|
||||
return (dk);
|
||||
}
|
||||
|
||||
void
|
||||
addpart(name, fsname, auxdata)
|
||||
char *name, *fsname;
|
||||
long auxdata;
|
||||
@ -256,6 +268,7 @@ addpart(name, fsname, auxdata)
|
||||
pt->auxdata = auxdata;
|
||||
}
|
||||
|
||||
int
|
||||
startdisk(dk, checkit)
|
||||
register struct disk *dk;
|
||||
int (*checkit)();
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)setup.c 8.2 (Berkeley) 2/21/94";
|
||||
static const char sccsid[] = "@(#)setup.c 8.2 (Berkeley) 2/21/94";
|
||||
#endif /* not lint */
|
||||
|
||||
#define DKTYPENAMES
|
||||
@ -45,6 +45,7 @@ static char sccsid[] = "@(#)setup.c 8.2 (Berkeley) 2/21/94";
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/file.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
@ -54,8 +55,13 @@ struct bufarea asblk;
|
||||
#define altsblock (*asblk.b_un.b_fs)
|
||||
#define POWEROF2(num) (((num) & ((num) - 1)) == 0)
|
||||
|
||||
struct disklabel *getdisklabel();
|
||||
static int readsb __P((int listerr));
|
||||
static void badsb __P((int listerr, char *s));
|
||||
static int calcsb __P((char *dev, int devfd, struct fs *fs));
|
||||
static struct disklabel * getdisklabel __P((char *s, int fd));
|
||||
|
||||
|
||||
int
|
||||
setup(dev)
|
||||
char *dev;
|
||||
{
|
||||
@ -99,7 +105,8 @@ 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))
|
||||
lp = getdisklabel((char *)NULL, fsreadfd);
|
||||
if (lp)
|
||||
dev_bsize = secsize = lp->d_secsize;
|
||||
else
|
||||
dev_bsize = secsize = DEV_BSIZE;
|
||||
@ -297,6 +304,7 @@ setup(dev)
|
||||
/*
|
||||
* Read in the super block and its summary info.
|
||||
*/
|
||||
static int
|
||||
readsb(listerr)
|
||||
int listerr;
|
||||
{
|
||||
@ -380,6 +388,7 @@ readsb(listerr)
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
badsb(listerr, s)
|
||||
int listerr;
|
||||
char *s;
|
||||
@ -398,6 +407,7 @@ badsb(listerr, s)
|
||||
* can be used. Do NOT attempt to use other macros without verifying that
|
||||
* their needed information is available!
|
||||
*/
|
||||
int
|
||||
calcsb(dev, devfd, fs)
|
||||
char *dev;
|
||||
int devfd;
|
||||
@ -409,7 +419,7 @@ calcsb(dev, devfd, fs)
|
||||
int i;
|
||||
|
||||
cp = index(dev, '\0') - 1;
|
||||
if (cp == (char *)-1 || (*cp < 'a' || *cp > 'h') && !isdigit(*cp)) {
|
||||
if (cp == (char *)-1 || ((*cp < 'a' || *cp > 'h') && !isdigit(*cp))) {
|
||||
pfatal("%s: CANNOT FIGURE OUT FILE SYSTEM PARTITION\n", dev);
|
||||
return (0);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)utilities.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)utilities.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -42,12 +42,17 @@ static char sccsid[] = "@(#)utilities.c 8.1 (Berkeley) 6/5/93";
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "fsck.h"
|
||||
|
||||
long diskreads, totalreads; /* Disk cache statistics */
|
||||
|
||||
static void rwerror __P((char *mesg, daddr_t blk));
|
||||
|
||||
int
|
||||
ftypeok(dp)
|
||||
struct dinode *dp;
|
||||
{
|
||||
@ -69,6 +74,7 @@ ftypeok(dp)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
reply(question)
|
||||
char *question;
|
||||
{
|
||||
@ -104,6 +110,7 @@ reply(question)
|
||||
/*
|
||||
* Malloc buffers and set up cache.
|
||||
*/
|
||||
void
|
||||
bufinit()
|
||||
{
|
||||
register struct bufarea *bp;
|
||||
@ -188,6 +195,7 @@ getblk(bp, blk, size)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
flush(fd, bp)
|
||||
int fd;
|
||||
register struct bufarea *bp;
|
||||
@ -213,6 +221,7 @@ flush(fd, bp)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rwerror(mesg, blk)
|
||||
char *mesg;
|
||||
daddr_t blk;
|
||||
@ -225,6 +234,7 @@ rwerror(mesg, blk)
|
||||
errexit("Program terminated\n");
|
||||
}
|
||||
|
||||
void
|
||||
ckfini()
|
||||
{
|
||||
register struct bufarea *bp, *nbp;
|
||||
@ -260,6 +270,7 @@ ckfini()
|
||||
(void)close(fswritefd);
|
||||
}
|
||||
|
||||
int
|
||||
bread(fd, buf, blk, size)
|
||||
int fd;
|
||||
char *buf;
|
||||
@ -298,6 +309,7 @@ bread(fd, buf, blk, size)
|
||||
return (errs);
|
||||
}
|
||||
|
||||
void
|
||||
bwrite(fd, buf, blk, size)
|
||||
int fd;
|
||||
char *buf;
|
||||
@ -334,6 +346,7 @@ bwrite(fd, buf, blk, size)
|
||||
/*
|
||||
* allocate a data block with the specified number of fragments
|
||||
*/
|
||||
int
|
||||
allocblk(frags)
|
||||
long frags;
|
||||
{
|
||||
@ -364,6 +377,7 @@ allocblk(frags)
|
||||
/*
|
||||
* Free a previously allocated block
|
||||
*/
|
||||
void
|
||||
freeblk(blkno, frags)
|
||||
daddr_t blkno;
|
||||
long frags;
|
||||
@ -378,6 +392,7 @@ freeblk(blkno, frags)
|
||||
/*
|
||||
* Find a pathname
|
||||
*/
|
||||
void
|
||||
getpathname(namebuf, curdir, ino)
|
||||
char *namebuf;
|
||||
ino_t curdir, ino;
|
||||
@ -386,7 +401,6 @@ getpathname(namebuf, curdir, ino)
|
||||
register char *cp;
|
||||
struct inodesc idesc;
|
||||
static int busy = 0;
|
||||
extern int findname();
|
||||
|
||||
if (curdir == ino && ino == ROOTINO) {
|
||||
(void)strcpy(namebuf, "/");
|
||||
@ -435,7 +449,8 @@ getpathname(namebuf, curdir, ino)
|
||||
}
|
||||
|
||||
void
|
||||
catch()
|
||||
catch(x)
|
||||
int x;
|
||||
{
|
||||
if (!doinglevel2)
|
||||
ckfini();
|
||||
@ -448,10 +463,9 @@ catch()
|
||||
* so that reboot sequence may be interrupted.
|
||||
*/
|
||||
void
|
||||
catchquit()
|
||||
catchquit(x)
|
||||
int x;
|
||||
{
|
||||
extern returntosingle;
|
||||
|
||||
printf("returning to single-user after filesystem check\n");
|
||||
returntosingle = 1;
|
||||
(void)signal(SIGQUIT, SIG_DFL);
|
||||
@ -462,7 +476,8 @@ catchquit()
|
||||
* Used by child processes in preen.
|
||||
*/
|
||||
void
|
||||
voidquit()
|
||||
voidquit(x)
|
||||
int x;
|
||||
{
|
||||
|
||||
sleep(1);
|
||||
@ -473,6 +488,7 @@ voidquit()
|
||||
/*
|
||||
* determine whether an inode should be fixed.
|
||||
*/
|
||||
int
|
||||
dofix(idesc, msg)
|
||||
register struct inodesc *idesc;
|
||||
char *msg;
|
||||
@ -506,15 +522,19 @@ dofix(idesc, msg)
|
||||
|
||||
default:
|
||||
errexit("UNKNOWN INODESC FIX MODE %d\n", idesc->id_fix);
|
||||
return (0);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/* VARARGS1 */
|
||||
errexit(s1, s2, s3, s4)
|
||||
char *s1;
|
||||
__dead void
|
||||
errexit(const char *s1, ...)
|
||||
{
|
||||
printf(s1, s2, s3, s4);
|
||||
va_list ap;
|
||||
va_start(ap,s1);
|
||||
vfprintf(stdout, s1, ap);
|
||||
va_end(ap);
|
||||
exit(8);
|
||||
}
|
||||
|
||||
@ -523,19 +543,22 @@ errexit(s1, s2, s3, s4)
|
||||
* Die if preening, otherwise just print message and continue.
|
||||
*/
|
||||
/* VARARGS1 */
|
||||
pfatal(s, a1, a2, a3)
|
||||
char *s;
|
||||
void
|
||||
pfatal(const char *s, ...)
|
||||
{
|
||||
|
||||
va_list ap;
|
||||
va_start(ap,s);
|
||||
if (preen) {
|
||||
printf("%s: ", cdevname);
|
||||
printf(s, a1, a2, a3);
|
||||
vfprintf(stdout, s, ap);
|
||||
printf("\n");
|
||||
printf("%s: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.\n",
|
||||
cdevname);
|
||||
exit(8);
|
||||
}
|
||||
printf(s, a1, a2, a3);
|
||||
vfprintf(stdout, s, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -543,24 +566,31 @@ pfatal(s, a1, a2, a3)
|
||||
* or a warning (preceded by filename) when preening.
|
||||
*/
|
||||
/* VARARGS1 */
|
||||
pwarn(s, a1, a2, a3, a4, a5, a6)
|
||||
char *s;
|
||||
void
|
||||
pwarn(const char *s, ...)
|
||||
{
|
||||
|
||||
va_list ap;
|
||||
va_start(ap,s);
|
||||
if (preen)
|
||||
printf("%s: ", cdevname);
|
||||
printf(s, a1, a2, a3, a4, a5, a6);
|
||||
vfprintf(stdout, s, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
#ifndef lint
|
||||
/*
|
||||
* Stub for routines from kernel.
|
||||
*/
|
||||
panic(s)
|
||||
char *s;
|
||||
__dead void
|
||||
#ifdef __STDC__
|
||||
panic(const char *fmt, ...)
|
||||
#else
|
||||
panic(fmt, va_alist)
|
||||
char *fmt;
|
||||
#endif
|
||||
{
|
||||
|
||||
pfatal("INTERNAL INCONSISTENCY:");
|
||||
errexit(s);
|
||||
errexit(fmt);
|
||||
}
|
||||
#endif
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -40,6 +40,7 @@ static char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 6/5/93";
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ufs/dir.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "fsck.h"
|
||||
@ -56,12 +57,20 @@ struct odirtemplate odirhead = {
|
||||
0, DIRBLKSIZ - 12, 2, ".."
|
||||
};
|
||||
|
||||
struct direct *fsck_readdir();
|
||||
struct bufarea *getdirblk();
|
||||
|
||||
static int chgino __P((struct inodesc *idesc));
|
||||
static int dircheck __P((struct inodesc *idesc, struct direct *dp));
|
||||
static int expanddir __P((struct dinode *dp, char *name));
|
||||
static void freedir __P((ino_t ino, ino_t parent));
|
||||
static struct direct * fsck_readdir __P((struct inodesc *idesc));
|
||||
static struct bufarea * getdirblk __P((daddr_t blkno, long size));
|
||||
static int lftempname __P((char *bufp, ino_t ino));
|
||||
static int mkentry __P((struct inodesc *idesc));
|
||||
|
||||
/*
|
||||
* Propagate connected state through the tree.
|
||||
*/
|
||||
void
|
||||
propagate()
|
||||
{
|
||||
register struct inoinfo **inpp, *inp;
|
||||
@ -87,6 +96,7 @@ propagate()
|
||||
/*
|
||||
* Scan each entry in a directory block.
|
||||
*/
|
||||
int
|
||||
dirscan(idesc)
|
||||
register struct inodesc *idesc;
|
||||
{
|
||||
@ -206,6 +216,7 @@ fsck_readdir(idesc)
|
||||
* Verify that a directory entry is valid.
|
||||
* This is a superset of the checks made in the kernel.
|
||||
*/
|
||||
int
|
||||
dircheck(idesc, dp)
|
||||
struct inodesc *idesc;
|
||||
register struct direct *dp;
|
||||
@ -248,6 +259,7 @@ dircheck(idesc, dp)
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
direrror(ino, errmesg)
|
||||
ino_t ino;
|
||||
char *errmesg;
|
||||
@ -256,6 +268,7 @@ direrror(ino, errmesg)
|
||||
fileerror(ino, ino, errmesg);
|
||||
}
|
||||
|
||||
void
|
||||
fileerror(cwd, ino, errmesg)
|
||||
ino_t cwd, ino;
|
||||
char *errmesg;
|
||||
@ -279,6 +292,7 @@ fileerror(cwd, ino, errmesg)
|
||||
pfatal("NAME=%s\n", pathbuf);
|
||||
}
|
||||
|
||||
void
|
||||
adjust(idesc, lcnt)
|
||||
register struct inodesc *idesc;
|
||||
short lcnt;
|
||||
@ -309,6 +323,7 @@ adjust(idesc, lcnt)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
mkentry(idesc)
|
||||
struct inodesc *idesc;
|
||||
{
|
||||
@ -345,6 +360,7 @@ mkentry(idesc)
|
||||
return (ALTERED|STOP);
|
||||
}
|
||||
|
||||
int
|
||||
chgino(idesc)
|
||||
struct inodesc *idesc;
|
||||
{
|
||||
@ -360,6 +376,7 @@ chgino(idesc)
|
||||
return (ALTERED|STOP);
|
||||
}
|
||||
|
||||
int
|
||||
linkup(orphan, parentdir)
|
||||
ino_t orphan;
|
||||
ino_t parentdir;
|
||||
@ -369,7 +386,6 @@ linkup(orphan, parentdir)
|
||||
ino_t oldlfdir;
|
||||
struct inodesc idesc;
|
||||
char tempname[BUFSIZ];
|
||||
extern int pass4check();
|
||||
|
||||
bzero((char *)&idesc, sizeof(struct inodesc));
|
||||
dp = ginode(orphan);
|
||||
@ -467,6 +483,7 @@ linkup(orphan, parentdir)
|
||||
/*
|
||||
* fix an entry in a directory.
|
||||
*/
|
||||
int
|
||||
changeino(dir, name, newnum)
|
||||
ino_t dir;
|
||||
char *name;
|
||||
@ -487,6 +504,7 @@ changeino(dir, name, newnum)
|
||||
/*
|
||||
* make an entry in a directory
|
||||
*/
|
||||
int
|
||||
makeentry(parent, ino, name)
|
||||
ino_t parent, ino;
|
||||
char *name;
|
||||
@ -522,6 +540,7 @@ makeentry(parent, ino, name)
|
||||
/*
|
||||
* Attempt to expand the size of a directory
|
||||
*/
|
||||
int
|
||||
expanddir(dp, name)
|
||||
register struct dinode *dp;
|
||||
char *name;
|
||||
@ -578,6 +597,7 @@ expanddir(dp, name)
|
||||
/*
|
||||
* allocate a new directory
|
||||
*/
|
||||
int
|
||||
allocdir(parent, request, mode)
|
||||
ino_t parent, request;
|
||||
int mode;
|
||||
@ -633,6 +653,7 @@ allocdir(parent, request, mode)
|
||||
/*
|
||||
* free a directory inode
|
||||
*/
|
||||
static void
|
||||
freedir(ino, parent)
|
||||
ino_t ino, parent;
|
||||
{
|
||||
@ -649,6 +670,7 @@ freedir(ino, parent)
|
||||
/*
|
||||
* generate a temporary name for the lost+found directory.
|
||||
*/
|
||||
int
|
||||
lftempname(bufp, ino)
|
||||
char *bufp;
|
||||
ino_t ino;
|
||||
|
@ -179,13 +179,14 @@ char havesb; /* superblock has been read */
|
||||
int fsmodified; /* 1 => write done to file system */
|
||||
int fsreadfd; /* file descriptor for reading file system */
|
||||
int fswritefd; /* file descriptor for writing file system */
|
||||
int returntosingle; /* return to single user mode */
|
||||
|
||||
daddr_t maxfsblock; /* number of blocks in the file system */
|
||||
char *blockmap; /* ptr to primary blk allocation map */
|
||||
ino_t maxino; /* number of inodes in file system */
|
||||
ino_t lastino; /* last inode in use */
|
||||
char *statemap; /* ptr to inode state table */
|
||||
char *typemap; /* ptr to inode type table */
|
||||
unsigned char *typemap; /* ptr to inode type table */
|
||||
short *lncntp; /* ptr to link count table */
|
||||
|
||||
ino_t lfdir; /* lost & found directory inode number */
|
||||
@ -208,9 +209,84 @@ struct dinode zino;
|
||||
#define ALTERED 0x08
|
||||
#define FOUND 0x10
|
||||
|
||||
time_t time();
|
||||
struct dinode *ginode();
|
||||
struct inoinfo *getinoinfo();
|
||||
void getblk();
|
||||
ino_t allocino();
|
||||
int findino();
|
||||
/* dir.c */
|
||||
void adjust __P((struct inodesc *idesc, short lcnt));
|
||||
int allocdir __P((ino_t parent, ino_t request, int mode));
|
||||
int changeino __P((ino_t dir, char *name, ino_t newnum));
|
||||
void direrror __P((ino_t ino, char *errmesg));
|
||||
int dirscan __P((struct inodesc *idesc));
|
||||
void fileerror __P((ino_t cwd, ino_t ino, char *errmesg));
|
||||
int linkup __P((ino_t orphan, ino_t parentdir));
|
||||
int makeentry __P((ino_t parent, ino_t ino, char *name));
|
||||
void propagate __P((void));
|
||||
|
||||
/* ffs_subr.c */
|
||||
void ffs_fragacct __P((struct fs *fs, int fragmap, long *fraglist, int cnt));
|
||||
|
||||
/* inode.c */
|
||||
ino_t allocino __P((ino_t request, int type));
|
||||
void blkerror __P((ino_t ino, char *type, daddr_t blk));
|
||||
void cacheino __P((struct dinode *dp, ino_t inumber));
|
||||
int chkrange __P((daddr_t blk, int cnt));
|
||||
int ckinode __P((struct dinode *dp, struct inodesc *idesc));
|
||||
void clri __P((struct inodesc *idesc, char *type, int flag));
|
||||
int findino __P((struct inodesc *idesc));
|
||||
void freeino __P((ino_t ino));
|
||||
void freeinodebuf __P((void));
|
||||
struct dinode * ginode __P((ino_t inumber));
|
||||
struct inoinfo * getinoinfo __P((ino_t inumber));
|
||||
struct dinode * getnextinode __P((ino_t inumber));
|
||||
void inodirty __P((void));
|
||||
void inocleanup __P((void));
|
||||
void pinode __P((ino_t ino));
|
||||
void resetinodebuf __P((void));
|
||||
int findname __P((struct inodesc *idesc));
|
||||
|
||||
/* pass1.c */
|
||||
void pass1 __P((void));
|
||||
int pass1check __P((struct inodesc *idesc));
|
||||
|
||||
/* pass1b.c */
|
||||
void pass1b __P((void));
|
||||
|
||||
/* pass2.c */
|
||||
void pass2 __P((void));
|
||||
|
||||
/* pass3.c */
|
||||
void pass3 __P((void));
|
||||
|
||||
/* pass4.c */
|
||||
void pass4 __P((void));
|
||||
int pass4check __P((struct inodesc *idesc));
|
||||
|
||||
/* pass5.c */
|
||||
void pass5 __P((void));
|
||||
|
||||
/* preen.c */
|
||||
char *blockcheck __P((char *name));
|
||||
int checkfstab __P((int preen, int maxrun,int (*docheck)(), int (*chkit)()));
|
||||
|
||||
/* setup.c */
|
||||
int setup __P((char *dev));
|
||||
|
||||
/* utilities.c */
|
||||
int allocblk __P((long frags));
|
||||
int bread __P((int fd, char *buf, daddr_t blk, long size));
|
||||
void bufinit __P((void));
|
||||
void bwrite __P((int fd, char *buf, daddr_t blk, long size));
|
||||
void catch __P((int));
|
||||
void catchquit __P((int));
|
||||
void ckfini __P((void));
|
||||
int dofix __P((struct inodesc *idesc, char *msg));
|
||||
__dead void errexit __P((const char *s1, ...)) __dead2;
|
||||
void flush __P((int fd, struct bufarea *bp));
|
||||
void freeblk __P((daddr_t blkno, long frags));
|
||||
int ftypeok __P((struct dinode *dp));
|
||||
void getblk __P((struct bufarea *bp, daddr_t blk, long size));
|
||||
struct bufarea * getdatablk __P((daddr_t blkno, long size));
|
||||
void getpathname __P((char *namebuf, ino_t curdir, ino_t ino));
|
||||
__dead void panic __P((const char *, ...)) __dead2;
|
||||
void pfatal __P((const char *s1, ...));
|
||||
void pwarn __P((const char *s1, ...));
|
||||
int reply __P((char *question));
|
||||
void voidquit __P((int));
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)inode.c 8.5 (Berkeley) 2/8/95";
|
||||
static const char sccsid[] = "@(#)inode.c 8.5 (Berkeley) 2/8/95";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -41,12 +41,16 @@ static char sccsid[] = "@(#)inode.c 8.5 (Berkeley) 2/8/95";
|
||||
#include <ufs/ufs/dir.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "fsck.h"
|
||||
|
||||
static ino_t startinum;
|
||||
|
||||
static int iblock __P((struct inodesc *idesc, long ilevel, quad_t isize));
|
||||
|
||||
int
|
||||
ckinode(dp, idesc)
|
||||
struct dinode *dp;
|
||||
register struct inodesc *idesc;
|
||||
@ -99,6 +103,7 @@ ckinode(dp, idesc)
|
||||
return (KEEPON);
|
||||
}
|
||||
|
||||
static int
|
||||
iblock(idesc, ilevel, isize)
|
||||
struct inodesc *idesc;
|
||||
long ilevel;
|
||||
@ -110,7 +115,6 @@ iblock(idesc, ilevel, isize)
|
||||
int i, n, (*func)(), nif;
|
||||
quad_t sizepb;
|
||||
char buf[BUFSIZ];
|
||||
extern int dirscan(), pass1check();
|
||||
|
||||
if (idesc->id_type == ADDR) {
|
||||
func = idesc->id_func;
|
||||
@ -164,6 +168,7 @@ iblock(idesc, ilevel, isize)
|
||||
* Check that a block in a legal block number.
|
||||
* Return 0 if in range, 1 if out of range.
|
||||
*/
|
||||
int
|
||||
chkrange(blk, cnt)
|
||||
daddr_t blk;
|
||||
int cnt;
|
||||
@ -253,6 +258,7 @@ getnextinode(inumber)
|
||||
return (dp++);
|
||||
}
|
||||
|
||||
void
|
||||
resetinodebuf()
|
||||
{
|
||||
|
||||
@ -278,6 +284,7 @@ resetinodebuf()
|
||||
(void)getnextinode(nextino);
|
||||
}
|
||||
|
||||
void
|
||||
freeinodebuf()
|
||||
{
|
||||
|
||||
@ -293,6 +300,7 @@ freeinodebuf()
|
||||
*
|
||||
* Enter inodes into the cache.
|
||||
*/
|
||||
void
|
||||
cacheino(dp, inumber)
|
||||
register struct dinode *dp;
|
||||
ino_t inumber;
|
||||
@ -352,6 +360,7 @@ getinoinfo(inumber)
|
||||
/*
|
||||
* Clean up all the inode cache structure.
|
||||
*/
|
||||
void
|
||||
inocleanup()
|
||||
{
|
||||
register struct inoinfo **inpp;
|
||||
@ -365,12 +374,13 @@ inocleanup()
|
||||
inphead = inpsort = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
inodirty()
|
||||
{
|
||||
|
||||
dirty(pbp);
|
||||
}
|
||||
|
||||
void
|
||||
clri(idesc, type, flag)
|
||||
register struct inodesc *idesc;
|
||||
char *type;
|
||||
@ -395,6 +405,7 @@ clri(idesc, type, flag)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
findname(idesc)
|
||||
struct inodesc *idesc;
|
||||
{
|
||||
@ -406,6 +417,7 @@ findname(idesc)
|
||||
return (STOP|FOUND);
|
||||
}
|
||||
|
||||
int
|
||||
findino(idesc)
|
||||
struct inodesc *idesc;
|
||||
{
|
||||
@ -421,6 +433,7 @@ findino(idesc)
|
||||
return (KEEPON);
|
||||
}
|
||||
|
||||
void
|
||||
pinode(ino)
|
||||
ino_t ino;
|
||||
{
|
||||
@ -446,6 +459,7 @@ pinode(ino)
|
||||
printf("MTIME=%12.12s %4.4s ", &p[4], &p[20]);
|
||||
}
|
||||
|
||||
void
|
||||
blkerror(ino, type, blk)
|
||||
ino_t ino;
|
||||
char *type;
|
||||
@ -526,11 +540,11 @@ allocino(request, type)
|
||||
/*
|
||||
* deallocate an inode
|
||||
*/
|
||||
void
|
||||
freeino(ino)
|
||||
ino_t ino;
|
||||
{
|
||||
struct inodesc idesc;
|
||||
extern int pass4check();
|
||||
struct dinode *dp;
|
||||
|
||||
bzero((char *)&idesc, sizeof(struct inodesc));
|
||||
|
@ -32,13 +32,13 @@
|
||||
*/
|
||||
|
||||
#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 */
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94";
|
||||
static const char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -49,22 +49,24 @@ static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94";
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <fstab.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include "fsck.h"
|
||||
static int argtoi __P((int flag, char *req, char *str, int base));
|
||||
static int docheck __P((struct fstab *fsp));
|
||||
static int checkfilesys __P((char *filesys, char *mntpt, long auxdata,
|
||||
int child));
|
||||
|
||||
void catch(), catchquit(), voidquit();
|
||||
int returntosingle;
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int ch;
|
||||
int ret, maxrun = 0;
|
||||
extern int docheck(), checkfilesys();
|
||||
extern char *optarg, *blockcheck();
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
sync();
|
||||
@ -135,6 +137,7 @@ main(argc, argv)
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
int
|
||||
argtoi(flag, req, str, base)
|
||||
int flag;
|
||||
char *req, *str;
|
||||
@ -152,6 +155,7 @@ argtoi(flag, req, str, base)
|
||||
/*
|
||||
* Determine whether a filesystem should be checked.
|
||||
*/
|
||||
int
|
||||
docheck(fsp)
|
||||
register struct fstab *fsp;
|
||||
{
|
||||
@ -168,9 +172,11 @@ docheck(fsp)
|
||||
* Check the specified filesystem.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
checkfilesys(filesys, mntpt, auxdata, child)
|
||||
char *filesys, *mntpt;
|
||||
long auxdata;
|
||||
int child;
|
||||
{
|
||||
daddr_t n_ffree, n_bfree;
|
||||
struct dups *dp;
|
||||
@ -255,7 +261,7 @@ checkfilesys(filesys, mntpt, auxdata, child)
|
||||
n_bfree = sblock.fs_cstotal.cs_nbfree;
|
||||
pwarn("%ld files, %ld used, %ld free ",
|
||||
n_files, n_blks, n_ffree + sblock.fs_frag * n_bfree);
|
||||
printf("(%ld frags, %ld blocks, %d.%d%% fragmentation)\n",
|
||||
printf("(%ld frags, %ld blocks, %ld.%ld%% fragmentation)\n",
|
||||
n_ffree, n_bfree, (n_ffree * 100) / sblock.fs_dsize,
|
||||
((n_ffree * 1000 + sblock.fs_dsize / 2) / sblock.fs_dsize) % 10);
|
||||
if (debug &&
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)pass1.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)pass1.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -40,15 +40,17 @@ static char sccsid[] = "@(#)pass1.c 8.1 (Berkeley) 6/5/93";
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ufs/dir.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "fsck.h"
|
||||
|
||||
static daddr_t badblk;
|
||||
static daddr_t dupblk;
|
||||
int pass1check();
|
||||
struct dinode *getnextinode();
|
||||
|
||||
static void checkinode __P((ino_t inumber, struct inodesc *idesc));
|
||||
|
||||
void
|
||||
pass1()
|
||||
{
|
||||
ino_t inumber;
|
||||
@ -87,6 +89,7 @@ pass1()
|
||||
freeinodebuf();
|
||||
}
|
||||
|
||||
void
|
||||
checkinode(inumber, idesc)
|
||||
ino_t inumber;
|
||||
register struct inodesc *idesc;
|
||||
@ -148,7 +151,7 @@ checkinode(inumber, idesc)
|
||||
errexit("cannot read symlink");
|
||||
if (debug) {
|
||||
symbuf[dp->di_size] = 0;
|
||||
printf("convert symlink %d(%s) of size %d\n",
|
||||
printf("convert symlink %ld(%s) of size %ld\n",
|
||||
inumber, symbuf, (long)dp->di_size);
|
||||
}
|
||||
dp = ginode(inumber);
|
||||
@ -247,6 +250,7 @@ checkinode(inumber, idesc)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
pass1check(idesc)
|
||||
register struct inodesc *idesc;
|
||||
{
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)pass1b.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)pass1b.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -45,6 +45,7 @@ static char sccsid[] = "@(#)pass1b.c 8.1 (Berkeley) 6/5/93";
|
||||
int pass1bcheck();
|
||||
static struct dups *duphead;
|
||||
|
||||
void
|
||||
pass1b()
|
||||
{
|
||||
register int c, i;
|
||||
@ -72,6 +73,7 @@ pass1b()
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
pass1bcheck(idesc)
|
||||
register struct inodesc *idesc;
|
||||
{
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)pass2.c 8.2 (Berkeley) 2/27/94";
|
||||
static const char sccsid[] = "@(#)pass2.c 8.2 (Berkeley) 2/27/94";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -40,6 +40,7 @@ static char sccsid[] = "@(#)pass2.c 8.2 (Berkeley) 2/27/94";
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ufs/dir.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "fsck.h"
|
||||
@ -48,6 +49,7 @@ static char sccsid[] = "@(#)pass2.c 8.2 (Berkeley) 2/27/94";
|
||||
|
||||
int pass2check(), blksort();
|
||||
|
||||
void
|
||||
pass2()
|
||||
{
|
||||
register struct dinode *dp;
|
||||
@ -189,6 +191,7 @@ pass2()
|
||||
propagate();
|
||||
}
|
||||
|
||||
int
|
||||
pass2check(idesc)
|
||||
struct inodesc *idesc;
|
||||
{
|
||||
@ -422,6 +425,7 @@ pass2check(idesc)
|
||||
/*
|
||||
* Routine to sort disk blocks.
|
||||
*/
|
||||
int
|
||||
blksort(inpp1, inpp2)
|
||||
struct inoinfo **inpp1, **inpp2;
|
||||
{
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)pass3.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)pass3.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -41,6 +41,7 @@ static char sccsid[] = "@(#)pass3.c 8.1 (Berkeley) 6/5/93";
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include "fsck.h"
|
||||
|
||||
void
|
||||
pass3()
|
||||
{
|
||||
register struct inoinfo **inpp, *inp;
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)pass4.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)pass4.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -45,6 +45,7 @@ static char sccsid[] = "@(#)pass4.c 8.1 (Berkeley) 6/5/93";
|
||||
|
||||
int pass4check();
|
||||
|
||||
void
|
||||
pass4()
|
||||
{
|
||||
register ino_t inumber;
|
||||
@ -103,6 +104,7 @@ pass4()
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
pass4check(idesc)
|
||||
register struct inodesc *idesc;
|
||||
{
|
||||
|
@ -32,19 +32,21 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)pass5.c 8.2 (Berkeley) 2/2/94";
|
||||
static const char sccsid[] = "@(#)pass5.c 8.2 (Berkeley) 2/2/94";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "fsck.h"
|
||||
|
||||
void
|
||||
pass5()
|
||||
{
|
||||
int c, blk, frags, basesize, sumsize, mapsize, savednrpos;
|
||||
int c, blk, frags, basesize, sumsize, mapsize, savednrpos = 0;
|
||||
register struct fs *fs = &sblock;
|
||||
register struct cg *cg = &cgrp;
|
||||
daddr_t dbase, dmax;
|
||||
|
@ -32,19 +32,20 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)preen.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)preen.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <fstab.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
char *rawname(), *unrawname(), *blockcheck();
|
||||
#include "fsck.h"
|
||||
|
||||
struct part {
|
||||
struct part *next; /* forward link of partitions on disk */
|
||||
@ -60,9 +61,16 @@ struct disk {
|
||||
int pid; /* If != 0, pid of proc working on */
|
||||
} *disks;
|
||||
|
||||
static void addpart __P((char *name, char *fsname, long auxdata));
|
||||
static int startdisk __P((struct disk *dk, int (*checkit)()));
|
||||
static struct disk *finddisk __P((char *name));
|
||||
static char *unrawname __P((char *name));
|
||||
static char *rawname __P((char *name));
|
||||
|
||||
int nrun, ndisks;
|
||||
char hotroot;
|
||||
|
||||
int
|
||||
checkfstab(preen, maxrun, docheck, chkit)
|
||||
int preen, maxrun;
|
||||
int (*docheck)(), (*chkit)();
|
||||
@ -84,10 +92,12 @@ checkfstab(preen, maxrun, docheck, chkit)
|
||||
while ((fsp = getfsent()) != 0) {
|
||||
if ((auxdata = (*docheck)(fsp)) == 0)
|
||||
continue;
|
||||
if (preen == 0 || passno == 1 && fsp->fs_passno == 1) {
|
||||
if (name = blockcheck(fsp->fs_spec)) {
|
||||
if (sumstatus = (*chkit)(name,
|
||||
fsp->fs_file, auxdata, 0))
|
||||
if (!preen || (passno == 1 && fsp->fs_passno == 1)) {
|
||||
name = blockcheck(fsp->fs_spec);
|
||||
if (name) {
|
||||
sumstatus = (*chkit)(name,
|
||||
fsp->fs_file, auxdata, 0);
|
||||
if (sumstatus)
|
||||
return (sumstatus);
|
||||
} else if (preen)
|
||||
return (8);
|
||||
@ -111,7 +121,8 @@ checkfstab(preen, maxrun, docheck, chkit)
|
||||
maxrun = ndisks;
|
||||
nextdisk = disks;
|
||||
for (passno = 0; passno < maxrun; ++passno) {
|
||||
while (ret = startdisk(nextdisk, chkit) && nrun > 0)
|
||||
while ((ret = startdisk(nextdisk, chkit)) != 0 &&
|
||||
nrun > 0)
|
||||
sleep(10);
|
||||
if (ret)
|
||||
return (ret);
|
||||
@ -150,8 +161,8 @@ checkfstab(preen, maxrun, docheck, chkit)
|
||||
|
||||
if (nextdisk == NULL) {
|
||||
if (dk->part) {
|
||||
while (ret = startdisk(dk, chkit) &&
|
||||
nrun > 0)
|
||||
while ((ret = startdisk(dk, chkit)) != 0
|
||||
&& nrun > 0)
|
||||
sleep(10);
|
||||
if (ret)
|
||||
return (ret);
|
||||
@ -164,8 +175,8 @@ checkfstab(preen, maxrun, docheck, chkit)
|
||||
nextdisk->pid == 0)
|
||||
break;
|
||||
}
|
||||
while (ret = startdisk(nextdisk, chkit) &&
|
||||
nrun > 0)
|
||||
while ((ret = startdisk(nextdisk, chkit)) != 0
|
||||
&& nrun > 0)
|
||||
sleep(10);
|
||||
if (ret)
|
||||
return (ret);
|
||||
@ -192,7 +203,7 @@ finddisk(name)
|
||||
{
|
||||
register struct disk *dk, **dkp;
|
||||
register char *p;
|
||||
size_t len;
|
||||
size_t len = 0;
|
||||
|
||||
for (p = name + strlen(name) - 1; p >= name; --p)
|
||||
if (isdigit(*p)) {
|
||||
@ -225,6 +236,7 @@ finddisk(name)
|
||||
return (dk);
|
||||
}
|
||||
|
||||
void
|
||||
addpart(name, fsname, auxdata)
|
||||
char *name, *fsname;
|
||||
long auxdata;
|
||||
@ -256,6 +268,7 @@ addpart(name, fsname, auxdata)
|
||||
pt->auxdata = auxdata;
|
||||
}
|
||||
|
||||
int
|
||||
startdisk(dk, checkit)
|
||||
register struct disk *dk;
|
||||
int (*checkit)();
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)setup.c 8.2 (Berkeley) 2/21/94";
|
||||
static const char sccsid[] = "@(#)setup.c 8.2 (Berkeley) 2/21/94";
|
||||
#endif /* not lint */
|
||||
|
||||
#define DKTYPENAMES
|
||||
@ -45,6 +45,7 @@ static char sccsid[] = "@(#)setup.c 8.2 (Berkeley) 2/21/94";
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/file.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
@ -54,8 +55,13 @@ struct bufarea asblk;
|
||||
#define altsblock (*asblk.b_un.b_fs)
|
||||
#define POWEROF2(num) (((num) & ((num) - 1)) == 0)
|
||||
|
||||
struct disklabel *getdisklabel();
|
||||
static int readsb __P((int listerr));
|
||||
static void badsb __P((int listerr, char *s));
|
||||
static int calcsb __P((char *dev, int devfd, struct fs *fs));
|
||||
static struct disklabel * getdisklabel __P((char *s, int fd));
|
||||
|
||||
|
||||
int
|
||||
setup(dev)
|
||||
char *dev;
|
||||
{
|
||||
@ -99,7 +105,8 @@ 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))
|
||||
lp = getdisklabel((char *)NULL, fsreadfd);
|
||||
if (lp)
|
||||
dev_bsize = secsize = lp->d_secsize;
|
||||
else
|
||||
dev_bsize = secsize = DEV_BSIZE;
|
||||
@ -297,6 +304,7 @@ setup(dev)
|
||||
/*
|
||||
* Read in the super block and its summary info.
|
||||
*/
|
||||
static int
|
||||
readsb(listerr)
|
||||
int listerr;
|
||||
{
|
||||
@ -380,6 +388,7 @@ readsb(listerr)
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
badsb(listerr, s)
|
||||
int listerr;
|
||||
char *s;
|
||||
@ -398,6 +407,7 @@ badsb(listerr, s)
|
||||
* can be used. Do NOT attempt to use other macros without verifying that
|
||||
* their needed information is available!
|
||||
*/
|
||||
int
|
||||
calcsb(dev, devfd, fs)
|
||||
char *dev;
|
||||
int devfd;
|
||||
@ -409,7 +419,7 @@ calcsb(dev, devfd, fs)
|
||||
int i;
|
||||
|
||||
cp = index(dev, '\0') - 1;
|
||||
if (cp == (char *)-1 || (*cp < 'a' || *cp > 'h') && !isdigit(*cp)) {
|
||||
if (cp == (char *)-1 || ((*cp < 'a' || *cp > 'h') && !isdigit(*cp))) {
|
||||
pfatal("%s: CANNOT FIGURE OUT FILE SYSTEM PARTITION\n", dev);
|
||||
return (0);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)utilities.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)utilities.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -42,12 +42,17 @@ static char sccsid[] = "@(#)utilities.c 8.1 (Berkeley) 6/5/93";
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "fsck.h"
|
||||
|
||||
long diskreads, totalreads; /* Disk cache statistics */
|
||||
|
||||
static void rwerror __P((char *mesg, daddr_t blk));
|
||||
|
||||
int
|
||||
ftypeok(dp)
|
||||
struct dinode *dp;
|
||||
{
|
||||
@ -69,6 +74,7 @@ ftypeok(dp)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
reply(question)
|
||||
char *question;
|
||||
{
|
||||
@ -104,6 +110,7 @@ reply(question)
|
||||
/*
|
||||
* Malloc buffers and set up cache.
|
||||
*/
|
||||
void
|
||||
bufinit()
|
||||
{
|
||||
register struct bufarea *bp;
|
||||
@ -188,6 +195,7 @@ getblk(bp, blk, size)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
flush(fd, bp)
|
||||
int fd;
|
||||
register struct bufarea *bp;
|
||||
@ -213,6 +221,7 @@ flush(fd, bp)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rwerror(mesg, blk)
|
||||
char *mesg;
|
||||
daddr_t blk;
|
||||
@ -225,6 +234,7 @@ rwerror(mesg, blk)
|
||||
errexit("Program terminated\n");
|
||||
}
|
||||
|
||||
void
|
||||
ckfini()
|
||||
{
|
||||
register struct bufarea *bp, *nbp;
|
||||
@ -260,6 +270,7 @@ ckfini()
|
||||
(void)close(fswritefd);
|
||||
}
|
||||
|
||||
int
|
||||
bread(fd, buf, blk, size)
|
||||
int fd;
|
||||
char *buf;
|
||||
@ -298,6 +309,7 @@ bread(fd, buf, blk, size)
|
||||
return (errs);
|
||||
}
|
||||
|
||||
void
|
||||
bwrite(fd, buf, blk, size)
|
||||
int fd;
|
||||
char *buf;
|
||||
@ -334,6 +346,7 @@ bwrite(fd, buf, blk, size)
|
||||
/*
|
||||
* allocate a data block with the specified number of fragments
|
||||
*/
|
||||
int
|
||||
allocblk(frags)
|
||||
long frags;
|
||||
{
|
||||
@ -364,6 +377,7 @@ allocblk(frags)
|
||||
/*
|
||||
* Free a previously allocated block
|
||||
*/
|
||||
void
|
||||
freeblk(blkno, frags)
|
||||
daddr_t blkno;
|
||||
long frags;
|
||||
@ -378,6 +392,7 @@ freeblk(blkno, frags)
|
||||
/*
|
||||
* Find a pathname
|
||||
*/
|
||||
void
|
||||
getpathname(namebuf, curdir, ino)
|
||||
char *namebuf;
|
||||
ino_t curdir, ino;
|
||||
@ -386,7 +401,6 @@ getpathname(namebuf, curdir, ino)
|
||||
register char *cp;
|
||||
struct inodesc idesc;
|
||||
static int busy = 0;
|
||||
extern int findname();
|
||||
|
||||
if (curdir == ino && ino == ROOTINO) {
|
||||
(void)strcpy(namebuf, "/");
|
||||
@ -435,7 +449,8 @@ getpathname(namebuf, curdir, ino)
|
||||
}
|
||||
|
||||
void
|
||||
catch()
|
||||
catch(x)
|
||||
int x;
|
||||
{
|
||||
if (!doinglevel2)
|
||||
ckfini();
|
||||
@ -448,10 +463,9 @@ catch()
|
||||
* so that reboot sequence may be interrupted.
|
||||
*/
|
||||
void
|
||||
catchquit()
|
||||
catchquit(x)
|
||||
int x;
|
||||
{
|
||||
extern returntosingle;
|
||||
|
||||
printf("returning to single-user after filesystem check\n");
|
||||
returntosingle = 1;
|
||||
(void)signal(SIGQUIT, SIG_DFL);
|
||||
@ -462,7 +476,8 @@ catchquit()
|
||||
* Used by child processes in preen.
|
||||
*/
|
||||
void
|
||||
voidquit()
|
||||
voidquit(x)
|
||||
int x;
|
||||
{
|
||||
|
||||
sleep(1);
|
||||
@ -473,6 +488,7 @@ voidquit()
|
||||
/*
|
||||
* determine whether an inode should be fixed.
|
||||
*/
|
||||
int
|
||||
dofix(idesc, msg)
|
||||
register struct inodesc *idesc;
|
||||
char *msg;
|
||||
@ -506,15 +522,19 @@ dofix(idesc, msg)
|
||||
|
||||
default:
|
||||
errexit("UNKNOWN INODESC FIX MODE %d\n", idesc->id_fix);
|
||||
return (0);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/* VARARGS1 */
|
||||
errexit(s1, s2, s3, s4)
|
||||
char *s1;
|
||||
__dead void
|
||||
errexit(const char *s1, ...)
|
||||
{
|
||||
printf(s1, s2, s3, s4);
|
||||
va_list ap;
|
||||
va_start(ap,s1);
|
||||
vfprintf(stdout, s1, ap);
|
||||
va_end(ap);
|
||||
exit(8);
|
||||
}
|
||||
|
||||
@ -523,19 +543,22 @@ errexit(s1, s2, s3, s4)
|
||||
* Die if preening, otherwise just print message and continue.
|
||||
*/
|
||||
/* VARARGS1 */
|
||||
pfatal(s, a1, a2, a3)
|
||||
char *s;
|
||||
void
|
||||
pfatal(const char *s, ...)
|
||||
{
|
||||
|
||||
va_list ap;
|
||||
va_start(ap,s);
|
||||
if (preen) {
|
||||
printf("%s: ", cdevname);
|
||||
printf(s, a1, a2, a3);
|
||||
vfprintf(stdout, s, ap);
|
||||
printf("\n");
|
||||
printf("%s: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.\n",
|
||||
cdevname);
|
||||
exit(8);
|
||||
}
|
||||
printf(s, a1, a2, a3);
|
||||
vfprintf(stdout, s, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -543,24 +566,31 @@ pfatal(s, a1, a2, a3)
|
||||
* or a warning (preceded by filename) when preening.
|
||||
*/
|
||||
/* VARARGS1 */
|
||||
pwarn(s, a1, a2, a3, a4, a5, a6)
|
||||
char *s;
|
||||
void
|
||||
pwarn(const char *s, ...)
|
||||
{
|
||||
|
||||
va_list ap;
|
||||
va_start(ap,s);
|
||||
if (preen)
|
||||
printf("%s: ", cdevname);
|
||||
printf(s, a1, a2, a3, a4, a5, a6);
|
||||
vfprintf(stdout, s, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
#ifndef lint
|
||||
/*
|
||||
* Stub for routines from kernel.
|
||||
*/
|
||||
panic(s)
|
||||
char *s;
|
||||
__dead void
|
||||
#ifdef __STDC__
|
||||
panic(const char *fmt, ...)
|
||||
#else
|
||||
panic(fmt, va_alist)
|
||||
char *fmt;
|
||||
#endif
|
||||
{
|
||||
|
||||
pfatal("INTERNAL INCONSISTENCY:");
|
||||
errexit(s);
|
||||
errexit(fmt);
|
||||
}
|
||||
#endif
|
||||
|
@ -32,19 +32,20 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)preen.c 8.1 (Berkeley) 6/5/93";
|
||||
static const char sccsid[] = "@(#)preen.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <fstab.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
char *rawname(), *unrawname(), *blockcheck();
|
||||
#include "fsck.h"
|
||||
|
||||
struct part {
|
||||
struct part *next; /* forward link of partitions on disk */
|
||||
@ -60,9 +61,16 @@ struct disk {
|
||||
int pid; /* If != 0, pid of proc working on */
|
||||
} *disks;
|
||||
|
||||
static void addpart __P((char *name, char *fsname, long auxdata));
|
||||
static int startdisk __P((struct disk *dk, int (*checkit)()));
|
||||
static struct disk *finddisk __P((char *name));
|
||||
static char *unrawname __P((char *name));
|
||||
static char *rawname __P((char *name));
|
||||
|
||||
int nrun, ndisks;
|
||||
char hotroot;
|
||||
|
||||
int
|
||||
checkfstab(preen, maxrun, docheck, chkit)
|
||||
int preen, maxrun;
|
||||
int (*docheck)(), (*chkit)();
|
||||
@ -84,10 +92,12 @@ checkfstab(preen, maxrun, docheck, chkit)
|
||||
while ((fsp = getfsent()) != 0) {
|
||||
if ((auxdata = (*docheck)(fsp)) == 0)
|
||||
continue;
|
||||
if (preen == 0 || passno == 1 && fsp->fs_passno == 1) {
|
||||
if (name = blockcheck(fsp->fs_spec)) {
|
||||
if (sumstatus = (*chkit)(name,
|
||||
fsp->fs_file, auxdata, 0))
|
||||
if (!preen || (passno == 1 && fsp->fs_passno == 1)) {
|
||||
name = blockcheck(fsp->fs_spec);
|
||||
if (name) {
|
||||
sumstatus = (*chkit)(name,
|
||||
fsp->fs_file, auxdata, 0);
|
||||
if (sumstatus)
|
||||
return (sumstatus);
|
||||
} else if (preen)
|
||||
return (8);
|
||||
@ -111,7 +121,8 @@ checkfstab(preen, maxrun, docheck, chkit)
|
||||
maxrun = ndisks;
|
||||
nextdisk = disks;
|
||||
for (passno = 0; passno < maxrun; ++passno) {
|
||||
while (ret = startdisk(nextdisk, chkit) && nrun > 0)
|
||||
while ((ret = startdisk(nextdisk, chkit)) != 0 &&
|
||||
nrun > 0)
|
||||
sleep(10);
|
||||
if (ret)
|
||||
return (ret);
|
||||
@ -150,8 +161,8 @@ checkfstab(preen, maxrun, docheck, chkit)
|
||||
|
||||
if (nextdisk == NULL) {
|
||||
if (dk->part) {
|
||||
while (ret = startdisk(dk, chkit) &&
|
||||
nrun > 0)
|
||||
while ((ret = startdisk(dk, chkit)) != 0
|
||||
&& nrun > 0)
|
||||
sleep(10);
|
||||
if (ret)
|
||||
return (ret);
|
||||
@ -164,8 +175,8 @@ checkfstab(preen, maxrun, docheck, chkit)
|
||||
nextdisk->pid == 0)
|
||||
break;
|
||||
}
|
||||
while (ret = startdisk(nextdisk, chkit) &&
|
||||
nrun > 0)
|
||||
while ((ret = startdisk(nextdisk, chkit)) != 0
|
||||
&& nrun > 0)
|
||||
sleep(10);
|
||||
if (ret)
|
||||
return (ret);
|
||||
@ -192,7 +203,7 @@ finddisk(name)
|
||||
{
|
||||
register struct disk *dk, **dkp;
|
||||
register char *p;
|
||||
size_t len;
|
||||
size_t len = 0;
|
||||
|
||||
for (p = name + strlen(name) - 1; p >= name; --p)
|
||||
if (isdigit(*p)) {
|
||||
@ -225,6 +236,7 @@ finddisk(name)
|
||||
return (dk);
|
||||
}
|
||||
|
||||
void
|
||||
addpart(name, fsname, auxdata)
|
||||
char *name, *fsname;
|
||||
long auxdata;
|
||||
@ -256,6 +268,7 @@ addpart(name, fsname, auxdata)
|
||||
pt->auxdata = auxdata;
|
||||
}
|
||||
|
||||
int
|
||||
startdisk(dk, checkit)
|
||||
register struct disk *dk;
|
||||
int (*checkit)();
|
||||
|
Loading…
Reference in New Issue
Block a user