summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/fs.d/ufs/fsck/Makefile2
-rw-r--r--usr/src/cmd/fs.d/ufs/fsck/dir.c4
-rw-r--r--usr/src/cmd/fs.d/ufs/fsck/fsck.h6
-rw-r--r--usr/src/cmd/fs.d/ufs/fsck/main.c18
-rw-r--r--usr/src/cmd/fs.d/ufs/fsck/pass2.c (renamed from usr/src/cmd/fs.d/ufs/fsck/pass2b.c)14
-rw-r--r--usr/src/cmd/fs.d/ufs/fsck/pass2a.c195
-rw-r--r--usr/src/cmd/fs.d/ufs/fsck/pass3.c2
7 files changed, 15 insertions, 226 deletions
diff --git a/usr/src/cmd/fs.d/ufs/fsck/Makefile b/usr/src/cmd/fs.d/ufs/fsck/Makefile
index 863bed92c5..ce8924b04e 100644
--- a/usr/src/cmd/fs.d/ufs/fsck/Makefile
+++ b/usr/src/cmd/fs.d/ufs/fsck/Makefile
@@ -35,7 +35,7 @@ include ../../Makefile.fstype
include ../Makefile.roll
FSCKOBJS= main.o dir.o dup_avl.o inode.o pass1.o pass1b.o \
- pass2b.o \
+ pass2.o \
pass3.o pass3b.o pass4.o pass5.o setup.o \
utilities.o
FSCKSRCS= $(FSCKOBJS:%.o=%.c)
diff --git a/usr/src/cmd/fs.d/ufs/fsck/dir.c b/usr/src/cmd/fs.d/ufs/fsck/dir.c
index ea255dfe85..abcf442880 100644
--- a/usr/src/cmd/fs.d/ufs/fsck/dir.c
+++ b/usr/src/cmd/fs.d/ufs/fsck/dir.c
@@ -1226,11 +1226,11 @@ allocdir(fsck_ino_t parent, fsck_ino_t request, int mode, int update_parent)
* parent. On the other hand, if the parent's already been
* looked at (statemap[ino] == DFOUND), the discrepancy
* between lncntp[] and di_nlink will be noted later, with
- * appropriate reporting and propagation, in pass2b.
+ * appropriate reporting and propagation, in pass2.
*
* We're explicitly skipping where the parent was DZLINK or
* DFOUND. If it has zero links, it can't be gotten to, so
- * we want a discrepancy set up that will be caught in pass2b.
+ * we want a discrepancy set up that will be caught in pass2.
* DFOUND was discussed above.
*
* Regarding the claim of a link from the parent: we've not
diff --git a/usr/src/cmd/fs.d/ufs/fsck/fsck.h b/usr/src/cmd/fs.d/ufs/fsck/fsck.h
index e53244b2f6..fd5519046a 100644
--- a/usr/src/cmd/fs.d/ufs/fsck/fsck.h
+++ b/usr/src/cmd/fs.d/ufs/fsck/fsck.h
@@ -506,8 +506,7 @@ enum magic {
MAGIC_NONE = 0,
MAGIC_ROOT = 1,
MAGIC_USR = 2,
- MAGIC_VAR = 3,
- MAGIC_LIMIT = 4
+ MAGIC_LIMIT = 3
};
extern char *magic_fs[];
@@ -592,8 +591,7 @@ int mounted(caddr_t, caddr_t, size_t);
void pass1(void);
void pass1b(void);
int pass1check(struct inodesc *);
-void pass2a(void);
-void pass2b(void);
+void pass2(void);
void pass3a(void);
void pass3b(void);
int pass3bcheck(struct inodesc *);
diff --git a/usr/src/cmd/fs.d/ufs/fsck/main.c b/usr/src/cmd/fs.d/ufs/fsck/main.c
index 377a63b242..d309730890 100644
--- a/usr/src/cmd/fs.d/ufs/fsck/main.c
+++ b/usr/src/cmd/fs.d/ufs/fsck/main.c
@@ -172,7 +172,6 @@ char *magic_fs[] = {
"", /* MAGIC_NONE, for normal filesystems */
"/", /* MAGIC_ROOT */
"/usr", /* MAGIC_USR */
- "/var", /* MAGIC_VAR */
NULL /* MAGIC_LIMIT */
};
@@ -431,24 +430,11 @@ checkfilesys(char *filesys)
}
/*
- * 2a: check for duplicate name entries inside each directory.
- */
-#if 0
- /*
- * XXX This is disabled for performance reasons. It should become
- * an optional test. Don't forget to update the printed label for
- * pass2b() when this is re-enabled.
- */
- if (!preen)
- (void) printf("** Phase 2a - Check Duplicated Names\n");
- pass2a();
-#endif
- /*
- * 2b: traverse directories from root to mark all connected directories
+ * 2: traverse directories from root to mark all connected directories
*/
if (!preen)
(void) printf("** Phase 2 - Check Pathnames\n");
- pass2b();
+ pass2();
/*
* 3a: scan inodes looking for disconnected directories.
diff --git a/usr/src/cmd/fs.d/ufs/fsck/pass2b.c b/usr/src/cmd/fs.d/ufs/fsck/pass2.c
index 14465ad027..998f98f3f6 100644
--- a/usr/src/cmd/fs.d/ufs/fsck/pass2b.c
+++ b/usr/src/cmd/fs.d/ufs/fsck/pass2.c
@@ -45,10 +45,10 @@
#define MINDIRSIZE (sizeof (struct dirtemplate))
static int blksort(const void *, const void *);
-static int pass2bcheck(struct inodesc *);
+static int pass2check(struct inodesc *);
void
-pass2b(void)
+pass2(void)
{
struct dinode *dp, *dp2, *dpattr;
struct inoinfo **inpp, *inp;
@@ -200,7 +200,7 @@ pass2b(void)
inp->i_blkssize);
init_inodesc(&curino);
curino.id_type = DATA;
- curino.id_func = pass2bcheck;
+ curino.id_func = pass2check;
curino.id_number = inp->i_number;
curino.id_parent = inp->i_parent;
curino.id_fix = DONTKNOW;
@@ -392,7 +392,7 @@ pass2b(void)
#define PASS2B_PROMPT "REMOVE DIRECTORY ENTRY FROM I=%d"
static int
-pass2bcheck(struct inodesc *idesc)
+pass2check(struct inodesc *idesc)
{
struct direct *dirp = idesc->id_dirp;
struct inodesc ldesc;
@@ -548,7 +548,7 @@ chk1:
* This is a can't-happen, since inodes get cached before
* we get called on them.
*/
- errexit("pass2bcheck got NULL from getinoinfo at chk1 I=%d\n",
+ errexit("pass2check got NULL from getinoinfo at chk1 I=%d\n",
idesc->id_number);
}
proto.d_ino = inp->i_parent;
@@ -782,7 +782,7 @@ again:
* above, and so it is a can't-happen
* at this point.
*/
- errexit("pass2bcheck found a zero-len "
+ errexit("pass2check found a zero-len "
"reference to bad I=%d\n",
dirp->d_ino);
}
@@ -841,7 +841,7 @@ again:
* Same can't-happen argument as in the
* zero-len case above.
*/
- errexit("pass2bcheck found bad reference to "
+ errexit("pass2check found bad reference to "
"hard-linked directory I=%d\n",
dirp->d_ino);
}
diff --git a/usr/src/cmd/fs.d/ufs/fsck/pass2a.c b/usr/src/cmd/fs.d/ufs/fsck/pass2a.c
deleted file mode 100644
index 8fded73379..0000000000
--- a/usr/src/cmd/fs.d/ufs/fsck/pass2a.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
-/* All Rights Reserved */
-
-/*
- * Copyright (c) 1980, 1986, 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that: (1) source distributions retain this entire copyright
- * notice and comment, and (2) distributions including binaries display
- * the following acknowledgement: ``This product includes software
- * developed by the University of California, Berkeley and its contributors''
- * in the documentation or other materials provided with the distribution
- * and in all advertising materials mentioning features or use of this
- * software. Neither the name of the University nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <strings.h>
-#include <sys/types.h>
-#include <sys/fs/ufs_fs.h>
-#include <sys/fs/ufs_fsdir.h>
-#include "fsck.h"
-
-/* XXX should convert pass2a to using avl tree */
-
-/*
- * Directory contents table is keyed first by name length, and
- * then the actual name.
- */
-typedef struct dirtree {
- caddr_t name;
- int len;
- fsck_ino_t ino;
-} dirtree_t;
-
-/*
- * Tree of contents of directory currently being traversed.
- * Elements are pointers to dirtree_t instances.
- */
-static void *contents;
-
-static int pass2acheck(struct inodesc *);
-static void discard_contents(void);
-static int dirtree_cmp(const void *, const void *);
-
-/*
- * Make sure directories don't contain duplicate names.
- */
-void
-pass2a(void)
-{
- struct inodesc idesc;
- struct inoinfo *inp, **inpp, **inpend;
- struct dinode *dp;
-
- inpend = &inpsort[inplast];
- for (inpp = inpsort; inpp < inpend; inpp++) {
- inp = *inpp;
-
- if (inp->i_isize == 0)
- continue;
-
- /* != DSTATE also covers case of == USTATE */
- if (((statemap[inp->i_number] & STMASK) != DSTATE) ||
- ((statemap[inp->i_number] & INCLEAR) == INCLEAR))
- continue;
-
- dp = ginode(inp->i_number);
- init_inodesc(&idesc);
- idesc.id_filesize = dp->di_size;
- idesc.id_type = DATA;
- idesc.id_func = pass2acheck;
- idesc.id_number = inp->i_number;
- idesc.id_parent = inp->i_parent;
- idesc.id_fix = NOFIX;
- (void) ckinode(dp, &idesc, CKI_TRAVERSE);
-
- discard_contents();
- }
-}
-
-/*
- * Used to scan a particular directory, noting what entries it contains.
- * If a duplicate entry is found, it is reported and the user given
- * the option of clearing said entry.
- */
-static int
-pass2acheck(struct inodesc *idesc)
-{
- struct direct *dirp = idesc->id_dirp;
- dirtree_t key;
- void **foundp;
- dirtree_t *firstp;
- int retval = KEEPON;
-
- /*
- * We've reached the end of the valid part of the directory.
- */
- if (idesc->id_blkno == 0) {
- return (STOP);
- }
-
- if (dirp->d_ino != 0) {
- key.name = dirp->d_name;
- key.len = dirp->d_namlen;
- foundp = tfind((void *)&key, &contents, dirtree_cmp);
- if ((foundp != NULL) && (*foundp != NULL)) {
- firstp = (dirtree_t *)*foundp;
-
- pfatal(
- "Duplicate entries in dir I=%d for ``%s'': I=%d and I=%d",
- idesc->id_number, dirp->d_name,
- firstp->ino, dirp->d_ino);
- if (reply("Clear second entry") == 1) {
- dirp->d_ino = 0;
- retval |= ALTERED;
- } else {
- iscorrupt = 1;
- }
- } else {
- firstp = (dirtree_t *)malloc(sizeof (dirtree_t));
- if ((firstp == NULL) ||
- ((firstp->name = strdup(dirp->d_name)) == NULL)) {
- goto nomem;
- }
- firstp->len = dirp->d_namlen;
- firstp->ino = dirp->d_ino;
- if (tsearch((void *)firstp,
- &contents, dirtree_cmp) == NULL) {
- goto nomem;
- }
- }
- }
-
- return (retval);
-
-nomem:
- if (firstp != NULL) {
- if (firstp->name != NULL)
- free(firstp->name);
- free(firstp);
- }
-
- pfatal(
- "Out of memory while looking for duplicate names in directory I=%d",
- idesc->id_number);
- if (reply("SKIP REST OF DUP NAME CHECK") == 0)
- errexit("Program terminated.");
-
- discard_contents();
- retval |= STOP;
-
- return (retval);
-}
-
-static void
-discard_contents(void)
-{
- dirtree_t *victim;
-
- while (contents != NULL) {
- victim = *(dirtree_t **)contents;
- (void) tdelete((void *)victim, &contents, dirtree_cmp);
- free((void *)victim->name);
- free((void *)victim);
- }
-}
-
-static int
-dirtree_cmp(const void *left, const void *right)
-{
- int cmp;
- const dirtree_t *lp = (const dirtree_t *)left;
- const dirtree_t *rp = (const dirtree_t *)right;
-
- cmp = lp->len - rp->len;
- if (cmp == 0)
- cmp = strcmp(lp->name, rp->name);
-
- return (cmp);
-}
diff --git a/usr/src/cmd/fs.d/ufs/fsck/pass3.c b/usr/src/cmd/fs.d/ufs/fsck/pass3.c
index 06c522843d..f0a9a693e9 100644
--- a/usr/src/cmd/fs.d/ufs/fsck/pass3.c
+++ b/usr/src/cmd/fs.d/ufs/fsck/pass3.c
@@ -197,7 +197,7 @@ pass3a(void)
/*
* Theoretically, this lookup via ckinode can't fail
* (if orphan doesn't exist in i_parent, then i_parent
- * would not have been filled in by pass2bcheck()).
+ * would not have been filled in by pass2check()).
* However, if we're interactive, we want to at least
* attempt to continue. The worst case is that it
* gets reconnected as #nnn into lost+found instead of