summaryrefslogtreecommitdiff
path: root/e2fsck
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>1997-04-26 14:37:06 +0000
committerTheodore Ts'o <tytso@mit.edu>1997-04-26 14:37:06 +0000
commit74becf3c0a065f8d64e07ce4d31f9fe53be91d62 (patch)
treedf6573f851195eb5a0beaa0bc540a74fc89cda3d /e2fsck
parent900e442732393189b8ecfd3bb39176e398b24970 (diff)
downloade2fsprogs-74becf3c0a065f8d64e07ce4d31f9fe53be91d62.tar.gz
Many files:
Checkin of e2fsprogs 1.02.
Diffstat (limited to 'e2fsck')
-rw-r--r--e2fsck/ChangeLog29
-rw-r--r--e2fsck/Makefile.in13
-rw-r--r--e2fsck/badblocks.c93
-rw-r--r--e2fsck/e2fsck.8.in (renamed from e2fsck/e2fsck.8)14
-rw-r--r--e2fsck/e2fsck.c10
-rw-r--r--e2fsck/e2fsck.h1
-rw-r--r--e2fsck/pass1.c23
7 files changed, 107 insertions, 76 deletions
diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog
index c1d04c9c..22969e5b 100644
--- a/e2fsck/ChangeLog
+++ b/e2fsck/ChangeLog
@@ -1,3 +1,32 @@
+Wed Jan 31 11:06:08 1996 <tytso@rsts-11.mit.edu>
+
+ * Release of E2fsprogs version 1.02
+
+Wed Dec 15 21:24:26 1996 <tytso@rsts-11.mit.edu>
+
+ * pass1.c (process_block): Check to see if a file is "fragmented".
+ i.e., non-contiguous. Note that any file which is larger
+ than the block group is guaranteed to be non-contiguous.
+ We may want to use a different hueristic for deciding
+ whether or not a file is "fragmented".
+
+ * e2fsck.c (show_stats): Print statistics of how many
+ non-contiguous files are on the system.
+
+Fri Dec 15 19:19:47 1995 <tytso@rsts-11.mit.edu>
+
+ * badblocks.c (read_bad_blocks_file, test_disk): Fold
+ functionality of test_disk() (which runs badblocks) into
+ read_bad_blocks_file(); test_disk() now calls
+ read_bad_blocks_file() with a NULL bad_blocks_file
+ argument.
+
+Mon Nov 20 18:30:10 1995 <tytso@rsts-11.mit.edu>
+
+ * e2fsck.c (check_mount): Use #if defined(__linux__) instead of
+ #if defined(linux). The latter won't work if we're
+ compiling -ansi.
+
Mon Oct 30 20:31:17 1995 <tytso@rsts-11.mit.edu>
* e2fsck.c (check_mount): For Linux systems, the check to see if
diff --git a/e2fsck/Makefile.in b/e2fsck/Makefile.in
index 328fc55a..9ed236ea 100644
--- a/e2fsck/Makefile.in
+++ b/e2fsck/Makefile.in
@@ -18,7 +18,7 @@ LIBS= -L../lib -lss -lcom_err -lext2fs $(CHECKLIB)
DEPLIBS= ../lib/libss.a ../lib/libcom_err.a ../lib/libext2fs.a
.c.o:
- $(CC) -c $(CFLAGS) $< -o $@
+ $(CC) -c $(ALL_CFLAGS) $< -o $@
#
# Flags for using Checker
@@ -70,16 +70,16 @@ SRCS= $(srcdir)/e2fsck.c \
all:: $(PROGS)
e2fsck: $(OBJS) $(DEPLIBS)
- $(LD) $(LDFLAGS) $(LDFLAG_STATIC) -o e2fsck $(OBJS) $(LIBS)
+ $(LD) $(ALL_LDFLAGS) $(LDFLAG_STATIC) -o e2fsck $(OBJS) $(LIBS)
extend: extend.o
- $(LD) $(LDFLAGS) -o extend extend.o $(CHECKLIB)
+ $(LD) $(ALL_LDFLAGS) -o extend extend.o $(CHECKLIB)
flushb: flushb.o
- $(LD) $(LDFLAGS) -o flushb flushb.o $(CHECKLIB)
+ $(LD) $(ALL_LDFLAGS) -o flushb flushb.o $(CHECKLIB)
iscan: iscan.o util.o
- $(LD) $(LDFLAGS) -o iscan iscan.o util.o ehandler.o $(LIBS)
+ $(LD) $(ALL_LDFLAGS) -o iscan iscan.o util.o ehandler.o $(LIBS)
installdirs:
@@ -93,8 +93,9 @@ install: $(PROGS) $(MANPAGES) installdirs
done
$(LN) -f $(DESTDIR)$(sbindir)/e2fsck $(DESTDIR)$(sbindir)/fsck.ext2
for i in $(MANPAGES); do \
- $(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(man8dir)/$$i; \
+ $(INSTALL_DATA) $$i $(DESTDIR)$(man8dir)/$$i; \
done
+
uninstall:
$(RM) -f $(sbindir)/e2fsck
$(RM) -f $(sbindir)/flushb
diff --git a/e2fsck/badblocks.c b/e2fsck/badblocks.c
index f0613d9d..c81baae8 100644
--- a/e2fsck/badblocks.c
+++ b/e2fsck/badblocks.c
@@ -29,6 +29,7 @@ void read_bad_blocks_file(ext2_filsys fs, const char *bad_blocks_file,
errcode_t retval;
badblocks_list bb_list = 0;
FILE *f;
+ char buf[1024];
read_bitmaps(fs);
@@ -44,7 +45,6 @@ void read_bad_blocks_file(ext2_filsys fs, const char *bad_blocks_file,
fatal_error(0);
}
-
/*
* If we're appending to the bad blocks inode, read in the
* current bad blocks.
@@ -59,16 +59,33 @@ void read_bad_blocks_file(ext2_filsys fs, const char *bad_blocks_file,
}
/*
- * Now read in the bad blocks from the file.
+ * Now read in the bad blocks from the file; if
+ * bad_blocks_file is null, then try to run the badblocks
+ * command.
*/
- f = fopen(bad_blocks_file, "r");
- if (!f) {
- com_err("read_bad_blocks_file", errno,
- "while trying to open %s", bad_blocks_file);
- fatal_error(0);
+ if (bad_blocks_file) {
+ f = fopen(bad_blocks_file, "r");
+ if (!f) {
+ com_err("read_bad_blocks_file", errno,
+ "while trying to open %s", bad_blocks_file);
+ fatal_error(0);
+ }
+ } else {
+ sprintf(buf, "badblocks %s%s %d", preen ? "" : "-s ",
+ fs->device_name,
+ fs->super->s_blocks_count);
+ f = popen(buf, "r");
+ if (!f) {
+ com_err("read_bad_blocks_file", errno,
+ "while trying popen '%s'", buf);
+ fatal_error(0);
+ }
}
retval = ext2fs_read_bb_FILE(fs, f, &bb_list, invalid_block);
- fclose (f);
+ if (bad_blocks_file)
+ fclose(f);
+ else
+ pclose(f);
if (retval) {
com_err("ext2fs_read_bb_FILE", retval,
"while reading in list of bad blocks from file");
@@ -89,6 +106,11 @@ void read_bad_blocks_file(ext2_filsys fs, const char *bad_blocks_file,
return;
}
+void test_disk(ext2_filsys fs)
+{
+ read_bad_blocks_file(fs, 0, 1);
+}
+
static int check_bb_inode_blocks(ext2_filsys fs, blk_t *block_nr, int blockcnt,
void *private)
{
@@ -108,58 +130,3 @@ static int check_bb_inode_blocks(ext2_filsys fs, blk_t *block_nr, int blockcnt,
return 0;
}
-void test_disk(ext2_filsys fs)
-{
- errcode_t retval;
- badblocks_list bb_list = 0;
- FILE *f;
- char buf[1024];
-
- read_bitmaps(fs);
-
- /*
- * Always read in the current list of bad blocks.
- */
- retval = ext2fs_read_bb_inode(fs, &bb_list);
- if (retval) {
- com_err("ext2fs_read_bb_inode", retval,
- "while reading the bad blocks inode");
- fatal_error(0);
- }
-
- /*
- * Now run the bad blocks program
- */
- sprintf(buf, "badblocks %s%s %d", preen ? "" : "-s ",
- fs->device_name,
- fs->super->s_blocks_count);
- if (verbose)
- printf("Running command: %s\n", buf);
- f = popen(buf, "r");
- if (!f) {
- com_err("popen", errno,
- "while trying to run %s", buf);
- fatal_error(0);
- }
- retval = ext2fs_read_bb_FILE(fs, f, &bb_list, invalid_block);
- fclose (f);
- if (retval) {
- com_err("ext2fs_read_bb_FILE", retval,
- "while processing list of bad blocks from program");
- fatal_error(0);
- }
-
- /*
- * Finally, update the bad blocks from the bad_block_map
- */
- retval = ext2fs_update_bb_inode(fs, bb_list);
- if (retval) {
- com_err("ext2fs_update_bb_inode", retval,
- "while updating bad block inode");
- fatal_error(0);
- }
-
- badblocks_list_free(bb_list);
- return;
-}
-
diff --git a/e2fsck/e2fsck.8 b/e2fsck/e2fsck.8.in
index 0febc3ef..bfd20f3b 100644
--- a/e2fsck/e2fsck.8
+++ b/e2fsck/e2fsck.8.in
@@ -2,13 +2,13 @@
.\" Copyright 1993, 1994, 1995 by Theodore Ts'o. All Rights Reserved.
.\" This file may be copied under the terms of the GNU Public License.
.\"
-.TH E2FSCK 8 "October 1995" "Version 1.01"
+.TH E2FSCK 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
.SH NAME
e2fsck \- check a Linux second extended file system
.SH SYNOPSIS
.B e2fsck
[
-.B \-panyrdfvtFV
+.B \-pacnyrdfvtFV
]
[
.B \-b
@@ -51,6 +51,13 @@ search can be fooled in some cases. This option forces e2fsck to only
try locating the superblock at a particular blocksize. If the
superblock is not found, e2fsck will terminate with a fatal error.
.TP
+.I -c
+This option causes e2fsck to run the
+.BR badblocks (8)
+program to find any blocks
+which are bad on the filesystem, and then marks them as bad by adding them
+to the bad block inode.
+.TP
.I -d
Print debugging output (useless unless you are debugging
.B e2fsck
@@ -81,7 +88,8 @@ Open the filesystem read-only, and assume an answer of ``no'' to all
questions. Allows
.B e2fsck
to be used non-interactively. (Note: if the
-.I -l
+.IR -c ,
+.IR -l ,
or
.I -L
options are specified in addition to the
diff --git a/e2fsck/e2fsck.c b/e2fsck/e2fsck.c
index bc9510cb..1c29e4c0 100644
--- a/e2fsck/e2fsck.c
+++ b/e2fsck/e2fsck.c
@@ -103,13 +103,17 @@ static void show_stats(ext2_filsys fs)
fs->super->s_free_blocks_count);
if (!verbose) {
- printf("%s: %d/%d files, %d/%d blocks\n", device_name,
- inodes_used, inodes, blocks_used, blocks);
+ printf("%s: %d/%d files (%3.1f%% non-contiguous), %d/%d blocks\n",
+ device_name, inodes_used, inodes,
+ 100.00 * fs_fragmented / inodes_used,
+ blocks_used, blocks);
return;
}
printf ("\n%8d inode%s used (%d%%)\n", inodes_used,
(inodes_used != 1) ? "s" : "",
100 * inodes_used / inodes);
+ printf ("%8d non-contiguous inodes (%3.1f%%)\n",
+ fs_fragmented, 100.00 * fs_fragmented / inodes_used);
printf (" # of inodes with ind/dind/tind blocks: %d/%d/%d\n",
fs_ind_count, fs_dind_count, fs_tind_count);
printf ("%8d block%s used (%d%%)\n"
@@ -156,7 +160,7 @@ static void check_mount(NOARGS)
if (!(mount_flags & EXT2_MF_MOUNTED))
return;
-#if (defined(linux) && defined(HAVE_MNTENT_H))
+#if (defined(__linux__) && defined(HAVE_MNTENT_H))
/*
* If the root is mounted read-only, then /etc/mtab is
* probably not correct; so we won't issue a warning based on
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index debd56a5..dea265dc 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -138,6 +138,7 @@ extern int fs_sockets_count;
extern int fs_ind_count;
extern int fs_dind_count;
extern int fs_tind_count;
+extern int fs_fragmented;
extern struct resource_track global_rtrack;
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 17b0939b..40955e16 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -59,6 +59,7 @@ int fs_sockets_count = 0;
int fs_ind_count = 0;
int fs_dind_count = 0;
int fs_tind_count = 0;
+int fs_fragmented = 0;
ext2fs_inode_bitmap inode_used_map = 0; /* Inodes which are in use */
ext2fs_inode_bitmap inode_bad_map = 0; /* Inodes which are bad in some way */
@@ -92,11 +93,12 @@ static char *describe_illegal_block(ext2_filsys fs, blk_t block);
struct process_block_struct {
ino_t ino;
- int is_dir:1, clear:1, suppress:1;
+ int is_dir:1, clear:1, suppress:1, fragmented:1;
int num_blocks;
int last_block;
int num_illegal_blocks;
int fix;
+ blk_t previous_block;
struct ext2_inode *inode;
};
@@ -157,6 +159,7 @@ static void unwind_pass1(ext2_filsys fs)
fs_ind_count = 0;
fs_dind_count = 0;
fs_tind_count = 0;
+ fs_fragmented = 0;
}
void pass1(ext2_filsys fs)
@@ -249,6 +252,7 @@ void pass1(ext2_filsys fs)
pb.num_blocks = pb.last_block = 0;
pb.num_illegal_blocks = 0;
pb.suppress = pb.clear = pb.is_dir = 0;
+ pb.fragmented = 0;
pb.fix = -1;
pb.inode = &inode;
retval = ext2fs_block_iterate(fs, ino, 0, block_buf,
@@ -593,6 +597,8 @@ static void check_blocks(ext2_filsys fs, ino_t ino, struct ext2_inode *inode,
pb.num_blocks = pb.last_block = 0;
pb.num_illegal_blocks = 0;
pb.suppress = pb.clear = 0;
+ pb.fragmented = 0;
+ pb.previous_block = 0;
pb.is_dir = LINUX_S_ISDIR(inode->i_mode);
pb.fix = -1;
pb.inode = inode;
@@ -603,6 +609,9 @@ static void check_blocks(ext2_filsys fs, ino_t ino, struct ext2_inode *inode,
com_err(program_name, retval,
"while calling ext2fs_block_iterate in check_blocks");
+ if (pb.fragmented && pb.num_blocks < fs->super->s_blocks_per_group)
+ fs_fragmented++;
+
if (pb.clear) {
e2fsck_read_inode(fs, ino, inode, "check_blocks");
if (retval) {
@@ -756,6 +765,18 @@ int process_block(ext2_filsys fs,
blockcnt);
#endif
+ /*
+ * Simplistic fragmentation check. We merely require that the
+ * file be contiguous. (Which can never be true for really
+ * big files that are greater than a block group.)
+ */
+ if (p->previous_block) {
+ if (p->previous_block+1 != blk)
+ p->fragmented = 1;
+ }
+ p->previous_block = blk;
+
+
if (blk < fs->super->s_first_data_block ||
blk >= fs->super->s_blocks_count ||
ext2fs_test_block_bitmap(block_illegal_map, blk)) {