Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/fsck_lfs Add "-i" flag to specify the location of the i...
details: https://anonhg.NetBSD.org/src/rev/a4557099e39b
branches: trunk
changeset: 487908:a4557099e39b
user: perseant <perseant%NetBSD.org@localhost>
date: Wed Jun 14 18:43:57 2000 +0000
description:
Add "-i" flag to specify the location of the index file inode, to
examine alternate checkpoints. Regularize usage of maxino. Remove olf
debugging cruft.
diffstat:
sbin/fsck_lfs/dir.c | 4 ++--
sbin/fsck_lfs/fsck_vars.h | 3 ++-
sbin/fsck_lfs/inode.c | 29 +++++++++++++++++------------
sbin/fsck_lfs/main.c | 13 ++++++++++---
sbin/fsck_lfs/pass0.c | 13 +++++++++----
sbin/fsck_lfs/pass1.c | 30 ++++++++----------------------
sbin/fsck_lfs/pass2.c | 4 ++--
sbin/fsck_lfs/setup.c | 32 ++++++++++++++------------------
sbin/fsck_lfs/utilities.c | 3 +--
sbin/fsck_lfs/vars.c | 3 ++-
10 files changed, 67 insertions(+), 67 deletions(-)
diffs (truncated from 459 to 300 lines):
diff -r 051dca6d9194 -r a4557099e39b sbin/fsck_lfs/dir.c
--- a/sbin/fsck_lfs/dir.c Wed Jun 14 17:57:59 2000 +0000
+++ b/sbin/fsck_lfs/dir.c Wed Jun 14 18:43:57 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.3 2000/05/23 01:48:52 perseant Exp $ */
+/* $NetBSD: dir.c,v 1.4 2000/06/14 18:43:57 perseant Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -299,7 +299,7 @@
pinode(ino);
printf("\n");
getpathname(pathbuf, cwd, ino);
- if (ino < ROOTINO || ino > maxino) {
+ if (ino < ROOTINO || ino >= maxino) {
pfatal("NAME=%s\n", pathbuf);
return;
}
diff -r 051dca6d9194 -r a4557099e39b sbin/fsck_lfs/fsck_vars.h
--- a/sbin/fsck_lfs/fsck_vars.h Wed Jun 14 17:57:59 2000 +0000
+++ b/sbin/fsck_lfs/fsck_vars.h Wed Jun 14 18:43:57 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fsck_vars.h,v 1.3 2000/05/23 01:48:53 perseant Exp $ */
+/* $NetBSD: fsck_vars.h,v 1.4 2000/06/14 18:43:58 perseant Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -49,6 +49,7 @@
extern struct zlncnt *zlnhead; /* head of zero link count list */
+extern daddr_t idaddr; /* inode block containing ifile inode */
extern long numdirs, listmax, inplast;
extern long dev_bsize; /* computed value of DEV_BSIZE */
diff -r 051dca6d9194 -r a4557099e39b sbin/fsck_lfs/inode.c
--- a/sbin/fsck_lfs/inode.c Wed Jun 14 17:57:59 2000 +0000
+++ b/sbin/fsck_lfs/inode.c Wed Jun 14 18:43:57 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: inode.c,v 1.6 2000/05/23 01:48:53 perseant Exp $ */
+/* $NetBSD: inode.c,v 1.7 2000/06/14 18:43:58 perseant Exp $ */
/*
* Copyright (c) 1997, 1998
@@ -193,12 +193,13 @@
* from a file whose inode has disk address idaddr. In practice
* we will only use this to find blocks of the ifile.
*/
+static struct bufarea empty;
+
struct bufarea *
getfileblk(struct lfs * fs, struct dinode * idinode, ino_t lbn)
{
struct bufarea *bp;
ufs_daddr_t blkno;
- static struct bufarea empty;
static char empty_buf[65536];
empty.b_un.b_buf = &(empty_buf[0]);
@@ -233,6 +234,9 @@
*bpp = getfileblk(&sblock, lfs_ginode(LFS_IFILE_INUM),
ino / sblock.lfs_ifpb + sblock.lfs_cleansz +
sblock.lfs_segtabsz);
+ if (*bpp == &empty) {
+ printf("Warning: ino %d ientry in unassigned block\n", ino);
+ }
if (*bpp) {
ifp = (((struct ifile *)((*bpp)->b_un.b_buf)) +
(ino % sblock.lfs_ifpb));
@@ -262,7 +266,7 @@
daddr = din_table[inumber];
} else {
if (inumber == LFS_IFILE_INUM)
- daddr = sblock.lfs_idaddr;
+ daddr = idaddr;
else {
ifp = lfs_ientry(inumber, &bp);
if (ifp == NULL) {
@@ -290,12 +294,12 @@
struct bufarea *bp;
daddr_t daddr;
- if (inumber > maxino)
+ if (inumber >= maxino)
errexit("bad inode number %d to lfs_ginode\n", inumber);
#if 0
if (inumber == LFS_IFILE_INUM) {
- daddr = sblock.lfs_idaddr;
+ daddr = idaddr;
if (din_table[LFS_IFILE_INUM] == 0) {
din_table[LFS_IFILE_INUM] = daddr;
seg_table[datosn(&sblock, daddr)].su_nbytes += DINODE_SIZE;
@@ -450,9 +454,8 @@
static int
iblock(struct inodesc * idesc, long ilevel, u_int64_t isize)
{
- register daddr_t *ap;
- register daddr_t *aplim;
- register struct bufarea *bp;
+ daddr_t *ap, *aplim;
+ struct bufarea *bp;
int i, n, (*func)(struct inodesc *), nif;
u_int64_t sizepb;
char pathbuf[MAXPATHLEN + 1], buf[BUFSIZ];
@@ -481,7 +484,7 @@
if (*ap == 0)
continue;
(void)sprintf(buf, "PARTIALLY TRUNCATED INODE I=%u",
- idesc->id_number);
+ idesc->id_number);
if (dofix(idesc, buf)) {
*ap = 0;
dirty(bp);
@@ -534,8 +537,10 @@
int
chkrange(daddr_t blk, int cnt)
{
+ if (blk < btodb(LFS_LABELPAD+LFS_SBPAD)) {
+ return (1);
+ }
if (blk > fsbtodb(&sblock, maxfsblock)) {
- printf("daddr 0x%x too large\n", blk);
return (1);
}
return (0);
@@ -687,7 +692,7 @@
if (dirp->d_ino == 0)
return (KEEPON);
if (strcmp(dirp->d_name, idesc->id_name) == 0 &&
- dirp->d_ino >= ROOTINO && dirp->d_ino <= maxino) {
+ dirp->d_ino >= ROOTINO && dirp->d_ino < maxino) {
idesc->id_parent = dirp->d_ino;
return (STOP | FOUND);
}
@@ -703,7 +708,7 @@
time_t t;
printf(" I=%u ", ino);
- if (ino < ROOTINO || ino > maxino)
+ if (ino < ROOTINO || ino >= maxino)
return;
dp = ginode(ino);
if (dp) {
diff -r 051dca6d9194 -r a4557099e39b sbin/fsck_lfs/main.c
--- a/sbin/fsck_lfs/main.c Wed Jun 14 17:57:59 2000 +0000
+++ b/sbin/fsck_lfs/main.c Wed Jun 14 18:43:57 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.5 2000/05/23 01:48:53 perseant Exp $ */
+/* $NetBSD: main.c,v 1.6 2000/06/14 18:43:58 perseant Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -69,11 +69,12 @@
{
int ch;
int ret = 0;
- char *optstring = "b:C:dm:npy";
+ char *optstring = "b:C:di:m:npy";
sync();
skipclean = 1;
exitonfail = 0;
+ idaddr = 0x0;
while ((ch = getopt(argc, argv, optstring)) != EOF) {
switch (ch) {
case 'b':
@@ -90,6 +91,9 @@
case 'e':
exitonfail++;
break;
+ case 'i':
+ idaddr = strtol(optarg, NULL, 0);
+ break;
case 'm':
lfmode = argtoi('m', "mode", optarg, 8);
if (lfmode & ~07777)
@@ -205,7 +209,10 @@
*/
if (preen == 0)
printf("** Phase 0 - Check Segment Summaries and Inode Free List\n");
- pass0();
+ if (idaddr != sblock.lfs_idaddr)
+ pwarn("-i given, skipping free list check\n");
+ else
+ pass0();
if (preen == 0) {
/*
diff -r 051dca6d9194 -r a4557099e39b sbin/fsck_lfs/pass0.c
--- a/sbin/fsck_lfs/pass0.c Wed Jun 14 17:57:59 2000 +0000
+++ b/sbin/fsck_lfs/pass0.c Wed Jun 14 18:43:57 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pass0.c,v 1.6 2000/05/30 04:33:14 perseant Exp $ */
+/* $NetBSD: pass0.c,v 1.7 2000/06/14 18:43:59 perseant Exp $ */
/*
* Copyright (c) 1998 Konrad E. Schroder.
@@ -82,12 +82,17 @@
* Check the inode free list for inuse inodes, and cycles.
* Make sure that all free inodes are in fact on the list.
*/
- visited = (ino_t *)malloc((maxino + 1) * sizeof(ino_t));
- memset(visited, 0, (maxino + 1) * sizeof(ino_t));
+ visited = (ino_t *)malloc(maxino * sizeof(ino_t));
+ memset(visited, 0, maxino * sizeof(ino_t));
lastino = 0;
ino = sblock.lfs_free;
while (ino) {
+ if (ino >= maxino) {
+ printf("! Ino %d out of range (last was %d)\n", ino,
+ lastino);
+ break;
+ }
if (visited[ino]) {
pwarn("! Ino %d already found on the free list!\n",
ino);
@@ -128,7 +133,7 @@
/*
* Make sure all free inodes were found on the list
*/
- for (ino = ROOTINO+1; ino <= maxino; ++ino) {
+ for (ino = ROOTINO+1; ino < maxino; ++ino) {
if (visited[ino])
continue;
diff -r 051dca6d9194 -r a4557099e39b sbin/fsck_lfs/pass1.c
--- a/sbin/fsck_lfs/pass1.c Wed Jun 14 17:57:59 2000 +0000
+++ b/sbin/fsck_lfs/pass1.c Wed Jun 14 18:43:57 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pass1.c,v 1.7 2000/05/30 04:33:15 perseant Exp $ */
+/* $NetBSD: pass1.c,v 1.8 2000/06/14 18:43:59 perseant Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -58,18 +58,6 @@
static void checkinode(ino_t, struct inodesc *);
static int i_d_cmp(const void *, const void *);
-static void
-bmapcheck(void)
-{
- int i;
-
- if (testbmap(0))
- raise(1);
- for (i = 0; i < maxfsblock; i++)
- if (testbmap(i) > maxino)
- raise(1);
-}
-
struct ino_daddr {
ino_t ino;
daddr_t daddr;
@@ -132,19 +120,19 @@
if (debug)
printf("creating inode address table...\n");
/* Sort by daddr */
- dins = (struct ino_daddr **)malloc((maxino + 1) * sizeof(*dins));
- for (i = 0; i <= maxino; i++) {
+ dins = (struct ino_daddr **)malloc(maxino * sizeof(*dins));
+ for (i = 0; i < maxino; i++) {
dins[i] = malloc(sizeof(**dins));
dins[i]->ino = i;
dins[i]->daddr = lfs_ino_daddr(i);
}
- qsort(dins, maxino + 1, sizeof(*dins), i_d_cmp);
+ qsort(dins, maxino, sizeof(*dins), i_d_cmp);
/* find a value for numdirs, fill in din_table */
if (debug)
printf("counting dirs...\n");
numdirs = 0;
- for (i = 0; i <= maxino; i++) {
+ for (i = 0; i < maxino; i++) {
inumber = dins[i]->ino;
if (inumber == 0 || dins[i]->daddr == 0)
continue;
@@ -168,7 +156,7 @@
/* resetinodebuf(); */
if (debug)
printf("counting blocks...\n");
- for (i = 0; i <= maxino; i++) {
+ for (i = 0; i < maxino; i++) {
inumber = dins[i]->ino;
if (inumber == 0 || dins[i]->daddr == 0) {
statemap[inumber] = USTATE;
@@ -186,7 +174,6 @@
}
free(dins);
- bmapcheck();
/* freeinodebuf(); */
}
@@ -375,9 +362,6 @@
register struct dups *dlp;
struct dups *new;
Home |
Main Index |
Thread Index |
Old Index