aboutsummaryrefslogtreecommitdiff
path: root/ufs-fsck
diff options
context:
space:
mode:
Diffstat (limited to 'ufs-fsck')
-rw-r--r--ufs-fsck/ChangeLog256
-rw-r--r--ufs-fsck/Makefile8
-rw-r--r--ufs-fsck/dir.c102
-rw-r--r--ufs-fsck/fsck.h14
-rw-r--r--ufs-fsck/main.c5
-rw-r--r--ufs-fsck/pass1.c78
-rw-r--r--ufs-fsck/pass1b.c10
-rw-r--r--ufs-fsck/pass2.c51
-rw-r--r--ufs-fsck/pass5.c80
-rw-r--r--ufs-fsck/setup.c21
-rw-r--r--ufs-fsck/utilities.c46
11 files changed, 206 insertions, 465 deletions
diff --git a/ufs-fsck/ChangeLog b/ufs-fsck/ChangeLog
deleted file mode 100644
index 8fcde4b2..00000000
--- a/ufs-fsck/ChangeLog
+++ /dev/null
@@ -1,256 +0,0 @@
-Tue Jul 23 19:32:09 1996 Miles Bader <miles@gnu.ai.mit.edu>
-
- * inode.c (allocino): `struct timespec' now uses a field prefix
- of `tv_'.
- * utilities.c (pinode): Likewise.
-
-Thu Jul 18 14:55:14 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
-
- * pass2.c (pass2): If an entire directory block is null, allow
- preen to patch it into a normal empty directory entry.
-
-Sat Jul 6 19:59:27 1996 Miles Bader <miles@gnu.ai.mit.edu>
-
- * main.c (argp_program_version): New variable.
- <hurd.h>: New include.
-
-Mon Jul 1 12:55:48 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
-
- * pass2.c (pass2): Don't skip empty directories in `.' and `..'
- correctness check; we don't clear them the way BSD does, so we
- want `.' and `..' to get created for us. Also handle `.' before
- `..' so that they get created in the usual order for empty
- directories.
-
- * dir.c (makeentry): After successful directory expansion, write
- out modified directory inode.
-
- * pass4.c (pass4): If a reconnect fails while we are preening,
- give up.
-
-Mon Jun 24 10:19:39 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
-
- * utilities.c (errexit, punt): Exit with status 8 for catastrophic
- failures.
-
-Thu May 23 14:12:21 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
-
- * pass2.c (pass2): Don't clear all node types in directories, just
- clear those that are wrong.
-
-Tue May 14 16:49:46 1996 Miles Bader <miles@gnu.ai.mit.edu>
-
- * pass2.c (pass2): Fix up test in preen case.
-
-Tue May 14 15:29:36 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
-
- * pass2.c (pass2): Handle directory entry type fields better for
- Hurd.
-
-Sat May 11 01:07:49 1996 Miles Bader <miles@gnu.ai.mit.edu>
-
- * main.c (parse_opt): Use ARGP_ERR_UNKNOWN instead of EINVAL.
-
-Thu May 9 20:12:51 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
-
- * pass1b.c (pass1b): Bother to initialize NUMBER.
-
-Fri May 3 00:48:39 1996 Miles Bader <miles@gnu.ai.mit.edu>
-
- * main.c (nice_size, show_stats): New functions.
- (main): Use show_stats.
-
-Wed May 1 13:59:06 1996 Miles Bader <miles@gnu.ai.mit.edu>
-
- * main.c (main): Shorten summary message so that it fits on one line.
- * utilities.c (no_preen): New function.
- (problem, warning, pinode): Use it.
- (warning): Don't flush all pending problems, just our own.
- * dir.c (linkup): Consistently put quotes around filenames.
-
- * main.c (preen, num_files): New variables.
- (main): Implement clean-bit checking in preen mode, and print
- summary statistics.
- (main, options): Add --force & --silent options.
- * pass1.c (pass1): Increment NUM_FILES.
- When clearing inode due to bad blocks, continue.
- * inode.c (allocino, freeino): Frob NUM_FILES.
- * fsck.h (force): New declaration.
- * pass5.c (pass5): Vary clean msg depending on whether FSMODIFIED.
- * setup.c (setup): Use error to print error msgs.
- <error.h>, <errno.h>: New includes.
-
- * utilities.c (problem, warning, pextend, pfail): New functions.
- (pinode, pfix, reply): Use new problem recording stuff.
- (push_problem, resolve_problem, flush_problems): New functions.
- (struct problem): New type.
- (problems, free_problems): New variables.
- (retch, punt): New functions.
- * fsck.h (problem, warning, pextend, pfail): New declarations.
- (pinode): Update declaration.
- * dir.c (validdir, makeentry, linkup): Use new printing functions.
- * pass1.c (pass1): Likewise.
- * pass1b.c (pass1b): Likewise.
- * pass2.c (pass2): Likewise.
- * pass3.c (pass3): Likewise.
- * pass4.c (pass4): Likewise.
- * pass5.c (pass5): Likewise.
- * setup.c (setup): Likewise.
-
-Tue Apr 30 19:06:42 1996 Miles Bader <miles@gnu.ai.mit.edu>
-
- * pass5.c (pass5): Be sure to call pwarn before pfix.
- * main.c (main): Don't print large obnoxious banner if PREEN.
-
-Fri Apr 26 16:20:37 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
-
- * inode.c (allocino): Parenthesize test correctly.
-
- * fsck.h (swab_disk): Define as constant zero.
-
- * pass5.c (pass5): If not marked clean, but now it is, then offer
- to mark it clean.
- * utilities.c (reply): Set fix_denied anytime we return 0.
- * fsck.h (fix_denied): New variable.
-
-Wed Apr 24 13:32:39 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
-
- * pass1.c (pass1): Don't print block numbers as we go anymore.
-
-Tue Apr 23 10:11:49 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
-
- * pass5.c (pass5): Correctly track contig summaries even though
- they aren't used by the filesystem; we still need to preserve the
- format.
-
-Mon Apr 15 12:51:41 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
-
- * Makefile (vpath tables.c): Find ufs directory in $(top_srcdir).
-
-Tue Apr 2 09:00:53 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
-
- * pass1.c (pass1): Print mode correctly in unknown file type case.
- Recognize inode type IFSOCK too.
-
-Mon Mar 18 19:48:39 1996 Miles Bader <miles@gnu.ai.mit.edu>
-
- * main.c (main): Pass new arg to argp_parse. Use argp_usage correctly.
-
-Thu Oct 19 17:45:12 1995 Miles Bader <miles@gnu.ai.mit.edu>
-
- * main.c (main): Exit with a non-zero status if we fixed anything.
- Use argp to parse options.
- (options): Converted to argp format.
- (args_doc): New variable.
- (USAGE, usage, SHORT_OPTIONS): Removed.
- Include <argp.h> instead of <getopt.h>.
- * Makefile ($(target)): Depend on libshouldbeinlibc.a.
-
-Fri Sep 22 16:55:03 1995 Miles Bader <miles@gnu.ai.mit.edu>
-
- * utilities.c (pfix): New function.
- (pfatal, pwarn, errexit): Print DEVICE_NAME too if in preen mode.
- * fsck.h: Declare DEVICE_NAME.
- * setup.c (setup): Set DEVICE_NAME.
- * pass1.c, pass2.c, pass3.c, pass4.c, pass5.c (pass1, pass2,
- pass3, pass4, pass5): Call pfix instead of printf.
- * pass1.c (pass1): Only print progress report if not in preen mode.
- * main.c (main): Only print section headers if not in preen mode.
-
-Wed Sep 20 09:11:59 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu>
-
- * utilities.c (pinode): Take a message & args to print as well.
- * fsck.h: Change declaration of pinode.
- * pass2.c (pass2): Use changed pinode.
- * pass3.c (pass3): Use changed pinode.
- * pass4.c (pass4): Use changed pinode.
-
-Tue Sep 19 15:37:02 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu>
-
- * pass1.c (pass1): Change the extent of DBWARN & IBWARN so that
- they actually work.
- * pass2.c (pass2): Adjust our record of link counts when we
- add/change dir entries; also print error messages when we can't.
- * pass4.c (pass4): If an unlinked file can't be reconnected, offer
- to clear it. Once a reconnect attempt fails, don't try again.
- * dir.c (linkup): Print the value of LFNAME rather than `lost+found'.
- (searchdir, changeino): Fix backward compare.
- (linkup): Don't fail when makeentry succeeds.
- (searchdir): Make searchdir return zero if there's an error
- during the search.
- (linkup): Print appropiate error messages if searchdir fails.
- (validdir): Get rid of extra newlines in error messages --
- everyone who calls this routine prints extra information if it
- fails, which should immediately follow.
- * main.c (main): Use getopt to parse command line options.
- (usage): New function.
- (options): New variable.
- (lfname, lfmode): Variables moved here from setup.c.
- (lfname): Made into a char* so that we can change it.
- (lfmode): Get rid of IFDIR; it's added when necessary.
- * fsck.h: Change LFNAME to char*.
- * setup.c (lfname, lfmode): Variables moved to main.c.
-
-Sat Sep 9 12:12:59 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu>
-
- * Makefile (target): Changed to `fsck.ufs'.
- (installationdir): New variable, install into $(sbindir).
-
-Thu Jul 6 15:33:46 1995 Michael I Bushnell <mib@duality.gnu.ai.mit.edu>
-
- * fsck.h (lookup_directory): New decl.
-
- * pass1.c (pass1): Remove assignment from if test.
- * utilities.c (pinode): Likewise.
-
- * Makefile (tables.o): Delete rule.
- (vpath tables.c): Tell where to find tables.c.
-
- * Makefile: Removed dependencies that are now automatically
- generated.
-
-Thu Nov 3 17:19:03 1994 Michael I Bushnell <mib@geech.gnu.ai.mit.edu>
-
- * Makefile (dir): Changed to fsck.
- (target): Changed to fsck.
-
-Wed Nov 2 14:39:13 1994 Michael I Bushnell <mib@geech.gnu.ai.mit.edu>
-
- * pass2.c (pass2): Use DIRECT_NAMLEN instead of d_namlen
- throughout.
- * dir.c (searchdir): Likewise.
- (changeino): Likewise.
- (makeentry): Likewise.
-
-Mon Oct 17 16:07:56 1994 Michael I Bushnell <mib@geech.gnu.ai.mit.edu>
-
- * inode.c (inode_iterate): FN takes new third arg.
- Keep track of new var `offset' and pass it to FN.
- * pass2.c (pass2/checkdirblock): New third arg.
- Only scan DIRBLKSIZ chunks to the total size of the file.
- * dir.c (searchdir/checkdirblock): Likewise.
- (changeino/checkdirblock): Likewise.
- (makeentry/checkdirblock): Likewise.
- * pass1.c (pass1/checkblock): New third arg (ignored).
- * pass1b.c (pass1b/checkblock): Likewise.
-
- * inode.c (inode_iterate): Compute MAXB correctly.
-
- * utilities.c (getinode): Multiple ino_to_fsbo by
- sizeof (struct dinode).
- (write_inode): Likewise.
- (getinode): Inode buffer needs to be a full block, not a
- fragment.
-
-Fri Oct 14 21:07:09 1994 Michael I Bushnell <mib@churchy.gnu.ai.mit.edu>
-
- * utilities.c (lastifrag): New variable.
- (getinode): Use lastifrag instead of buf; Only I/O new block
- if lastifrag isn't what we want.
- (write_inode): Likewise.
-
-Fri Oct 14 17:44:59 1994 Michael I Bushnell <mib@geech.gnu.ai.mit.edu>
-
- * setup.c (setup): Test ISCHR, not ISDIR.
- Fix NCYL against NCG * CPG test.
- Bother to set MAXFSBLOCK, MAXINO, and DIRECT_SYMLINK_EXTENSION.
diff --git a/ufs-fsck/Makefile b/ufs-fsck/Makefile
index f68fe52a..a484428e 100644
--- a/ufs-fsck/Makefile
+++ b/ufs-fsck/Makefile
@@ -18,7 +18,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-dir := fsck
+dir := ufs-fsck
makemode := utility
SRCS = dir.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \
@@ -27,9 +27,9 @@ OBJS = $(subst .c,.o,$(SRCS)) tables.o
LCLHDRS = fsck.h
target = fsck.ufs
installationdir = $(sbindir)
+HURDLIBS=shouldbeinlibc
-vpath tables.c $(top_srcdir)/ufs
+include ../Makeconf
-$(target): ../libshouldbeinlibc/libshouldbeinlibc.a
+vpath tables.c $(top_srcdir)/ufs
-include ../Makeconf
diff --git a/ufs-fsck/dir.c b/ufs-fsck/dir.c
index d4f05858..85757b16 100644
--- a/ufs-fsck/dir.c
+++ b/ufs-fsck/dir.c
@@ -1,5 +1,5 @@
/* Directory management subroutines
- Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1994,96,99,2002 Free Software Foundation, Inc.
Written by Michael I. Bushnell.
This file is part of the GNU Hurd.
@@ -28,19 +28,19 @@ record_directory (struct dinode *dp, ino_t number)
{
u_int blks;
struct dirinfo *dnp;
-
+
blks = howmany (dp->di_size, sblock->fs_bsize);
if (blks > NDADDR)
- blks = NDADDR * NIADDR;
+ blks = NDADDR + NIADDR;
blks *= sizeof (daddr_t);
dnp = malloc (sizeof (struct dirinfo) + blks);
-
+
dnp->i_number = number;
dnp->i_parent = dnp->i_dotdot = 0;
dnp->i_isize = dp->di_size;
dnp->i_numblks = blks;
bcopy (dp->di_db, dnp->i_blks, blks);
-
+
if (dirarrayused == dirarraysize)
{
if (dirarraysize == 0)
@@ -68,12 +68,12 @@ struct dirinfo *
lookup_directory (ino_t ino)
{
int i;
-
+
for (i = 0; i < dirarrayused; i++)
if (dirarray[i]->i_number == ino)
return dirarray[i];
-
- errexit ("Cannot find chached directory I=%d\n", ino);
+
+ errexit ("Cannot find cached directory I=%Ld\n", ino);
}
/* Check to see if DIR is really a readable directory; if it
@@ -87,23 +87,23 @@ validdir (ino_t dir, char *action)
case DIRECTORY:
case DIRECTORY|DIR_REF:
return 1;
-
+
case UNALLOC:
- warning (1, "CANNOT %s I=%d; NOT ALLOCATED", action, dir);
+ warning (1, "CANNOT %s I=%Ld; NOT ALLOCATED", action, dir);
return 0;
-
+
case BADDIR:
- warning (1, "CANNOT %s I=%d; BAD BLOCKS", action, dir);
+ warning (1, "CANNOT %s I=%Ld; BAD BLOCKS", action, dir);
return 0;
-
+
case REG:
- warning (1, "CANNOT %s I=%d; NOT DIRECTORY", action, dir);
+ warning (1, "CANNOT %s I=%Ld; NOT DIRECTORY", action, dir);
return 0;
default:
errexit ("ILLEGAL STATE");
}
-}
+}
/* Search directory DIR for name NAME. If NAME is found, then
set *INO to the inode of the entry; otherwise clear INO. Returns 1 if all
@@ -114,7 +114,7 @@ searchdir (ino_t dir, char *name, ino_t *ino)
struct dinode dino;
int len;
- /* Scan through one directory block and see if it
+ /* Scan through one directory block and see if it
contains NAME. */
void
check1block (void *buf)
@@ -147,7 +147,7 @@ searchdir (ino_t dir, char *name, ino_t *ino)
{
void *buf = alloca (nfrags * sblock->fs_fsize);
void *bufp;
-
+
readblock (fsbtodb (sblock, bno), buf, nfrags * sblock->fs_fsize);
for (bufp = buf;
bufp - buf < nfrags * sblock->fs_fsize
@@ -160,7 +160,7 @@ searchdir (ino_t dir, char *name, ino_t *ino)
}
return 1;
}
-
+
*ino = 0;
if (!validdir (dir, "READ"))
@@ -220,7 +220,7 @@ changeino (ino_t dir, char *name, ino_t ino)
{
void *buf = alloca (nfrags * sblock->fs_fsize);
void *bufp;
-
+
readblock (fsbtodb (sblock, bno), buf, nfrags * sblock->fs_fsize);
for (bufp = buf;
bufp - buf < nfrags * sblock->fs_fsize
@@ -236,10 +236,10 @@ changeino (ino_t dir, char *name, ino_t ino)
}
return 1;
}
-
+
if (!validdir (dir, "REWRITE"))
return 0;
-
+
getinode (dir, &dino);
len = strlen (name);
madechange = 0;
@@ -254,7 +254,7 @@ expanddir (struct dinode *dp)
{
daddr_t lastbn, newblk;
char *cp, buf[sblock->fs_bsize];
-
+
lastbn = lblkno (sblock, dp->di_size);
if (blkoff (sblock, dp->di_size) && lastbn >= NDADDR - 1)
return 0;
@@ -264,24 +264,24 @@ expanddir (struct dinode *dp)
return 0;
else if (!blkoff (sblock, dp->di_size) && dp->di_db[lastbn])
return 0;
-
+
newblk = allocblk (sblock->fs_frag);
if (!newblk)
return 0;
-
+
if (blkoff (sblock, dp->di_size))
dp->di_db[lastbn + 1] = dp->di_db[lastbn];
dp->di_db[lastbn] = newblk;
dp->di_size += sblock->fs_bsize;
dp->di_blocks += sblock->fs_bsize / DEV_BSIZE;
-
+
for (cp = buf; cp < buf + sblock->fs_bsize; cp += DIRBLKSIZ)
{
struct directory_entry *dir = (struct directory_entry *) cp;
dir->d_ino = 0;
dir->d_reclen = DIRBLKSIZ;
}
-
+
writeblock (fsbtodb (sblock, newblk), buf, sblock->fs_bsize);
return 1;
}
@@ -297,10 +297,10 @@ makeentry (ino_t dir, ino_t ino, char *name)
struct dinode dino;
int needed;
int madeentry;
-
+
/* Read a directory block and see if it contains room for the
new entry. If so, add it and return 1; otherwise return 0. */
- int
+ int
check1block (void *buf)
{
struct directory_entry *dp;
@@ -341,7 +341,7 @@ makeentry (ino_t dir, ino_t ino, char *name)
}
}
return 0;
- }
+ }
/* Read part of a directory and look to see if it
contains NAME. Return 1 if we should keep looking
@@ -351,7 +351,7 @@ makeentry (ino_t dir, ino_t ino, char *name)
{
void *buf = alloca (nfrags * sblock->fs_fsize);
void *bufp;
-
+
readblock (fsbtodb (sblock, bno), buf, nfrags * sblock->fs_fsize);
for (bufp = buf;
bufp - buf < nfrags * sblock->fs_fsize
@@ -367,10 +367,10 @@ makeentry (ino_t dir, ino_t ino, char *name)
}
return 1;
}
-
+
if (!validdir (dir, "MODIFY"))
return 0;
-
+
getinode (dir, &dino);
len = strlen (name);
needed = DIRSIZ (len);
@@ -379,7 +379,7 @@ makeentry (ino_t dir, ino_t ino, char *name)
if (!madeentry)
{
/* Attempt to expand the directory. */
- problem (0, "NO SPACE LEFT IN DIR INO=%d", dir);
+ problem (0, "NO SPACE LEFT IN DIR INO=%Ld", dir);
if (preen || reply ("EXPAND"))
{
if (expanddir (&dino))
@@ -408,7 +408,7 @@ allocdir (ino_t parent, ino_t request, mode_t mode)
ino_t ino;
mode |= IFDIR;
-
+
ino = allocino (request, mode);
if (!ino)
return 0;
@@ -416,11 +416,11 @@ allocdir (ino_t parent, ino_t request, mode_t mode)
goto bad;
if (!makeentry (ino, parent, ".."))
goto bad;
-
+
linkfound[ino]++;
linkfound[parent]++;
return ino;
-
+
bad:
freeino (ino);
return 0;
@@ -471,16 +471,16 @@ linkup (ino_t ino, ino_t parent)
}
}
}
-
+
getinode (lfdir, &lfdino);
if ((lfdino.di_model & IFMT) != IFDIR)
{
ino_t oldlfdir;
-
+
problem (1, "`%s' IS NOT A DIRECTORY", lfname);
if (! reply ("REALLOCATE"))
return 0;
-
+
oldlfdir = lfdir;
lfdir = allocdir (ROOTINO, 0, lfmode);
@@ -494,20 +494,20 @@ linkup (ino_t ino, ino_t parent)
warning (1, "SORRY, CANNOT CREATE `%s' DIRECTORY", lfname);
return 0;
}
-
+
/* One less link to the old one */
linkfound[oldlfdir]--;
-
+
getinode (lfdir, &lfdino);
}
-
+
if (inodestate[lfdir] != DIRECTORY && inodestate[lfdir] != (DIRECTORY|DIR_REF))
{
warning (1, "SORRY. `%s' DIRECTORY NOT ALLOCATED", lfname);
return 0;
}
- asprintf (&tempname, "#%d", ino);
+ asprintf (&tempname, "#%Ld", ino);
search_failed = !searchdir (lfdir, tempname, &foo);
while (foo)
{
@@ -519,8 +519,8 @@ linkup (ino_t ino, ino_t parent)
}
if (search_failed)
{
- free (tempname);
warning (1, "FAILURE SEARCHING FOR `%s' IN `%s'", tempname, lfname);
+ free (tempname);
return 0;
}
if (!makeentry (lfdir, ino, tempname))
@@ -531,7 +531,7 @@ linkup (ino_t ino, ino_t parent)
}
free (tempname);
linkfound[ino]++;
-
+
if (parent != -1)
{
/* Reset `..' in ino */
@@ -539,7 +539,7 @@ linkup (ino_t ino, ino_t parent)
{
if (!changeino (ino, "..", lfdir))
{
- warning (1, "CANNOT ADJUST `..' LINK I=%u", ino);
+ warning (1, "CANNOT ADJUST `..' LINK I=%Ld", ino);
return 0;
}
/* Forget about link to old parent */
@@ -547,21 +547,21 @@ linkup (ino_t ino, ino_t parent)
}
else if (!makeentry (ino, lfdir, ".."))
{
- warning (1, "CANNOT CREAT `..' LINK I=%u", ino);
+ warning (1, "CANNOT CREAT `..' LINK I=%Ld", ino);
return 0;
}
-
+
/* Account for link to lost+found; update inode directly
here to avoid confusing warning later. */
linkfound[lfdir]++;
linkcount[lfdir]++;
lfdino.di_nlink++;
write_inode (lfdir, &lfdino);
-
+
if (parent)
- warning (0, "DIR I=%u CONNECTED; PARENT WAS I=%u", ino, parent);
+ warning (0, "DIR I=%Ld CONNECTED; PARENT WAS I=%Ld", ino, parent);
else
- warning (0, "DIR I=%u CONNECTED", ino);
+ warning (0, "DIR I=%Ld CONNECTED", ino);
}
return 1;
}
diff --git a/ufs-fsck/fsck.h b/ufs-fsck/fsck.h
index 7d55bea6..4a5dabf5 100644
--- a/ufs-fsck/fsck.h
+++ b/ufs-fsck/fsck.h
@@ -1,5 +1,5 @@
-/*
- Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
+/*
+ Copyright (C) 1994,95,96,2002 Free Software Foundation, Inc.
Written by Michael I. Bushnell.
This file is part of the GNU Hurd.
@@ -59,7 +59,7 @@ char *blockmap;
extern char *device_name;
-/* Command line flags */
+/* Command line flags */
int nowrite; /* all questions fail */
int noquery; /* all questions succeed */
@@ -81,7 +81,7 @@ struct dirinfo
ino_t i_parent; /* inode entry of parent */
ino_t i_dotdot; /* inode number of `..' */
ino_t i_dot; /* inode number of `.' */
- ino_t i_isize; /* size of inode */
+ u_int i_isize; /* size of inode */
u_int i_numblks; /* size of block array in bytes */
daddr_t i_blks[0]; /* array of inode block addresses */
};
@@ -121,10 +121,10 @@ extern int fix_denied;
extern int fsmodified;
-extern int lfdir;
+extern ino_t lfdir;
/* Total number of files found on the partition. */
-extern daddr_t num_files;
+extern long num_files;
extern mode_t lfmode;
extern char *lfname;
@@ -145,7 +145,7 @@ extern char *lfname;
#define DI_MODE(dp) (((dp)->di_modeh << 16) | (dp)->di_model)
-
+
int setup (char *);
void pass1 (), pass1b (), pass2 (), pass3 (), pass4 (), pass5 ();
diff --git a/ufs-fsck/main.c b/ufs-fsck/main.c
index b5af2d88..34c32a67 100644
--- a/ufs-fsck/main.c
+++ b/ufs-fsck/main.c
@@ -1,5 +1,5 @@
/* Main program for GNU fsck
- Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc.
Written by Michael I. Bushnell.
This file is part of the GNU Hurd.
@@ -21,10 +21,11 @@
#include <errno.h>
#include <argp.h>
#include <hurd.h>
+#include <version.h>
#include "fsck.h"
-char *argp_program_version = "fsck.ufs 1.0 (GNU " HURD_RELEASE ")";
+const char *argp_program_version = STANDARD_HURD_VERSION (fsck.ufs);
char *lfname = "lost+found";
mode_t lfmode = 0755;
diff --git a/ufs-fsck/pass1.c b/ufs-fsck/pass1.c
index 066f4649..bd41cc62 100644
--- a/ufs-fsck/pass1.c
+++ b/ufs-fsck/pass1.c
@@ -1,5 +1,5 @@
/* Pass one of GNU fsck -- count blocks and verify inodes
- Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1994,95,96,2002 Free Software Foundation, Inc.
Written by Michael I. Bushnell.
This file is part of the GNU Hurd.
@@ -24,7 +24,7 @@
static struct dinode zino;
-/* Find all the blocks in use by files and filesystem reserved blocks.
+/* Find all the blocks in use by files and filesystem reserved blocks.
Set them in the global block map. For each file, if a block is found
allocated twice, then record the block and inode in DUPLIST.
Initialize INODESTATE, LINKCOUNT, and TYPEMAP. */
@@ -52,7 +52,7 @@ pass1 ()
node. Increment NBLOCKS by the number of data blocks held.
Set BLKERROR if this block is invalid.
Return RET_GOOD, RET_BAD, RET_STOP if the block is good,
- bad, or if we should entirely stop checking blocks in this
+ bad, or if we should entirely stop checking blocks in this
inode. */
int
checkblock (daddr_t bno, int nfrags, off_t offset)
@@ -69,10 +69,10 @@ pass1 ()
blkerror = 1;
wasbad = 1;
if (nblkrngerrors == 0)
- warning (0, "I=%d HAS BAD BLOCKS", number);
+ warning (0, "I=%Ld HAS BAD BLOCKS", number);
if (nblkrngerrors++ > MAXBAD)
{
- problem (0, "EXCESSIVE BAD BLKS I=%d", number);
+ problem (0, "EXCESSIVE BAD BLKS I=%Ld", number);
if (preen || reply ("SKIP"))
{
pfail ("SKIPPING");
@@ -93,12 +93,12 @@ pass1 ()
{
blkerror = 1;
if (nblkduperrors == 0)
- warning (0, "I=%d HAS DUPLICATE BLOCKS", number);
+ warning (0, "I=%Ld HAS DUPLICATE BLOCKS", number);
warning (0, "DUPLICATE BLOCK %ld", bno);
wasbad = 1;
if (nblkduperrors++ > MAXBAD)
{
- problem (0, "EXCESSIVE DUP BLKS I=%d", number);
+ problem (0, "EXCESSIVE DUP BLKS I=%Ld", number);
if (preen || reply ("SKIP"))
{
pfail ("SKIPPING");
@@ -128,16 +128,16 @@ pass1 ()
}
return wasbad ? RET_BAD : RET_GOOD;
}
-
+
/* Account for blocks used by meta data */
for (cg = 0; cg < sblock->fs_ncg; cg++)
{
daddr_t firstdata, firstcgblock, bno;
-
+
/* Each cylinder group past the first reserves data
from its cylinder group copy to (but not including)
- the first datablock.
+ the first datablock.
The first, however, reserves from the very front of the
cylinder group (thus including the boot block), and it also
@@ -155,7 +155,7 @@ pass1 ()
for (bno = firstcgblock; bno < firstdata; bno++)
setbmap (bno);
}
-
+
/* Loop through each inode, doing initial checks */
for (number = 0, cg = 0; cg < sblock->fs_ncg; cg++)
for (i = 0; i < sblock->fs_ipg; i++, number++)
@@ -165,15 +165,15 @@ pass1 ()
int dbwarn = 0, ibwarn = 0;
/* if (!preen && !(number % 10000))
- printf ("I=%d\n", number); */
+ printf ("I=%Ld\n", number); */
if (number < ROOTINO)
continue;
-
+
getinode (number, dp);
mode = DI_MODE (dp);
type = mode & IFMT;
-
+
/* If the node is not allocated, then make sure it's
properly clear */
if (type == 0)
@@ -184,7 +184,7 @@ pass1 ()
|| DI_MODE (dp)
|| dp->di_size)
{
- problem (0, "PARTIALLY ALLOCATED INODE I=%d", number);
+ problem (0, "PARTIALLY ALLOCATED INODE I=%Ld", number);
if (preen || reply ("CLEAR"))
{
clear_inode (number, dp);
@@ -196,15 +196,15 @@ pass1 ()
else
{
/* Node is allocated. */
-
+
/* Check to see if we think the node should be cleared */
/* Verify size for basic validity */
holdallblocks = 0;
-
+
if (dp->di_size + sblock->fs_bsize - 1 < dp->di_size)
{
- problem (1, "OVERFLOW IN FILE SIZE I=%d (SIZE == %lld)", number,
+ problem (1, "OVERFLOW IN FILE SIZE I=%Ld (SIZE == %lld)", number,
dp->di_size);
if (reply ("CLEAR"))
{
@@ -213,12 +213,12 @@ pass1 ()
continue;
}
inodestate[number] = UNALLOC;
- warning (0, "WILL TREAT ANY BLOCKS HELD BY I=%d AS ALLOCATED",
+ warning (0, "WILL TREAT ANY BLOCKS HELD BY I=%Ld AS ALLOCATED",
number);
holdallblocks = 1;
}
- /* Decode type and set NDB
+ /* Decode type and set NDB
also set inodestate correctly. */
inodestate[number] = REG;
switch (type)
@@ -227,19 +227,19 @@ pass1 ()
case IFCHR:
ndb = 1;
break;
-
+
case IFIFO:
case IFSOCK:
ndb = 0;
break;
-
+
case IFLNK:
if (sblock->fs_maxsymlinklen != -1)
{
/* Check to see if this is a fastlink. The
old fast link format has fs_maxsymlinklen
of zero and di_blocks zero; the new format has
- fs_maxsymlinklen set and we ignore di_blocks.
+ fs_maxsymlinklen set and we ignore di_blocks.
So check for either. */
if ((sblock->fs_maxsymlinklen
&& dp->di_size < sblock->fs_maxsymlinklen)
@@ -262,16 +262,16 @@ pass1 ()
else
ndb = howmany (dp->di_size, sblock->fs_bsize);
break;
-
+
case IFDIR:
inodestate[number] = DIRECTORY;
/* Fall through */
case IFREG:
ndb = howmany (dp->di_size, sblock->fs_bsize);
break;
-
+
default:
- problem (1, "UNKNOWN FILE TYPE I=%d (MODE=%ol)", number, mode);
+ problem (1, "UNKNOWN FILE TYPE I=%Ld (MODE=%ol)", number, mode);
if (reply ("CLEAR"))
{
clear_inode (number, dp);
@@ -280,14 +280,14 @@ pass1 ()
}
inodestate[number] = UNALLOC;
holdallblocks = 1;
- warning (0, "WILL TREAT ANY BLOCKS HELD BY I=%d "
+ warning (0, "WILL TREAT ANY BLOCKS HELD BY I=%Ld "
"AS ALLOCATED", number);
ndb = 0;
}
if (ndb < 0)
{
- problem (1, "BAD FILE SIZE I= %d (SIZE == %lld)", number,
+ problem (1, "BAD FILE SIZE I= %Ld (SIZE == %lld)", number,
dp->di_size);
if (reply ("CLEAR"))
{
@@ -296,7 +296,7 @@ pass1 ()
continue;
}
inodestate[number] = UNALLOC;
- warning (0, "WILL TREAT ANY BLOCKS HELD BY I=%d AS ALLOCATED",
+ warning (0, "WILL TREAT ANY BLOCKS HELD BY I=%Ld AS ALLOCATED",
number);
holdallblocks = 1;
}
@@ -308,10 +308,10 @@ pass1 ()
if (!holdallblocks)
{
if (dp->di_size
- && (type == IFBLK || type == IFCHR
+ && (type == IFBLK || type == IFCHR
|| type == IFSOCK || type == IFIFO))
{
- problem (1, "SPECIAL NODE I=%d (MODE=%ol) HAS SIZE %lld",
+ problem (1, "SPECIAL NODE I=%Ld (MODE=%ol) HAS SIZE %lld",
number, mode, dp->di_size);
if (reply ("TRUNCATE"))
{
@@ -319,10 +319,10 @@ pass1 ()
write_inode (number, dp);
}
}
-
+
/* If we haven't set NDB speciall above, then it is set from
the file size correctly by the size check. */
-
+
/* Check all the direct and indirect blocks that are past the
amount necessary to be zero. */
for (lbn = ndb; lbn < NDADDR; lbn++)
@@ -332,7 +332,7 @@ pass1 ()
if (!dbwarn)
{
dbwarn = 1;
- problem (0, "INODE I=%d HAS EXTRA DIRECT BLOCKS",
+ problem (0, "INODE I=%Ld HAS EXTRA DIRECT BLOCKS",
number);
if (preen || reply ("DEALLOCATE"))
{
@@ -357,7 +357,7 @@ pass1 ()
if (ibwarn)
{
ibwarn = 1;
- problem (0, "INODE I=%d HAS EXTRA INDIRECT BLOCKS",
+ problem (0, "INODE I=%Ld HAS EXTRA INDIRECT BLOCKS",
number);
if (preen || reply ("DEALLOCATE"))
{
@@ -373,7 +373,7 @@ pass1 ()
write_inode (number, dp);
}
}
-
+
/* If this node is really allocated (as opposed to something
that we should clear but the user won't) then set LINKCOUNT
and TYPEMAP entries. */
@@ -397,7 +397,7 @@ pass1 ()
warning (1, "DUPLICATE or BAD BLOCKS");
else
{
- problem (0, "I=%d has ", number);
+ problem (0, "I=%Ld has ", number);
if (nblkduperrors)
{
pextend ("%d DUPLICATE BLOCKS", nblkduperrors);
@@ -418,7 +418,7 @@ pass1 ()
}
else if (dp->di_blocks != nblocks)
{
- problem (0, "INCORRECT BLOCK COUNT I=%d (%ld should be %d)",
+ problem (0, "INCORRECT BLOCK COUNT I=%Ld (%ld should be %d)",
number, dp->di_blocks, nblocks);
if (preen || reply ("CORRECT"))
{
@@ -435,5 +435,3 @@ pass1 ()
}
}
}
-
-
diff --git a/ufs-fsck/pass1b.c b/ufs-fsck/pass1b.c
index 0cf50a17..4da86974 100644
--- a/ufs-fsck/pass1b.c
+++ b/ufs-fsck/pass1b.c
@@ -1,5 +1,5 @@
/* Pass 1b of fsck -- scan inodes for references to duplicate blocks
- Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1994,96,2002 Free Software Foundation, Inc.
Written by Michael I. Bushnell.
This file is part of the GNU Hurd.
@@ -31,7 +31,7 @@ pass1b ()
struct dups *duphead = duplist;
/* Check each block of file DP; if the block is in the dup block
- list then add it to the dup block list under this file.
+ list then add it to the dup block list under this file.
Return RET_GOOD or RET_BAD if the block is
good or bad, respectively. */
int
@@ -39,7 +39,7 @@ pass1b ()
{
struct dups *dlp;
int hadbad = 0;
-
+
for (; nfrags > 0; bno++, nfrags--)
{
if (check_range (bno, 1))
@@ -76,7 +76,7 @@ pass1b ()
allblock_iterate (dp, checkblock);
if (dupblk)
{
- problem (1, "I=%d HAS %d DUPLICATE BLOCKS", number, dupblk);
+ problem (1, "I=%Ld HAS %d DUPLICATE BLOCKS", number, dupblk);
if (reply ("CLEAR"))
{
clear_inode (number, dp);
@@ -88,5 +88,3 @@ pass1b ()
}
}
}
-
-
diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c
index db63abd7..d95929ef 100644
--- a/ufs-fsck/pass2.c
+++ b/ufs-fsck/pass2.c
@@ -1,5 +1,5 @@
/* Pass 2 of GNU fsck -- examine all directories for validity
- Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1994,96,2002 Free Software Foundation, Inc.
Written by Michael I. Bushnell.
This file is part of the GNU Hurd.
@@ -19,6 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "fsck.h"
+#include <assert.h>
/* Verify root inode's allocation and check all directories for
viability. Set DIRSORTED array fully and check to make sure
@@ -69,7 +70,7 @@ pass2 ()
for (bp = (char *)buf; bp < (char *)buf + DIRBLKSIZ; bp++)
if (*bp)
goto reclen_problem;
-
+
problem (0, "NULL BLOCK IN DIRECTORY");
if (preen || reply ("PATCH"))
{
@@ -82,7 +83,7 @@ pass2 ()
else
return mod;
}
-
+
reclen_problem:
problem (1, "BAD RECLEN IN DIRECTORY");
if (reply ("SALVAGE"))
@@ -97,7 +98,7 @@ pass2 ()
/* But give up regardless */
return mod;
}
-
+
/* Check INO */
if (dp->d_ino > maxino)
{
@@ -112,7 +113,7 @@ pass2 ()
if (!dp->d_ino)
continue;
-
+
/* Check INO */
if (inodestate[dp->d_ino] == UNALLOC)
{
@@ -137,7 +138,7 @@ pass2 ()
dp->d_ino = 0;
mod = 1;
}
- }
+ }
else
{
/* Check for illegal characters */
@@ -164,7 +165,7 @@ pass2 ()
}
}
}
-
+
if (!dp->d_ino)
continue;
@@ -180,10 +181,10 @@ pass2 ()
mod = 1;
}
}
-
+
/* Here we should check for duplicate directory entries;
that's too much trouble right now. */
-
+
/* Account for the inode in the linkfound map */
if (inodestate[dp->d_ino] != UNALLOC)
linkfound[dp->d_ino]++;
@@ -204,7 +205,7 @@ pass2 ()
{
problem (0, "EXTRANEOUS LINK `%s' TO DIR I=%ld",
dp->d_name, dp->d_ino);
- pextend (" FOUND IN DIR I=%d", dnp->i_number);
+ pextend (" FOUND IN DIR I=%Ld", dnp->i_number);
if (preen || reply ("REMOVE"))
{
dp->d_ino = 0;
@@ -233,9 +234,9 @@ pass2 ()
readblock (fsbtodb (sblock, bno), buf, nfrags * sblock->fs_fsize);
rewrite = 0;
- for (bufp = buf;
+ for (bufp = buf;
bufp - buf < nfrags * sblock->fs_fsize
- && offset + (bufp - buf) + DIRBLKSIZ <= dnp->i_isize;
+ && offset + (bufp - buf) + DIRBLKSIZ <= dnp->i_isize;
bufp += DIRBLKSIZ)
{
if (check1block (bufp))
@@ -250,7 +251,7 @@ pass2 ()
{
default:
errexit ("BAD STATE %d FOR ROOT INODE", (int) (inodestate[ROOTINO]));
-
+
case DIRECTORY:
break;
@@ -261,7 +262,7 @@ pass2 ()
if (allocdir (ROOTINO, ROOTINO, 0755) != ROOTINO)
errexit ("CANNOT ALLOCATE ROOT INODE");
break;
-
+
case REG:
problem (1, "ROOT INODE NOT DIRECTORY");
if (reply ("REALLOCATE"))
@@ -269,7 +270,7 @@ pass2 ()
if (allocdir (ROOTINO, ROOTINO, 0755) != ROOTINO)
errexit ("CANNOT ALLOCATE ROOT INODE");
break;
-
+
case BADDIR:
problem (1, "DUPLICATE or BAD BLOCKS IN ROOT INODE");
if (reply ("REALLOCATE"))
@@ -282,20 +283,20 @@ pass2 ()
errexit ("ABORTING");
break;
}
-
+
/* Sort inpsort */
qsort (dirsorted, dirarrayused, sizeof (struct dirinfo *), sortfunc);
-
+
/* Check basic integrity of each directory */
for (nd = 0; nd < dirarrayused; nd++)
{
dnp = dirsorted[nd];
-
+
if (dnp->i_isize == 0)
continue;
if (dnp->i_isize % DIRBLKSIZ)
{
- problem (0, "DIRECTORY INO=%d: LENGTH %d NOT MULTIPLE OF %d",
+ problem (0, "DIRECTORY INO=%Ld: LENGTH %d NOT MULTIPLE OF %d",
dnp->i_number, dnp->i_isize, DIRBLKSIZ);
if (preen || reply ("ADJUST"))
{
@@ -307,11 +308,12 @@ pass2 ()
}
bzero (&dino, sizeof (struct dinode));
dino.di_size = dnp->i_isize;
+ assert (dnp->i_numblks <= (NDADDR + NIADDR) * sizeof (daddr_t));
bcopy (dnp->i_blks, dino.di_db, dnp->i_numblks);
-
+
datablocks_iterate (&dino, checkdirblock);
}
-
+
/* At this point for each directory:
If this directory is an entry in another directory, then i_parent is
@@ -321,12 +323,12 @@ pass2 ()
for (nd = 0; nd < dirarrayused; nd++)
{
dnp = dirsorted[nd];
-
+
/* Root is considered to be its own parent even though it isn't
listed. */
if (dnp->i_number == ROOTINO && !dnp->i_parent)
dnp->i_parent = ROOTINO;
-
+
/* Check `.' to make sure it exists and is correct */
if (dnp->i_dot == 0)
{
@@ -395,5 +397,4 @@ pass2 ()
}
}
}
-}
-
+}
diff --git a/ufs-fsck/pass5.c b/ufs-fsck/pass5.c
index 7ea7aeed..cb426a7d 100644
--- a/ufs-fsck/pass5.c
+++ b/ufs-fsck/pass5.c
@@ -1,5 +1,5 @@
/* Pass 5 of GNU fsck -- check allocation maps and summaries
- Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1994,96,2001 Free Software Foundation, Inc.
Written by Michael I. Bushnell.
This file is part of the GNU Hurd.
@@ -23,7 +23,7 @@
/* From ../ufs/subr.c: */
/*
- * Update the frsum fields to reflect addition or deletion
+ * Update the frsum fields to reflect addition or deletion
* of some frags.
*/
static void
@@ -87,7 +87,7 @@ pass5 ()
sbcsums = alloca (fragroundup (sblock, sblock->fs_cssize));
- readblock (fsbtodb (sblock, sblock->fs_csaddr), sbcsums,
+ readblock (fsbtodb (sblock, sblock->fs_csaddr), sbcsums,
fragroundup (sblock, sblock->fs_cssize));
/* Construct a CG structure; initialize everything that's the same
@@ -105,37 +105,37 @@ pass5 ()
savednrpos = sblock->fs_nrpos;
sblock->fs_nrpos = 8;
break;
-
+
case FS_DYNAMICPOSTBLFMT:
/* Set fields unique to new cg structure */
newcg->cg_btotoff = &newcg->cg_space[0] - (u_char *)(&newcg->cg_link);
newcg->cg_boff = newcg->cg_btotoff + sblock->fs_cpg * sizeof (long);
newcg->cg_iusedoff = newcg->cg_boff + (sblock->fs_cpg
- * sblock->fs_nrpos
+ * sblock->fs_nrpos
* sizeof (short));
newcg->cg_freeoff = newcg->cg_iusedoff + howmany (sblock->fs_ipg, NBBY);
if (sblock->fs_contigsumsize <= 0)
{
- newcg->cg_nextfreeoff =
+ newcg->cg_nextfreeoff =
(newcg->cg_freeoff
+ howmany (sblock->fs_cpg * sblock->fs_spc / NSPF (sblock),
NBBY));
}
else
{
- newcg->cg_clustersumoff =
+ newcg->cg_clustersumoff =
(newcg->cg_freeoff
+ howmany (sblock->fs_cpg * sblock->fs_spc / NSPF (sblock), NBBY)
- sizeof (long));
- newcg->cg_clustersumoff =
+ newcg->cg_clustersumoff =
roundup (newcg->cg_clustersumoff, sizeof (long));
- newcg->cg_clusteroff =
- (newcg->cg_clustersumoff
+ newcg->cg_clusteroff =
+ (newcg->cg_clustersumoff
+ (sblock->fs_contigsumsize + 1) * sizeof (long));
- newcg->cg_nextfreeoff =
- (newcg->cg_clusteroff
- + howmany (sblock->fs_cpg * sblock->fs_spc / NSPB (sblock),
+ newcg->cg_nextfreeoff =
+ (newcg->cg_clusteroff
+ + howmany (sblock->fs_cpg * sblock->fs_spc / NSPB (sblock),
NBBY));
}
@@ -150,32 +150,32 @@ pass5 ()
default:
errexit ("UNKNOWN POSTBL FORMAT");
}
-
+
bzero (&cstotal, sizeof (struct csum));
/* Mark fragments past the end of the filesystem as used. */
j = blknum (sblock, sblock->fs_size + sblock->fs_frag - 1);
for (i = sblock->fs_size; i < j; i++)
setbmap (i);
-
+
/* Now walk through the cylinder groups, checking each one. */
for (c = 0; c < sblock->fs_ncg; c++)
{
int dbase, dmax;
-
+
/* Read the cylinder group structure */
readblock (fsbtodb (sblock, cgtod (sblock, c)), cg, sblock->fs_cgsize);
writecg = 0;
-
+
if (!cg_chkmagic (cg))
warning (1, "CG %d: BAD MAGIC NUMBER", c);
-
+
/* Compute first and last data block addresses in this group */
dbase = cgbase (sblock, c);
dmax = dbase + sblock->fs_fpg;
if (dmax > sblock->fs_size)
dmax = sblock->fs_size;
-
+
/* Initialize newcg fully; values from cg for those
we can't check. */
newcg->cg_time = cg->cg_time;
@@ -230,7 +230,7 @@ pass5 ()
pfix ("FIXED");
}
}
-
+
/* Zero the block maps and summary areas */
bzero (&newcg->cg_frsum[0], sizeof newcg->cg_frsum);
bzero (&cg_blktot (newcg)[0], sumsize + mapsize);
@@ -267,8 +267,8 @@ pass5 ()
setbit (cg_inosused (newcg), i);
newcg->cg_cs.cs_nifree--;
}
-
- /* Walk through each data block, accounting for it in
+
+ /* Walk through each data block, accounting for it in
the block map and in newcg->cg_cs. */
/* In this look, D is the block number and I is the
block number relative to this CG. */
@@ -277,7 +277,7 @@ pass5 ()
d += sblock->fs_frag, i += sblock->fs_frag)
{
int frags = 0;
-
+
/* Set each free frag of this block in the block map;
count how many frags were free. */
for (j = 0; j < sblock->fs_frag; j++)
@@ -287,8 +287,8 @@ pass5 ()
setbit (cg_blksfree (newcg), i + j);
frags++;
}
-
- /* If all the frags were free, then count this as
+
+ /* If all the frags were free, then count this as
a free block too. */
if (frags == sblock->fs_frag)
{
@@ -308,7 +308,7 @@ pass5 ()
ffs_fragacct (sblock, blk, newcg->cg_frsum, 1);
}
}
-
+
if (sblock->fs_contigsumsize > 0)
{
long *sump = cg_clustersum (newcg);
@@ -316,7 +316,7 @@ pass5 ()
int map = *mapp++;
int bit = 1;
int run = 0;
-
+
for (i = 0; i < newcg->cg_nclusterblks; i++)
{
if ((map & bit) != 0)
@@ -363,7 +363,7 @@ pass5 ()
pfix ("FIXED");
}
}
-
+
/* Check inode and block maps */
if (bcmp (cg_inosused (newcg), cg_inosused (cg), mapsize))
{
@@ -375,7 +375,7 @@ pass5 ()
pfix ("FIXED");
}
}
-
+
if (bcmp (&cg_blktot(newcg)[0], &cg_blktot(cg)[0], sumsize))
{
problem (0, "SUMMARY INFORMATION FOR CG %d BAD", c);
@@ -386,7 +386,7 @@ pass5 ()
pfix ("FIXED");
}
}
-
+
if (bcmp (newcg, cg, basesize))
{
problem (0, "CYLINDER GROUP %d BAD", c);
@@ -399,14 +399,14 @@ pass5 ()
}
if (writecg)
- writeblock (fsbtodb (sblock, cgtod (sblock, c)),
+ writeblock (fsbtodb (sblock, cgtod (sblock, c)),
cg, sblock->fs_cgsize);
}
-
+
/* Restore nrpos */
if (sblock->fs_postblformat == FS_42POSTBLFMT)
sblock->fs_nrpos = savednrpos;
-
+
if (bcmp (&cstotal, &sblock->fs_cstotal, sizeof (struct csum)))
{
problem (0, "TOTAL FREE BLK COUNTS WRONG IN SUPERBLOCK");
@@ -430,21 +430,21 @@ pass5 ()
pfix ("MARKED CLEAN");
}
}
-
+
if (writesb)
writeblock (SBLOCK, sblock, SBSIZE);
if (writecsum)
{
+ const int cssize = fragroundup (sblock, sblock->fs_cssize);
struct csum *test;
-
- writeblock (fsbtodb (sblock, sblock->fs_csaddr), sbcsums,
+
+ writeblock (fsbtodb (sblock, sblock->fs_csaddr), sbcsums,
fragroundup (sblock, sblock->fs_cssize));
- test = alloca (fragroundup (sblock, sblock->fs_cssize));
- readblock (fsbtodb (sblock, sblock->fs_csaddr), test,
- fragroundup (sblock, sblock->fs_cssize));
- if (bcmp (test, sbcsums, fragroundup (sblock, sblock->fs_cssize)))
+ test = alloca (cssize);
+ readblock (fsbtodb (sblock, sblock->fs_csaddr), test, cssize);
+ if (bcmp (test, sbcsums, cssize))
warning (0, "CSUM WRITE INCONSISTENT");
}
}
diff --git a/ufs-fsck/setup.c b/ufs-fsck/setup.c
index d40cf70b..9433bd68 100644
--- a/ufs-fsck/setup.c
+++ b/ufs-fsck/setup.c
@@ -1,5 +1,5 @@
-/*
- Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+/*
+ Copyright (C) 1994,96,99,2002 Free Software Foundation, Inc.
Written by Michael I. Bushnell.
This file is part of the GNU Hurd.
@@ -42,7 +42,7 @@ int fix_denied = 0;
int fsmodified = 0;
-int lfdir;
+ino_t lfdir;
/* Get ready to run on device with pathname DEV. */
int
@@ -51,7 +51,7 @@ setup (char *dev)
struct stat st;
int changedsb;
size_t bmapsize;
-
+
device_name = dev;
if (stat (dev, &st) == -1)
@@ -59,9 +59,9 @@ setup (char *dev)
error (0, errno, "%s", dev);
return 0;
}
- if (!S_ISCHR (st.st_mode))
+ if (!S_ISCHR (st.st_mode) && !S_ISBLK (st.st_mode))
{
- problem (1, "%s is not a character device", dev);
+ problem (1, "%s is not a character or block device", dev);
if (! reply ("CONTINUE"))
return 0;
}
@@ -88,7 +88,7 @@ setup (char *dev)
if (preen == 0)
printf ("\n");
-
+
lfdir = 0;
/* We don't do the alternate superblock stuff here (yet). */
@@ -171,10 +171,10 @@ setup (char *dev)
sblock->fs_qfmask = ~sblock->fs_fmask;
newinofmt = 0;
}
-
+
if (changedsb)
writeblock (SBLOCK, sblock, SBSIZE);
-
+
/* Constants */
maxfsblock = sblock->fs_size;
maxino = sblock->fs_ncg * sblock->fs_ipg;
@@ -189,6 +189,3 @@ setup (char *dev)
linkfound = calloc (maxino + 1, sizeof (nlink_t));
return 1;
}
-
-
-
diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c
index 4c515f61..14705f84 100644
--- a/ufs-fsck/utilities.c
+++ b/ufs-fsck/utilities.c
@@ -1,5 +1,5 @@
/* Miscellaneous functions for fsck
- Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1994,95,96,99,2001,02 Free Software Foundation, Inc.
Written by Michael I. Bushnell.
This file is part of the GNU Hurd.
@@ -25,6 +25,7 @@
#include <stdarg.h>
#include <pwd.h>
#include <error.h>
+#include <time.h>
static void retch (char *reason);
@@ -61,12 +62,12 @@ getinode (ino_t ino, struct dinode *di)
if (!lastifrag)
lastifrag = malloc (sblock->fs_bsize);
-
+
iblk = ino_to_fsba (sblock, ino);
if (iblk != lastifragaddr)
readblock (fsbtodb (sblock, iblk), lastifrag, sblock->fs_bsize);
lastifragaddr = iblk;
- bcopy (lastifrag + ino_to_fsbo (sblock, ino) * sizeof (struct dinode),
+ bcopy (lastifrag + ino_to_fsbo (sblock, ino) * sizeof (struct dinode),
di, sizeof (struct dinode));
}
@@ -75,7 +76,7 @@ void
write_inode (ino_t ino, struct dinode *di)
{
daddr_t iblk;
-
+
iblk = ino_to_fsba (sblock, ino);
if (iblk != lastifragaddr)
readblock (fsbtodb (sblock, iblk), lastifrag, sblock->fs_bsize);
@@ -101,10 +102,10 @@ allocblk (int nfrags)
{
daddr_t i;
int j, k;
-
+
if (nfrags <= 0 || nfrags > sblock->fs_frag)
return 0;
-
+
/* Examine each block of the filesystem. */
for (i = 0; i < maxfsblock - sblock->fs_frag; i += sblock->fs_frag)
{
@@ -115,7 +116,7 @@ allocblk (int nfrags)
for (k = 0; k < nfrags; k++)
if (testbmap (i + j + k))
break;
-
+
/* If one of the frags was allocated... */
if (k < nfrags)
{
@@ -123,7 +124,7 @@ allocblk (int nfrags)
j += k;
continue;
}
-
+
/* It's free (at address i + j) */
/* Mark the frags allocated in our map */
@@ -136,16 +137,16 @@ allocblk (int nfrags)
return 0;
}
-/* Check if a block starting at BLK and extending for CNT
+/* Check if a block starting at BLK and extending for CNT
fragments is out of range; if it is, then return 1; otherwise return 0. */
int
check_range (daddr_t blk, int cnt)
{
int c;
-
+
if ((unsigned)(blk + cnt) > maxfsblock)
return 1;
-
+
c = dtog (sblock, blk);
if (blk < cgdmin (sblock, c))
{
@@ -157,9 +158,9 @@ check_range (daddr_t blk, int cnt)
if (blk + cnt > cgbase (sblock, c + 1))
return 1;
}
-
+
return 0;
-}
+}
struct problem {
char *desc;
@@ -236,7 +237,7 @@ flush_problems ()
{
fail (problems)->prev = free_problems;
free_problems = problems;
- }
+ }
}
/* Like printf, but exit after printing. */
@@ -269,14 +270,14 @@ retch (char *reason)
static void
punt (char *msg)
{
- problem (0, msg);
+ problem (0, "%s", msg);
flush_problems ();
exit (8);
}
/* If SEVERE is true, and we're in preen mode, then things are too hair to
fix automatically, so tell the user to do it himself and punt. */
-static void
+static void
no_preen (int severe)
{
if (severe && preen)
@@ -295,7 +296,7 @@ problem (int severe, char *fmt, ...)
va_start (args, fmt);
push_problem (fmt, args);
va_end (args);
-
+
no_preen (severe);
}
@@ -322,6 +323,7 @@ pextend (char *fmt, ...)
strcpy (concat + strlen (concat), more);
prob->desc = concat;
+ free (more);
}
/* Like problem, but as if immediately followed by pfail. */
@@ -353,7 +355,7 @@ pinode (int severe, ino_t ino, char *fmt, ...)
}
if (ino < ROOTINO || ino > maxino)
- pextend (" (BOGUS INODE) I=%d", ino);
+ pextend (" (BOGUS INODE) I=%Ld", ino);
else
{
char *p;
@@ -362,7 +364,7 @@ pinode (int severe, ino_t ino, char *fmt, ...)
getinode (ino, &dino);
- pextend (" %s I=%d", (DI_MODE (&dino) & IFMT) == IFDIR ? "DIR" : "FILE",
+ pextend (" %s I=%Ld", (DI_MODE (&dino) & IFMT) == IFDIR ? "DIR" : "FILE",
ino);
pw = getpwuid (dino.di_uid);
@@ -370,7 +372,7 @@ pinode (int severe, ino_t ino, char *fmt, ...)
pextend (" O=%s", pw->pw_name);
else
pextend (" O=%lu", dino.di_uid);
-
+
pextend (" M=0%o", DI_MODE (&dino));
pextend (" SZ=%llu", dino.di_size);
p = ctime (&dino.di_mtime.tv_sec);
@@ -406,7 +408,7 @@ reply (char *question)
{
int persevere;
char c;
-
+
if (preen)
retch ("Got to reply() in preen mode");
@@ -448,6 +450,6 @@ reply (char *question)
{
fix_denied = 1;
return 0;
- }
+ }
}
}