Commit Graph

864 Commits (010c49cf499738c7a06de13077f31f2a12ecadeb)

Author SHA1 Message Date
Valerie Aurora Henson c5d2f50dee e2fsck: Convert e2fsck to new bitmap interface
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-22 22:29:02 -04:00
Theodore Ts'o 6013915487 e2fsck: Add a global latch question for bad group descriptor checksums
Very often all the block group descriptors will have bad checksums, so
don't force the user answer 'yes' many, many times.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-19 01:06:50 -04:00
Theodore Ts'o 9a7fe4bdc9 e2fsck: Only ask to relocate a block group's inode table once
If multiple blocks of a block group's inode table overlaps with other
file system blocks, only ask once for each block group.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-18 23:14:03 -04:00
Theodore Ts'o 617446e4aa e2fsck: Teach new_table_block() to allocate new itables/bitmaps with FLEX_BG
If the filesystem feature FLEX_BG is enabled, the inode table and
bitmap blocks can be located anywhere in the inode table.  So for
FLEX_BG filesystems, new_table_block() now tries allocate in the block
group's flex_bg first, and if there is no space in the local flex_bg,
then try to allocate from the whole filesystem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-18 23:06:30 -04:00
Theodore Ts'o fe26a55ac9 e2fsck: Fix and enhance superblock dates in future problem reports
Fixed a bug where e2fsck would report that last mount time was in the
future when it was really the last write time that was in the future.

Also, since people can't seem to believe that (a) their distribution
has buggy init scripts, or (b) their CMOS/RTC clock or backup battery
is dead, print the incorrect time and the current system time.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-08 10:14:48 -04:00
Valerie Aurora Henson bee24f364c e2fsck: Allow cancellation during group descriptor checks.
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-04 22:48:15 -04:00
Theodore Ts'o 1d72214658 Merge branch 'maint' into next 2009-08-22 13:18:29 -04:00
Theodore Ts'o 26ea4899d1 e2fsck: Fix superblock times in the future even if buggy_init_scripts=1
Unfortunately, distributions like Ubuntu seem to have buggy init
scripts that run e2fsck and mount the root filesystem before making
sure the system time and time zone is correctly set.  As a result, a
filesystem's last write and last mounted time can be set in future.
The buggy_init_scripts configuration option will stop e2fsck from
aborting the boot process, but it also inhibits the superblock times
from getting fixed.  This causes resize2fs to refuse to resize the
filesystem, even after running e2fsck on the file system.  To deal
with this, we need to fix the superblock write times unconditionally.

Addresses-Launchpad-bug: #373409

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-16 23:44:50 -04:00
Kazuya Mio e31b32721d e2fsck: remove unused variable in check_block_bitmap()
check_block_bitmap() calculates the block number of superblock in the current
block group but it's not used.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-07-06 23:24:18 -04:00
Kazuya Mio 01ec1268a5 e2fsck: optimize loop counter when fixing bitmap padding
If unused range of the bitmap has an unmarked bit, check_[inode/block]_end()
marks all bits in the range. However, we know that the checked bits are marked.
So this patch fixes loop counter to mark from the unmarked bit.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-07-06 23:24:18 -04:00
Kazuya Mio f27aea2fba e2fsck: remove unnecessary continue statement
Remove the continue statement because it calls at the end of the loop.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-07-06 23:24:18 -04:00
Theodore Ts'o c13351f6c5 Add support for configure --enable-verbose-makecmds
Some people don't want to see the concise "kernel-style" make output.
This configure option allows build engines that want to see the full
set of commands executed by the makefile to get what they want.  Most
people will find this more distracting than useful, unless they need
to debug the Makefiles.

(It is not necessary to rerun configure to enable this verbose make
output temprarily; if a developer wants to do a quick debug of a
directory's makefile, he or she can simply edit the definition of the
$(E) and $(Q) variables in the Makefile; instructions can be found in
the MCONFIG file which is included in at the beginning of every
Makefile.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-02 00:11:17 -04:00
Theodore Ts'o a6a1c0815c Fix Makefile dependencies for libcom_err
The e2fsprogs makefiles were using the same Makefile variable
LIBCOM_ERR for the link-line arguments as well as the dependencies.
Since LIBCOM_ERR can now include non-file arguments such as
"-lpthread", we need to use a separate DEPLIBCOM_ERR variable that
only has build file dependencies.

Do the same thing for STATIC_LIBCOM_ERR and PROFILED_LIBCOM_ERR.

Addresses-Sourceforge-Patches: #2813809

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-01 22:06:51 -04:00
Theodore Ts'o 8a48035095 Fix encoding for rec_len in directories for >= 64k blocksize file systems
Previously e2fsprogs interpreted 0 for a rec_len of 65536 (which could
occur if the directory block is completely empty in 64k blocksize
filesystems), while the kernel interpreted 65535 to mean 65536.  The
kernel will accept both to mean 65536, and encodes 65535 to be 65536.
This commit changes e2fsprogs to match.

We add the encoding agreed upon for 128k and 256k filesystems, but we
don't enable support for these larger block sizes, since they haven't
been fully tested.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-21 21:07:38 -04:00
Theodore Ts'o 23f75f6efa e2fsck: fix miscellaneous memory leaks
Fix various miscellaneous memory leaks which were discovered using valgrind.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-15 03:54:06 -04:00
Theodore Ts'o 5635e75c91 Merge branch 'maint' into next 2009-07-21 17:07:33 -04:00
Jose R. Santos 20f2ccb326 Use new ext2fs_super_and_bgd_loc2 call in libext2fs
The new ext2fs_super_and_bgd_loc2() function has some changes aside
from just blk64_t support.  Lets make sure that the interfaces are
sane by adding libext2fs support early to get the new API tested here.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-11 21:29:30 -04:00
Kazuya Mio 479463aaf6 e2fsck: Speed up pass 5 processing for ext4 filesystems
e2fsck_pass5() checks whether the inode and block allocation bitmaps
are consistent.  However, if EXT2_BG_[INODE/BLOCK]_BITMAP is set to a
ext4's block group, most of its bitmap is uninitialized (0).  In that
case, we can optimize e2fsck's pass 5 by checking the entire range of
an uninitalized block group instead of checking bit by bit.

This can speed up e2fsck pass 5 by up to 80%:

         +-----+--------------------+--------------------+
         |     |     old e2fsck     |     new e2fsck     |
         |Pass |       time(s)      |       time(s)      |
         |     | real | user |system| real | user |system|
         +-----+------+------+------+------+------+------+
         |  1  |  5.70|  3.29|  0.50|  5.66|  3.21|  0.54|
         |  2  |  3.33|  0.80|  0.19|  3.40|  0.82|  0.23|
         |  3  |  0.01|  0.00|  0.00|  0.01|  0.00|  0.00|
         |  4  |  1.04|  1.04|  0.00|  1.05|  1.04|  0.00|
         |  5  | 19.60| 17.27|  0.06|  3.53|  1.21|  0.05|
         +-----+------+------+------+------+------+------+
         |Total| 29.94| 22.57|  0.80| 13.90|  6.47|  0.86|
         +-----+------+------+------+------+------+------+

Comparison of e2fsck time on an ext4 500GB partition (20% blocks used)

Machine environment:
CPU:       Intel(R) Xeon(TM) CPU 3.00GHz
Memory:    1GB
Kernel:    linux-2.6.29-git2

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-09 14:56:30 -04:00
Theodore Ts'o 4f858546e1 Update man pages to include ext4 in the synposis, instead of just "ext2/ext3"
The e2fsprogs programs have historically just said that they operate
on ext2 and ext3 file system in their man pages.  Update them to say
that they also operate on ext4 file systems.

Addresses-Launchpad-bug: #381854

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-30 12:34:28 -04:00
Theodore Ts'o 606638906a e2fsck: Go back to the original superblock if the backup sb is invalid
In the case where the block group descriptors appear corrupt, e2fsck
will try to use the backup superblock.  However, it could be that the
backup superblock itself is completely corrupted, in which e2fsck
should go back to the original superblock instead of refusing to fix
the file system.

Addresses-Debian-Bug: #516820

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-28 23:40:18 -04:00
Theodore Ts'o b6bb99feb9 e2fsck: if i_file_acl_hi is non-zero, fix it and don't abort e2fsck -p
Ext3 filesystems don't care if i_file_acl_hi is non-zero in some
inode, and newer kernels should ignore this field (although 2.6.29 and
older kernels will not).  So e2fsck should fix this without aborting
an e2fsck preen operation.

Addresses-Debian-Bug: #526524

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-28 17:05:40 -04:00
number9652 84b239aea4 libext2fs: add ext2fs_extent_open2
The patch below adds a function, ext2fs_extent_open2(), that behaves
as ext2fs_extent_open(), but will use the user-supplied inode
structure when opening an extent instead of reading the inode from
disk.  It also changes several of the calls to extent_open() to use
this enhancement.

Signed-off-by: Nic Case <number9652@yahoo.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-28 16:33:38 -04:00
Ken Chen 9facd076ae Add empty function for init_resource_track() and print_resource_track()
in the case of ! defined RESOURCE_TRACK, so that we can clean up #ifdef
throughout e2fsck source.

Signed-off-by: Ken Chen <kenchen@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-28 09:55:10 -04:00
Ken Chen fea390e253 e2fsck: add resource tracking for passes 1[b-d]
On ext2, time tracking for pass1 includes both error detection and
specific type of fs fix-up phase (e.g. block referenced by multiple
inodes).  The multi-reference fix-up phase some time take significant
amount of time to complete.  We would like to track time spent in sub
component of pass1 by having a finer granularity during pass1b through
pass1d phase.

Signed-off-by: Ken Chen <kenchen@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-28 09:37:16 -04:00
Andreas Dilger 70eabde9a5 e2fsck: use unsigned values for memory tracking stats
Use unsigned values for printing memory tracking to avoid overflows.
The mallinfo() data is currently signed ints, but it might change in
the future so we may as well compute/print unsigned longs.

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-28 07:59:04 -04:00
Andreas Dilger 6267ee49be e2fsck: only restart e2fsck once for inodes in uninit range
Restart e2fsck only once in case of multiple inodes in uninit range.
Display correct inode number during BG_INO_UNINIT and INOREF_IN_USED errors.

Signed-off-by: Kalpak Shah <kalpak.shah@sun.com>
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-28 07:58:52 -04:00
Theodore Ts'o 27a407df54 e2fsck: Fix journal replay bug which reverts changes to the bg descriptors
Fix a regression in e2fsprogs 1.41.5 which would undo updates to the
block group descriptors after a journal replay, caused by commit
b7c5b403.  We now use ext2fs_free() instead of ext2fs_close() to make
sure we the library will never try to write out superblock or block
group descriptors.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-25 22:09:59 -04:00
Andreas Dilger 14c5af32f2 e2fsck: initialize error handling before journal replay
One of our customers hit a temporary IO error during an e2fsck run during
the read from the journal.  It seems that the read error resulted in
e2fsck automatically discarding the journals and recreating them on several
filesystems on this node without any prompting from the user:

   end_request: I/O error, dev sdg, sector 484832
   Buffer I/O error on device sdg, logical block 60604
   fsck-sdg[8276]: ls2-OST024c: Superblock has an invalid ext3 journal (inode 8).
   fsck-sdg[8276]: CLEARED.
   fsck-sdg[8276]: *** ext3 journal has been deleted - filesystem is now ext2
   only ***
   fsck-sdg[8276]: ls2-OST024c was not cleanly unmounted, check forced.
   fsck-sdg[8276]: ls2-OST024c: Journal inode is not in use, but contains data.
   CLEARED.
   fsck-sdg[8276]: ls2-OST024c: Recreate journal to make the filesystem ext3
   again?
   fsck-sdg[8276]: FIXED.
   fsck-sdg[8276]: Creating journal (32768 blocks):  Done.
   fsck-sdg[8276]:
   fsck-sdg[8276]: *** journal has been re-created - filesystem is now ext3 again
   ***
   fsck-sdg[8276]: ls2-OST024c: 39818/20183248 files (8.2% non-contiguous), 222122257/779902976 blocks
   fsck-sdg[8276]: exit code 1 (file system errors corrected)

The following patch moves the e2fsck error handler initialization earlier
in the e2fsck startup code before the journal is processed, so that the
user will be prompted for an action.  This is the first IO that is not
part of ext2fs_open() where fs->io is first initialized.

It doesn't seem possible to initialize the error handlers for the initial
filesystem open without changing the prototype for ext2fs_open2().  If we
are getting a new ext2fs_open3() prototype for 64-bit it might make sense
to add at least "read_error" as a parameter ("write_error" is not strictly
necessary for the open and could be set afterward).

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jim Garlick <garlick@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-17 23:03:04 -04:00
Theodore Ts'o 0a68b181c1 e2fsck: Don't crash if an inode with a bad extent header is not cleared
If ext2fs_extent_open() fails due to a corrupt extent header, and the
user declines to clear the inode, check_blocks_extents() should bail
out; otherwise, it will cause a core dump due a null pointer
dereference.

Addresses-Sourceforge-Bug: #2791794

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-17 08:42:52 -04:00
Andreas Dilger ae33f578c0 e2fsck: cleanup whitespace in problem.c and problem.h
Cleanup whitespace in the problem.h and problem.c files.  Removes a
bunch of places where tabs follow spaces, whitespace on empty lines, etc.
I didn't reformat the indenting of the entire problem.h error codes,
but there is some room for doing this...

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-02 21:10:45 -04:00
Andreas Dilger 7494cbfd59 e2fsck: Add test code in problem.c to verify problem codes
We've hit a number of cases where the error codes in problem.h have
been assigned duplicate values compared to problems in our own e2fsck
patches, and this can lead to confusing and difficult to find bugs
in e2fsck (e.g. wrong problem messages, incorrect repair action, etc).

Attached is a test case for the problem.c file to ensure that the
problem table is sorted and does not contain any duplicate values.
Having the problem table sorted allows the correctness checking to be
very simple, and if it ever became important for performance we could
use binary searching of the problem table for the specific problem code.

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-02 21:10:44 -04:00
Theodore Ts'o 47c1b8e166 e2fsck: Skip journal checks if the fs is mounted and doesn't need recovery
If we are checking a mounted filesystem (typically the root
filesystem, mounted read/only) and the NEEDS_RECOVERY flag is not set,
skip all of the checks associated with making sure the journal is
consistent.  There is the very slight possibility we could lose if the
NEEDS_RECOVERY flag was somehow cleared even though there was data in
the journal, but this has practically never happend in practice, and
it reduces the number of reads required at boot-time, which is a big
deal when trying to reduce boot times with HDD's.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-28 09:09:44 -04:00
Theodore Ts'o 911ec62615 e2fsck: On a 32-bit filesystem, make sure i_file_acl_high is zero
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-23 21:31:16 -04:00
Theodore Ts'o 982dd30ce8 e2fsck: Reduce unnecessary I/O when checking backup superblock
E2fsck needs to check to see if the backup superblock differs from the
primary superblock.  Previously it was doing so by calling
ext2fs_open(), which does a lot of unnecessary work, including reading
all of the backup block group descriptors.  Avoid this by reading in
the backup superblock directly.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-23 01:27:07 -04:00
Theodore Ts'o 69d0edfd01 e2fsck: Don't test the resize_inode if the filesystem is clean
Move check_resize_inode() out of check_super_block(), since we only
need to test the resize_inode for correctness only if the filesystem
requires checking.  This change avoids a lot of I/O operations which
slows down a 1 second boot.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-23 00:39:06 -04:00
Theodore Ts'o b0258cbcd8 e2fsck: Fix warn_unused_result warnings from gcc
Fixed a potential bug where by partial returns from the write(2)
system call could lost characters to be sent to external progress bar
display program.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 15:09:41 -04:00
Andreas Dilger 611378fe20 e2fsck: print unsigned RAM usage statistics
Running e2fsck against a 14.5TB filesystem with -tt it reported
-200904kB for RAM usage in pass3 instead of the correct 2300773kB.
The RAM usage statistics were being printed with %d instead of %u.

Also fix a few places using %ld for inode numbers instead of %lu.

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-07 13:39:24 -04:00
Eric Sandeen d9ff474b74 e2fsck: ignore differing NEEDS_RECOVERY flag on backup sbs
When we resize online, the primary superblock gets copied to all
the backups, and of course since we're mounted the NEEDS_RECOVERY
flag is set.  A subsequent fsck will find the backups have the
NEEDS_RECOVERY flag set while the primary does not, and this
forces a full fsck pass.

I think this flag can be safely ignored in the flag comparisons.

Addresses-Red-Hat-Bugzilla: #471925

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-07 13:20:53 -04:00
Jim Meyering 45e338f533 remove useless if-before-free tests
In case you're wondering about whether this change is safe from a
portability standpoint, fear not.  This has been beaten to death
in other forums.  Here are a few threads:

  http://thread.gmane.org/gmane.comp.version-control.git/74187
  http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/12712
  http://thread.gmane.org/gmane.emacs.devel/98144
  http://thread.gmane.org/gmane.comp.lib.glibc.alpha/13092

There has been debate about whether it's a good idea from a
performance standpoint, too, but imho you'll have a hard time
finding an instance where this sort of change induces a
measurable performance penalty.  If you do, please let me know.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-03-08 20:37:12 -04:00
Eric Sandeen f2fe5da31d e2fsprogs: fix potential null ptr defef in check_for_modules()
The coverity scanner found this one.

If a line in modules.dep has a ":" but no "/" then:

                if ((cp = strchr(buf, ':')) != NULL)
                        *cp = 0;
                else
                        continue;
                if ((cp = strrchr(buf, '/')) != NULL)
                        cp++;
                /* XXX else cp is still null */
                i = strlen(cp);

... we will deref a null pointer (cp).  This can be
demonstrated by putting a line like:

foo.ko:

into modules.dep.  The below change just says that if no "/" is
found, treat the whole string as the module name.

Addresses-Red-Hat-Bugzilla: #486997

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-03-06 02:37:33 -05:00
Theodore Ts'o cf9fbcccbc e2fsck: Add missing newlines when reporting errors in pass 3A
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-26 16:41:46 -05:00
Theodore Ts'o 206d2ade6e e2fsck: Change PR_3_CREATE_LPF_ERROR to be a non-fatal problem
The other problem codes associated with failing to create the
lost+found directory are non-fatal, and this one should be non-fatal
as well.  The two places which call e2fsck_get_lost_and_found()
already deal with a failure to create the directory, so there's no
point making this be a fatal error.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-22 16:05:29 -05:00
Theodore Ts'o 1f790a7cc1 e2fsck: Add superblock check to make sure s_first_ino is valid
An deliberately corrupted filesystem with an insanely large
s_first_ino field could cause e2fsck to crash with a seg fault.

Thanks to Eric Sesterhenn for supplying test cases which demonstrated
this issue.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-22 15:52:50 -05:00
Theodore Ts'o e35d548b59 e2fsck: Fix journal replay for block sizes greater than 8k
E2fsck was using a fixed-size 8k buffer for replaying blocks from the
journal.  So attempts to replay a journal on filesystems greater than
8k would cause e2fsck to crash with a segfault.

Thanks to Miao Xie <miaox@cn.fujitsu.com> for reporting this problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-02 18:14:42 -05:00
Theodore Ts'o dd04d05f70 e2fsck: Remove "ext3" from problem descriptions of the journal
The ext4 filesystem uses journals too, so remove "ext3" from the
problem descriptions involving journals.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-01 23:10:40 -05:00
Theodore Ts'o 7518c17686 e2fsck: Fix an unhandled corruption case in scan_extent_node()
A corrupted interior node in an extent tree would cause e2fsck to
crash with the error message:

Error1: Corrupt extent header on inode 107192
Aborted (core dumped)

Handle this and related failures when scanning an inode's extent tree
more robustly.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-12-25 22:42:38 -05:00
Theodore Ts'o 7dca4c88f1 e2fsck: When repacking directories, leave slack space for more efficiency
If the directory is packed with no slack space, as soon as any new
directory entries are added, leaf nodes end up getting split and
directory ends up getting very inefficient.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-12-25 17:59:36 -05:00
Theodore Ts'o d5a74ff10b e2fsck: Fix double-counting of non-contiguous extent-based inodes
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-12-22 01:23:59 -05:00
Theodore Ts'o 100d4701d5 e2fsck: Enhance fragcheck report with file/directory information
Report whether a fragmented inode is a directory or a file, as this is
highly useful for determining what is going on with an ext4 filesystem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-12-08 22:00:13 -05:00
Theodore Ts'o ce44d8cafa e2fsck: In verbose mode, distinguish between fragmented directories/files
Track the number of non-contiguous files and directories so we can
give more detailed information in verbose mode.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-12-08 21:33:11 -05:00
Theodore Ts'o 42e89ce7f8 e2fsck: Don't cancel the fsck run after clearing an errant INODE_UNINIT flag
Thanks to Kelly Kane from Dreamhost for reporting this bug and then
helping us find and fix it.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-11-26 20:41:26 -05:00
Theodore Ts'o 03fa6f8ae2 Fix various signed/unsigned gcc warnings
Some of these could affect filesystems between 2^31 and 2^32-1 blocks.

Thanks to Valerie Aurora Henson for pointing out the problems in
lib/ext2fs/alloc_tables.c, which led me to do a "make gcc-wall" scan
over the source tree.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-11-16 10:06:59 -05:00
Theodore Ts'o 992a2f7f68 e2fsck: Fix build of e2fsck.profiled if profiling is enabled
It's been a while since I've done a build using "configure
--enable-profile", and some bitrot had set into the Makefiles...

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-11-15 12:12:57 -05:00
Theodore Ts'o 80875db58a e2fsck: Offer to clear the test_fs flag if ext4 is available
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-10-12 23:12:23 -04:00
Theodore Ts'o 4758835c28 e2fsck: Print the correct inode number for uninit-bg related problem reports
Fix the reporting for problem codes PR_2_INOREF_BG_INO_UNINIT and
PR_2_INOREF_IN_UNUSED.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-10-12 23:12:22 -04:00
Eric Sandeen 79cc336282 e2fsck: exit from preenhalt if IO errors were encountered
If a block device is read-only, e2fsck -p gets into an infinite loop
trying to preenhalt, closing and flushing the fs, which tries to flush
the cache, which gets a write error and calls preenhalt which tries to
close and flush the fs ... ad infinitum.

Per Ted's suggestion just flag the ctx as "exiting" and short-circuit
the infinite loop.

Tested by running e2fsck -p on a block device set read-only by BLKROSET.

Thanks to Vlado Potisk for reporting this.

Addresses-Red-Hat-Bugzilla: #465679

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-10-12 23:12:22 -04:00
Theodore Ts'o 0f589a4d57 Fix spelling mistake in e2fsck man page
Addresses-Launchpad-Bug: #275272

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-10-01 20:27:41 -04:00
Theodore Ts'o 0eeec8ac61 Fix compiling under diet libc
Some recent changes had caused diet libc support to bitrot.  Fix up
missing header files and other portability fixups needed for dietlibc.
(Many of these changes also improve general portability.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-12 09:10:39 -04:00
Theodore Ts'o 52771ab591 e2fsck: Fix e2fsck automatic blocksize detetion
This fixes a regression that was introduced in commit dcc91e10 (it
showed up first in e2fsprogs 1.40.7).  Since we weren't freeing the
filesystem handle, ext2fs_open2() was returning EBUSY, and so this
caused a failure in the code that would automatically determine the
filesystem block size when only the superblock number was specified by
the user.

This was discussed in http://ubuntuforums.org/showthread.php?t=789323,
and Matthias Bannach pointed this out to me, for which I am very
grateful.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-09 15:02:24 -04:00
Theodore Ts'o 4efd17cccb e2fsck: Don't print the PO header when printing problems with PROMPT_NULL
A few e2fsck problem messages supply their own prompt, and set a
prompt value of PROMPT_NULL.  We have to check for this case, and not
pass the null string to _(), since that will result in the translation
header getting printed, like this:

Run journal anywayProject-Id-Version: e2fsprogs
Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>
POT-Creation-Date: 2008-02-28 21:45-0500
PO-Revision-Date: 2006-05-23 11:12+0000
Last-Translator: Somebody32 <som32@mail.ru>
Language-Team: Russian <ru@li.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 &&
n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;
X-Launchpad-Export-Date: 2008-05-28 00:43+0000
X-Generator: Launchpad (build Unknown)
<y>? yes

Addresses-Launchpad-Bug: #246892

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-07 01:35:15 -04:00
Theodore Ts'o 55da987650 Improve ELF shared library handling
Pass in -rpath-link option to the linker so that blkid will build
correctly on systems that don't have libcom_err.so.2 installed.

Fix debugfs to only try to link with -ldl when building without shared
libraries; with ELF shared libraries, the library which requires -ldl
(libss.so) can required the library dependency itself.

Fix how we build tune2fs.static so that we use @LDFLAG_STATIC@, via
$(LDFLAGS_STATIC), instead of hard-coding the use of -static.

Addresses-Sourceforge-Bug: #2088537

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-02 23:12:38 -04:00
Theodore Ts'o f38cf3cb34 Only use the test_io manager if the right environment variables are set
In order to make it possible for the test_io manager to be compiled in
by default, make all of the programs that might try to use it to only
do so if the environment variables TEST_IO_FLAGS and TEST_IO_DEBUG are
set.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-01 11:36:53 -04:00
Theodore Ts'o efc6f628e1 Remove trailing whitespace for the entire source tree
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-27 23:07:54 -04:00
Theodore Ts'o 5dd77dbe5a Add support for with empty directory blocks in 64k blocksize filesystems
The rec_len field in the directory entry is 16 bits, so if the
filesystem is completely empty, rec_len of 0 is used to designate
65536, for the case where the directory entry takes the entire 64k
block.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-25 21:08:19 -04:00
Andreas Dilger e5e12db959 fix e2fsck error message for bad htree depth
Fix error message to print the depth of a corrupt htree directory.

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Kalpak Shah <kalpak.shah@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-08-24 21:57:31 -04:00
Andreas Dilger ba7b0feef6 e2fsck: Change comments in problem array to match what is printed
This makes it easier to locate the problem code in question.

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-24 20:38:22 -04:00
Andreas Dilger 864b8d4eab Fix miscellaneous compile warnings
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-24 20:37:39 -04:00
Andreas Dilger 1bb6f6c87e e2fsck_write_bitmaps() optimization
This patch changes the e2fsck_write_bitmaps() function to write out the
block and inode bitmaps together, instead of writing them in two passes.

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-08-24 17:59:09 -04:00
Theodore Ts'o 094c2d4393 e2fsck: Portability fix: Use WORDS_BIGENDIAN instead of __LITTLE_ENDIAN
__LITTLE_ENDIAN is set by the glibc headers, and isn't portable.  We
should be using WORDS_BIGENDIAN, which is set by autoconf.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-22 19:19:18 -04:00
Theodore Ts'o 0ea910997b e2fsck: fix spurious complaints about i_size caused by preallocated blocks
For inodes with blocks preallocated with FALLOC_FL_KEEP_SIZE, e2fsck
complained about i_size being too small.  Fix this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-17 23:14:30 -04:00
Theodore Ts'o 3ec7be439a e2fsck: Fix max size calculation for extent files
A misunderstanding C's precedence rules and the meaning of
s_log_block_size meant that we were capping the maximum size of
extent-based files at 8GB instead of the 64TB that it should be for
filesystems with 4k block sizes.

Addresses-Kernel-Bugzilla: #11341

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-17 09:41:38 -04:00
Theodore Ts'o 8da6d1a18a e2fsck: Fix ind/dind/tind statistics and add extent depth statistics
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-14 09:48:07 -04:00
Theodore Ts'o f4e2c991ef e2fsck: Fix signed/unsigned error in fragcheck report for indirect blocks
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-12 22:11:02 -04:00
Theodore Ts'o 63b5e354d9 e2fsck: Fix check to see if an extent-based file is fragmented
Also added support for "e2fsck -E fragcheck" which issues a
comprehensive report of discontiguous file extents.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-10 22:43:24 -04:00
Theodore Ts'o 3467f2db22 Fix cross compilation issues in e2fsck/gen_crc32table
The Makefile should use BUILD_CFLAGS instead of ALL_CFLAGS since it
will be built for the host, not the target.

Addresses-Sourceforge-Bug: #2019287

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-18 21:05:30 -04:00
Theodore Ts'o ceebf84fbd e2fsck: Set LD_LIBRARY_PATH before running "make check" programs
This is needed so that "make check" works in the e2fsck library even
if the shared libraries are not yet installed, and so that we run
those programs against the version of the libraries built in the build
tree.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-13 16:06:57 -04:00
Theodore Ts'o ebabf2ad6d Define _XOPEN_SOURCE to 600 consistently for Solaris C99 support
Solaris's header files are very picky about which C compiler can be
used for SUSv3 conformance.  Use of C99 is not compatible with SUSv2
(_XOPEN_SOURCE=500), and C89 is not compatible with SUSv3
(_XOPEN_SOURCE=600).  Since we need some SUSv3 functions, consistently
use SUSv3 so that e2fsprogs will build on Solaris using c99.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-13 16:06:57 -04:00
Theodore Ts'o 387df00577 Only use __builtin_expect if __GNUC__ > 3
Gcc only supports __builtin_expect for gcc versions 2.96 and up.
Since it's tricky to check for gcc 2.95 vs 2.96 (and either are only
used on really ancient systems anyway), we only use this optimization
on 3.x and newer versions of gcc.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-13 16:06:56 -04:00
Theodore Ts'o 1911bf113e e2fsck: Change kmem_cache_t to lkmem_cache_t for Solaris
Solaris polutes the C namespace with kmem_cache_t when
you include in/netinet.h is included, so rename kmem_cache_t
to lkmem_cache_t.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-13 16:06:56 -04:00
Eric Sandeen 7c1e090ce1 e2fsck: Fix i_size checking for large extent-based files
This:

Truncating bigfile to 14680064000000
Pass 1: Checking inodes, blocks, and sizes
Inode 49154, i_size is 14680064000000, should be 0.  Fix<y>?

is a bit unexpected.  It's because the size is being checked against
the max sizes for bitmap files, not extent-based files.

Nick saw this with his 14TB file.

Patch below applies different size limits to the different file
formats.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-07 11:01:36 -04:00
Theodore Ts'o 6f2ca692ec Fix "make check" in e2fsck subdirectory to use the in-tree com_err library
Thanks to Jose Santos for pointing this out

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-19 10:09:08 -04:00
Theodore Ts'o 9329866d3d Add a reference to e2fsck.conf(5) to the e2fsck man page
Addresses-Debian-Bug: #393313

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-18 11:27:21 -04:00
Theodore Ts'o 68eb092dda e2fsck: Add better explanatory message when s_lastcheck is in the future
Addresses-Debian-Bug: #446005

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-07 12:19:08 -04:00
Theodore Ts'o 2acad6b489 Fix gcc -Wall warnings in e2fsck
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-07 11:04:10 -04:00
Theodore Ts'o 185c4aeaf2 e2fsck: Add support to check journal checksums
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-06 23:38:38 -04:00
Theodore Ts'o 51d12cebb6 Add CRC32 (big-endian) routine for use by journal checksums
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-06 23:38:38 -04:00
Theodore Ts'o d5a8f9a9f2 e2fsck: Detect unordered extents in an extent node
The logical block numbers must be monotonically increasing, and there
must not be any overlapping extents.  If any are found, report them as
filesystem corruption.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-02 20:33:30 -04:00
Theodore Ts'o 16bd349e1f e2fsck: Wire up callback functions for _alloc_block() and _block_alloc_stats()
Wire up callback functions for ext2fs_alloc_block() and
ext2fs_block_alloc_stats() so that we use the ctx->block_found_map
block bitmap to determine which new block we should allocate, and then
to update the block_found_map bitmap if the extent functions need to
allocate or release blocks.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-02 18:52:12 -04:00
Theodore Ts'o 11de9261c1 e2fsck: Don't double count an extent after deleting the last extent
ext2fs_extent_delete() will leave the extent handle pointing at the
next extent --- except if the last extent in the node.  To deal with
this last case, call ext2fs_get_extent_info() and stop scanning after
processing info->num_entries extents.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-05-30 15:23:24 -04:00
Theodore Ts'o 73e5abcfe4 e2fsck: Don't skip an extent after deleting an invalid extent
ext2fs_delete_extent() deletes the current extent and moves to the
next extent (if present).  So we need to skip moving to the next
extent and get the (new) current extent and check it before moving on.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-05-28 04:54:44 -04:00
Theodore Ts'o c0af709e52 Merge branch 'maint'
Conflicts:

	README
	version.h
2008-05-21 16:56:42 -04:00
Theodore Ts'o e5ea6b14eb e2fsck: Fix potential data corruptor bug in journal recovery
While synchronizing e2fsck's recovery.c with the latest 2.6 kernel
sources, I discovered a serious bug that apparently had been fixed in
the kernel sometime between Deceber 2003 and April 2005, but which had
not been carried over to e2fsprogs.  Specifically, when blocks whose
first 4 bytes are JFS_MAGIC_NUMBER (0xc03b3998) are written into the
journal, the first 4 bytes zero'ed out.  A one character typo meant
that when the blocks were replayed by e2fsck, the JFS_MAGIC_NUMBER
would not be restored.

Oops.

Fortunately, it is *highly* unlikely that ext4 metadata blocks will
contain that magic number in the first four bytes, and data=journalled
is a relatively rarely used.

This commit fixes this bug, as well as updating e2fsck's recovery.c to
be in sync with 2.6.25.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-05-20 14:51:14 -04:00
Theodore Ts'o eda08d45bd Install {mkfs,fsck}.{ext4,ext4dev} binary and man pages
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-05-14 18:41:01 -04:00
Theodore Ts'o 16b851cdae Remove LAZY_BG feature
This simplifies the code, and using the uninit_bg with the inode table
lazily initialized is just as good.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-20 23:33:34 -04:00
Theodore Ts'o 4a2924eaa3 e2fsck: Fix pass5 handling of meta_bg and uninit_bg combination
The pass5 lazy block group support didn't understand meta_bg formats
correctly.  Fix this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-20 18:33:19 -04:00
Theodore Ts'o 2930dad2b2 Rename the feature uninit_groups to uninit_bg
Allow the old name of uninit_groups when converting feature names for
backwards compatibility for scripts running mke2fs and tune2fs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-17 23:31:44 -04:00
Eric Sandeen 7a1eac2fbe e2fsck: Only check PR_1_EXTENT_ENDS_BEYOND for leaf nodes
pass1 was checking that an "extent's" start+len did not extend
past the last filesystem block, but unless we are at a leaf
block, the physical block is that of a node in the tree, and
the length may include sparseness.  The test is only valid
for leaf blocks.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-04-17 17:16:47 -04:00
Theodore Ts'o 1ca1059fd0 Add support for the HUGE_FILE feature
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-17 16:38:13 -04:00
Theodore Ts'o 60dc00b285 Merge branch 'maint' 2008-04-07 12:38:16 -04:00
Matthias Koenig bb0224a771 e2fsck: avoid double free of ctx->filesystem_name
In current git there is a double free on ctx->filesystem_name in the
end of main() and in e2fsck_free_context, causing e2fsck to abort at
the end of pass5.

Signed-off-by: Matthias Koenig <mkoenig@suse.de>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-07 12:29:03 -04:00
Eric Sandeen 01c196b4f1 Fix a couple of implicit function declarations
Fedora seems to be gearing up to add
-Werror-implicit-function-declaration
to the standard build flags, so I thought I'd get out ahead
of this one...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-06 17:20:12 -04:00
Eric Sandeen dfc870c718 e2fsck: Fix extent flag validity tests in pass1 on big endian boxes.
Extent data is shared with the i_block[] space in the inode,
but it is always swapped on access, not when the inode is read.

In e2fsck/pass1.c we must be careful when checking validity
of the extents flag on the inode.  If the flag was set when
the inode was read & swapped, then the extents data itself
(in ->i_block[]) was NOT swapped, so testing for a valid
extent header requires some swapping first.  Then, if we
ultimately set the extents flag, all of i_block[] must be
re/un-swapped.

This passes the f_extent regression test on both ppc & x86.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-01 15:18:44 -04:00
Theodore Ts'o db0691b555 Fix trailing whitespace in e2fsck/problem.[ch]
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-31 14:28:38 -04:00
Andreas Dilger 0d5439c8e0 e2fsck: Add check to enforce a valid block bitmap in last block group
Add a check for the UNINIT_BLOCKS flag set in the last group.  The kernel
patch doesn't handle this gracefully, because it assumes there are a full
set of blocks in each group marked UNINIT_BLOCKS.  The kernel should be
fixed up, but in the meantime this avoids hitting the problem, and is
more consistent with lazy_bg not marking the last group UNINIT.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-31 14:28:38 -04:00
Andreas Dilger f628acea26 ext2fs_set_gdt_csum(): Return an error code on errors instead of void
Change the function signature so that ext2fs_set_gdt_csum() returns an
error code.

If the inode bitmap hasn't been loaded return EXT2_ET_NO_INODE_BITMAP.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-31 14:28:37 -04:00
Theodore Ts'o a70f10dbc4 Merge branch 'maint' 2008-03-30 14:03:51 -04:00
Theodore Ts'o a2447f8c8a e2fsck: Avoid core dump when using the -N option
This bug was accidentally introduced by commit 1dc506cb.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-29 14:46:48 -04:00
Theodore Ts'o 1dc506cbe9 e2fsck: Include the device name in the progress information
Also make sure the device name has no spaces in it, to avoid confusing
displays, and make ctx->filesystem_name and ctx->device_name allocated
memory to avoid potential problems in the future.

Addresses-Launchpad-Bug: #203323
Addresses-Sourceforge-Bug: #1926023

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-26 09:11:46 -04:00
Theodore Ts'o be62523be2 e2fsck: Support a negative argument to -C to suppress progress information
If a negative progress argument is given to -C, initially suppress the
progress information.  It can be enabled later by sending the e2fsck
process a SIGUSR1 signal.

Addresses-Launchpad-Bug: #203323
Addresses-Sourceforge-Bug: #1926023

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-26 08:26:01 -04:00
Theodore Ts'o cb23cad5b7 e2fsck: Don't object to extents flags on deleted fast symlinks
Thanks to Aneesh Kumar for pointing this out.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-24 08:17:24 -04:00
Eric Sandeen 85b59c40f4 Fix ext2fs_extent_get for uninit leaf extents
The ext2fs_extent_get() function was not OR-ing together UNINIT
and LEAF flags in the case where an extent was both; so if we
had an extent which was both uniint and leaf, pass1 would bail
out where depth == max_depth but was not marked as leaf, and
e2fsck (from the next branch) would abort with:

e2fsck 1.40.8 (13-Mar-2008)
Pass 1: Checking inodes, blocks, and sizes
Error1: No 'down' extent
Aborted

Also, if the error is encountered again, print the inode number
to aid debugging until it's properly handled, at least.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-20 15:45:27 -04:00
Jose R. Santos 49a7360ba6 Make e2fsck uninit block group aware
This patch has all the necesary pieces to open and fix filesystems created
with the uninit block group feature.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-20 15:33:12 -04:00
Theodore Ts'o 2d328bb76d Fix miscellaneous gcc -Wall warnings
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-17 23:17:13 -04:00
Andreas Dilger a7c9cb7d0d Add support for the DIR_NLINK feature.
This patch includes the changes required to e2fsck to understand the
nlink count changes made in the kernel.

In e2fsck pass 4, when we fetch the actual link count, if it is
exceeds 65,000 we set the link count to 1.  We silently fix the
situation where the nlink count of the directory is 1, and there are
fewer than 65,000 subdirectories, since since that can happen
naturally.

Patch originally from CFS, significantly rewritten by Theodore Ts'o.

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-15 01:39:19 -04:00
Theodore Ts'o ee19c902e6 e2fsck: Check for fast symlinks that have EXTENTS_FL set
These shouldn't show up in the wild, but if they do, e2fsck will offer
to clear them.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-13 23:13:18 -04:00
Theodore Ts'o 7cadc57780 e2fsck: Support long symlinks which use extents
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-13 23:05:00 -04:00
Theodore Ts'o a040a99b6c Merge branch 'maint'
Conflicts:

	lib/ext2fs/ext2_err.et.in
2008-03-13 10:53:26 -04:00
Theodore Ts'o 2a60480627 e2fsck: Use "Clear Htree" instead of "Clear" when the Htree is corrupt
Change the prompt so it is clear to the user that e2fsck will be
clearing the htree information, not the directory inode itself, when
the htree information has proven to be corrupt.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-13 10:44:54 -04:00
Theodore Ts'o 2cd1233839 e2fsck: Fix directory i_size handling
If a directory's i_size is bigger than the number of blocks, don't try
to allocate extra empty blocks to the end of the directory; there's no
real point to do that.  Also, if a directory's i_size is not a
multiple of the blocksize, flag that as a mistake so it can be fixed.

This more elegantly addresses the problem which was found on Bas van
Schaik's filesystem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-13 00:58:54 -04:00
Theodore Ts'o d45edec0fb e2fsck: Handle a pass 2 "should never happen" error gracefully
Turns out a "should never happen" error can indeed happen very easily
if a directory with an htree index has an incorrect, and too-large,
i_size field.  This patch fixes this so that we handle this situation
gracefully, allowing filesystems with this error to be fixed.

In another patch I will clean up the specific problem which caused the
internal "should never happen" error from happening at all, but patch
will prevent e2fsck from crashing, and prompt the user to remove the
htree index, so it can be rebuilt again after pass 3.

Thanks to Bas van Schaik at Tetra for giving me access to his system
so this problem could be debugged.

Addresses-Launchpad-Bug: #129395

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-12 16:10:48 -04:00
Theodore Ts'o 46d9a7462b e2fsck: Fix obvious typo in an "internal error" message
Thanks to Philipp Thomas for pointing this out.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-12 12:12:50 -04:00
Theodore Ts'o 399033a6ab Merge branch 'maint' 2008-02-29 00:43:29 -05:00
Mike Frysinger 1f803990b8 Fix makefile dependency issues for various install targets
Addresses-Sourceforge-Patches: #1903484
Addresses-Sourceforge-Patches: #1903466
Addresses-Sourceforge-Patches: #1903456

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-28 20:45:39 -05:00
Theodore Ts'o a49670e64e Merge branch 'maint'
Conflicts:

	lib/blkid/devname.c
	lib/blkid/probe.c
	misc/mke2fs.c
	misc/tune2fs.c
2008-02-27 18:53:34 -05:00
Theodore Ts'o 4f9abdcb30 e2fsck: Print an explicit message when the bad block inode is updated
Some users were confused about why the filesystem was modified.

Addresses-Sourceforge-Bug: #756460

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-27 15:10:20 -05:00
Theodore Ts'o 77175ca20c e2fsck: Don't clear the LARGE_FILES feature flag
Stop clearing the EXT2_FEATURE_RO_COMPAT_LARGE_FILE flag automatically
if there are no large files in the filesystem.  It's been almost a
decade since there have been kernels that don't support this flag, and
e2fsck clears it quietly without telling the user why the filesystem
has been changed.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-27 00:00:30 -05:00
Theodore Ts'o dcc91e1053 Enhance e2fsck's reporting for reporting unsupported filesystem features
Addresses-Sourceforge-Feature-Request: #1175808

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-26 20:59:56 -05:00
Theodore Ts'o a3d9d37664 e2fsck: Document that the -D option finds duplicate file names
Document in the e2fsck man page that e2fsck finds duplicate filenames
only when the -D option is passed to e2fsck.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-26 12:50:51 -05:00
Theodore Ts'o 7dc099887c e2fsck: Account for index nodes in the extent tree for i_blocks
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-22 15:53:50 -05:00
Andreas Dilger fefaef39e0 Improve support for in-inode EA's
Add vertificaton of the in-inode EA information, and allow in-inode
EA's to have a checksum.

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-18 21:20:26 -05:00
Theodore Ts'o 15d482ba6e e2fsck: Add support for extents
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-18 20:06:18 -05:00
Theodore Ts'o e3df15abdb e2fsck: factor out code to clear an inode into e2fsck_clear_inode()
Factor out code to clear a bogus inode and update e2fsck's internal
data structures accordingly into a common routine,
e2fsck_clear_inode().  This saves about 200 bytes in the compiled x86
e2fsck executable, and makes the code more maintainable in the
long-term.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-18 15:27:04 -05:00
Theodore Ts'o ef80fdc8ad Merge branch 'maint' into next 2008-02-10 08:03:54 -05:00
Theodore Ts'o 414025e542 Fix bug in e2fsck which caused it to core dump if --enable-jbd-debug is used
Missing curly braces from a python programmer; my bad for noticing it!

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-01-31 14:22:24 -05:00
Theodore Ts'o 428f6b32a9 Merge branch 'maint' into next
Conflicts:

	configure
	lib/ext2fs/ext2_fs.h
	misc/e2image.c
2008-01-27 20:09:05 -05:00
Theodore Ts'o 7e8fe327b5 Don't build e2fsck statically by default anymore
Also removed the --enable-dynamic-static configure option.

Unfortunately the usefulness of building e2fsck statically is gone on
all modern distributions, since everything else on the system is built
dynamically these days.  In fact on some distributions it is almost
impossible to build programs statically any more.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-01-27 18:22:18 -05:00
Theodore Ts'o a8cde73acb Ignore "safe" flag differences when e2fsck compares superblocks
Recent e2fsprogs (1.40.3 and higher) fsck compares primary superblock to
backups, and if things differ, it forces a full check.  However, the
kernel has a penchant for updating flags the first time a feature is
used - attributes, large files, etc.

This is a bad idea, and we should break the kernel of this habit,
especially for the ext4 feature flags.  But for now, let's make e2fsck
avoid forcing a full check and backup except when absolutely
necessary.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-01-26 23:17:50 -05:00
Theodore Ts'o fef2b38d8e Merge branch 'maint' into next
Conflicts:

	configure
	debian/rules
	e2fsck/swapfs.c
	lib/ext2fs/ext2_fs.h
2008-01-01 12:41:35 -05:00
Theodore Ts'o d66c38329e e2fsck: When optimizing non-htree directories, sort by inode number
Previously "e2fsck -fD" on a non-htree directory would sort the
directory alphabetically by name.  That's stupid.  Better to sort the
directory by inode number, since that will optimize performance much
more significantly than sorting by name!

Addresses-Sourceforge-Feature-Request: #532439

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-01-01 10:59:57 -05:00
Theodore Ts'o 1e5c6d34e7 Expand discussion of the -D option in e2fsck's man page
Add an explanation of how e2fsck might decide to optimize a few
directories even without the -D option being specified.

Addresses-Debian-Bug: #441872

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-01-01 00:22:46 -05:00
Theodore Ts'o e5aace908e Convert use of ext2fs_get_mem to ext2fs_get_array for overflow detection
Add some additional checks, primarily in resize2fs and in the rarely
used (and soon to-be-deprecated) e2fsck byte-swap filesystem function.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-27 10:08:13 -05:00
Theodore Ts'o e6a4571eec Merge branch 'maint' into next
Conflicts:

	lib/ext2fs/closefs.c
2007-12-09 17:03:01 -05:00
Theodore Ts'o 7ce238977a Add Ubuntu-specific e2fsck.conf file to work around Ubuntu issues
Ubuntu has init script and installer issues which cause them to have
significant problems with time zones.  This is compounded with a
relatively inexperienced user base who want to dual boot with Windows
and so have their hardware clocks tick localtime.

Addresses-Ubuntu-Bug: #131201

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-05 21:01:22 -05:00
Theodore Ts'o 5ea565fd37 Merge basic FLEX_BG support
Merge commit 'c2d4300b8a4a13d8a78b86c386f76259f23feec2' into next
2007-11-03 21:01:01 -04:00
Jose R. Santos 88b34b1f87 Relax group descriptor checking for FLEX_BG
The FLEX_BG feature allows the inode table, block bitmap, and inode
bitmaps to be located anywhere in the filesystem.  Update e2fsck and
libext2fs's checking code to recognize this.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
--

 e2fsck/super.c          |   14 ++++++++++++--
 lib/ext2fs/check_desc.c |   15 +++++++++++++--
 2 files changed, 25 insertions(+), 4 deletions(-)
2007-11-03 20:13:16 -04:00
Theodore Ts'o d9099eec8e Merge branch 'cl/remove-masix' into next 2007-11-01 01:54:22 -04:00
Coly Li 5b57d921b4 e2fsck: remove masix support
This patch remove masix support from e2fsck.

Signed-off-by: Coly Li <coyli@suse.de>
2007-11-01 01:53:56 -04:00
Dmitry V. Levin da938f20ac check_ea_in_inode: Cleanup e2fsck_write_inode_full() call
Avoid pointer cast and call e2fsck_write_inode_full() the same way
as check_inode_extra_space() does.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2007-11-01 00:32:32 -04:00
Valerie Clement 5d38ef1d04 libext2fs: cleanup usage of unsigned int or __u32 and replace it with blk_t
Signed-off-by: Valerie Clement <valerie.clement@bull.net>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-10-14 21:54:28 -04:00
Theodore Ts'o 2628a1d3e1 Merge branch 'maint' 2007-10-06 12:41:26 -04:00
Theodore Ts'o 0c37f456d9 e2fsck: backup superblocks if key constants have changed
If the primary superblock differs from the backup superblock in
certain key respects, force a full check (if e2fsck was invoked in
preen mode).  If the filesystem check passes cleanly, and the
filesystem was opened in read/write mode, then write the primary
superblock to all of the backups.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-10-06 12:39:57 -04:00
Theodore Ts'o 0cfce7f749 e2fsck: update the backup superblocks if the feature bitmasks are changed
If e2fsck adds or deletes any of the feature bitmasks, clear
EXT2_FLAG_MASTER_SB_ONLY so the backup superblocks are updated when
e2fsck finishes.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-10-06 12:39:57 -04:00
Theodore Ts'o d006b8cee7 e2fsck: Don't mark the filesystem invalid because of time errors
If superblock mount time or last write time is in the future, and the
user refuses to fix the problem, don't mark the filesystem as being
invalid and needing to be checked.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-09-23 08:20:51 -04:00
Theodore Ts'o 60702c267d Work around lame Ubuntu init scripts / installer bugs
The Ubuntu init scripts don't properly set the system time correctly
from hardware clock if the hardware clock is configured to tick local
time instead of GMT time.

Work around this as best as we can by providing an option in
/etc/e2fsck.conf which can be set on Ubuntu systems:

[options]
	buggy_init_scripts = 1

Addresses-Debian-Bug: #441093
Addresses-Ubuntu-Bug: #131201

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-09-22 20:43:11 -04:00
Theodore Ts'o cd538080ab e2fsck: If the superblock is corrupt, automatically retry with the backup sb
E2fsck currently only retries with the backup superblock if the
primary superblock is missing (e.g., overwritten with garbage).  If
the superblock is just corrupted enough that it looks like ext2/3/4
superblock, but it is corrupt enough that ext2fs_open2() returns an
error, e2fsck stops without retrying.  Let's fix this oversight.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-09-07 16:54:11 -04:00
Theodore Ts'o e9e9602246 Merge branch 'maint' 2007-08-20 22:58:25 -04:00
Theodore Ts'o 5845caa464 Use sscanf instead of atoi when parsing e2fsck options
atoi() does not check for errors so it shouldn't be used for human
input.  For example, if the user enters the command "e2fsck -C -n" and
forgets that -C requires an argument, the -n will be used as the
argument to -C, and not parsed as an option.  When using sscanf(),
this error case can be detected.

Addresses-Debian-Bug: #435381

Signed-off-by: Bernd Schubert <bs@q-leap.de>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-08-20 22:55:33 -04:00
Theodore Ts'o 2eae093081 Clean up applications to not use EXT2FS_ENABLE_SWAPFS or EXT2_FLAG_SWAP_BYTES
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-08-11 02:57:31 -04:00
Theodore Ts'o 1a855cb21f Remove e2fsck's -s and -S options to byte-swap ancient PPC filesystems
The need for fixing byte-swapped filesystems is long-gone, and this is
getting in the way of cleaning up e2fsprogs's bitmaps code.  So let's
get rid of it; modern kernels haven't been able to deal with a
byte-swapped filesystem in in about 9 years.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-08-11 01:58:21 -04:00
Theodore Ts'o aef2283196 Merge branch 'maint' 2007-08-03 23:21:34 -04:00
Theodore Ts'o 9f0288d3bb e2fsck: Allow i_size to be rounded up to the size of a VM page
Allow files to be preallocated on-disk up to the next multiple of the
system's page size without complaining about extra blocks.

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: Girish Shilamkar <girish@clusterfs.com>
Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-08-03 20:43:37 -04:00
Theodore Ts'o 6d96b00d57 Add I/O statistics to e2fsck
This patch instruments the libext2fs unix I/O manager and adds bytes
read/written and data rate to e2fsck -tt pass/overall timing output.

Signed-off-by: Jim Garlick <garlick@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-08-03 20:07:09 -04:00
Theodore Ts'o f1f115a78f libext2fs: 32-bit bitmap refactorization, part 3
Create new functions ext2fs_{set,get}_{inode,block}_bitmap_range()
which allow programs like e2fsck, dumpe2fs, etc. to get and set chunks
of the bitmap at a time.

Move the representation details of the 32-bit old-style bitmaps into
gen_bitmap.c.

Change calls in dumpe2fs, mke2s, et. al to use the new abstractions.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-23 04:32:48 -04:00
Theodore Ts'o 5e9ba85c26 Fix e2fsck segfault on very badly damaged filesystems
A recent change to e2fsck_add_dir_info() to use tdb files to check
filesystems with a very large number of filesystems had a typo which
caused us to resize the wrong data structure.  This would cause a
array overrun leading to malloc pointer corruptions.  Since we
normally can very accurately predict how big the the dirinfo array
needs to be, this bug only got triggered on very badly corrupted
filesystems.

Thanks to Andreas Dilger for submitting the test case which discovered
this problem, and to Kalpak Shah for writing a random testing script
which created the test case.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-11 13:42:43 -04:00
Kalpak Shah 575307cc63 e2fsck: Fix salvage_directory when the last entry's rec_len is too big
Recently, one of our customers found this message in pass2 of e2fsck
  while doing some regression testing:

  "Entry '4, 0x695a, 0x81ff, 0x0040, 0x8320, 0xa192, 0x0021' in ??? (136554) has
  rec_len of 14200, should be 26908."

  Both the displayed rec_len and the "should be" value are bogus. The
  reason is that salvage_directory sets a offset beyond blocksize
  leading to bogus messages.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-10 07:28:35 -04:00
Theodore Ts'o 424a3e4a23 Remove Changelog files since they're not used after the git migration
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-08 08:50:41 -04:00
Theodore Ts'o 6f890e516d Add new function: profile_set_default()
profile_set_default() sets the value of the pseudo file "<default>".
If the file "<default>" had previously been passed to profile_init(),
then def_string parameter will be parsed and used as the profile
information for the "<default>" file.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-04 13:03:35 -04:00
Theodore Ts'o 6bde5c28ba Add PROFILE_FILE_NO_RELOAD flag which is used by profile_update_file()
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-04 10:36:15 -04:00
Theodore Ts'o 1a191d6648 e2fsck: Detect recursive loops in @-expansions
The Turkish translation has a bug in it where it has the translation
of "E@e '%Dn' in %p (%i)" to "E@E".  This causes @E to be expanded at
@E, recursively, forever, until the stack fills up e2fsck core dumps.

Fix it by stopping after a recursive depth of 10, which is far more
than we need.

Addresses-Sourceforge-Bug: 1646081

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-02 19:04:31 -04:00
Theodore Ts'o d7b64725ee Update Release Notes, Changelogs, version.h, etc. for 1.40 release
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-24 17:32:47 -04:00
Andreas Dilger a34c6ffd68 e2fsck: added sanity check for xattr validation
Add an extra validity test in check_ext_attr().  If an attribute's
e_value_size is zero the current code does not allocate a region for it
and as a result the e_value_offs value is not verified.  However, if
e_value_offs is very large then the later call to
ext2fs_ext_attr_hash_entry() can dereference bad memory and crash
e2fsck.

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: Jim Garlick <garlick@llnl.gov>
2007-06-22 02:22:38 -04:00
Theodore Ts'o df36136301 Fix gcc -Wall bug in e2fsck
Remove extraneous return after fatal_error().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-21 13:31:13 -04:00
Theodore Ts'o 051afbe0d7 e2fsck: Check the all of journal blocks for validity
The original code only checked the direct blocks to make sure the
journal inode was sane.  Unfortunately, if some or all of the indirect
or doubly indirect blocks were corrupted, this would not be caught.
Thanks to Andreas Dilger and Kalpak Shah for noticing this problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-21 11:59:06 -04:00
Kalpak Shah ded28ac2ab Write the updated journal inode if s_jnl_blocks was successfully used
If the journal inode was corrected from s_jnl_blocks, write the fixed
journal inode back to disk.

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
2007-06-21 11:59:06 -04:00
Kalpak Shah 5107d0d196 Recreate journal that had been removed previously due to corruption
If the journal had been removed because it was corrupt, the
E2F_FLAG_JOURNAL_INODE flag will be set.  If this flag is set, then
recreate the filesystem after checking the filesystem.

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
2007-06-21 11:59:06 -04:00
Theodore Ts'o 058ad1c70c Don't write changes to the backup superblocks by default
This patch changes ext2fs_open() to set EXT2_FLAG_MASTER_SB_ONLY by
default.  This avoids some problems in e2fsck (reported by Jim Garlick)
where a corrupt journal can end up writing the bad superblock to the
backups.  In general, only e2fsck (after the filesystem is clean),
tune2fs, and resize2fs should change the backup superblocks by default.
Most callers of ext2fs_open() should not be touching anything where the
backups should be touched.  So let's change the defaults to avoid
potential problems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-18 18:26:50 -04:00
Theodore Ts'o d2af1bdd05 Fix e2fsck's get_size logic so it will work with the Linux floppy driver
The Linux floppy driver is a bit different from the other block device
drivers, in that if the device has been opened with O_EXCL, it disallows
another open(), even if the second open() does not have the O_EXCL flag.
So this patch moves the call to ext2fs_get_device_size() so that if it
returns EBUSY, e2fsck can close the filesystem, retry the device size,
and then reopen it.  This rather complicated approach is required since
we need to know the blocksize of the filesystem before we can call
ext2fs_get_device_size().

Addresses Debian Bug: #410569

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-04 01:14:52 -04:00
Daniel Drake e7b5d3c0b2 e2fsck: Add blocksize sanity check when finding a backup superblock
I've been investigating why e2fsck refuses to restore the backup superblock
of a partition with a broken primary superblock.

The partition in question has a block size of 4096, and mke2fs reports that
backup superblocks were created on blocks 32768, 98304, 163840, ...

When running e2fsck, get_backup_sb starts by guessing a block size of 1024
and backup superblock at block 8193. I'm not sure why, but it actually finds
a superblock at this location, so returns a context with superblock 8193,
blocksize 1024.

Later on, ext2fs_open2() tries to process this superblock. It then realises
that the block size value stored in the superblock (4096) does not match what
it was told (1024), so it bails out with EXT2_ET_UNEXPECTED_BLOCK_SIZE. fsck
aborts without fixing the partition.

The following patch solves the problem by discounting superblocks which do
not meet the currently-sought block size.
As a result, block 32768 (blocksize=4096) is now used to restore the backup,
which agrees with the first location that mke2fs listed.

Signed-off-by: Daniel Drake <d.drake@mmm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-31 11:56:17 -04:00
Brian Behlendorf 8f234d9650 [COVERITY] Free potential null dereference bug in e2fsck
At the second conditional iter->file could still be NULL. We need to
check for it again.  Should never happen in practice, but better to be
sure.

Coverity ID: 6: Forward Null

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-31 11:42:48 -04:00
Andreas Dilger de8f3a7621 Fix gcc -Wall warnings, especially on 64-bit systems
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-25 11:18:11 -04:00
Theodore Ts'o f954ba012f Fix gcc -Wall issues in e2fsck sources
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
2007-05-22 20:53:01 -04:00
Theodore Ts'o 32460c1e4c Add new function profile_get_uint() in the e2fsck sources
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-22 20:51:47 -04:00
Kalpak Shah 1a8c2c4a89 Remove check in e2fsck which requires EA's in inodes to be sorted
This patch removes a code snippet from check_ea_in_inode() in pass1 which checks
if the EA values in the inode are sorted or not. The comments in fs/ext*/xattr.c
state that the EA values in the external EA block are sorted but those in the
inode need not be sorted. I have also attached a test image which has unsorted
EAs in the inodes. The current e2fsck wrongly clears the EAs in the inode.

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
2007-05-08 01:07:30 -04:00
Eric Sandeen 5113a6e32b Fix mke2fs and debugfs to support large (> 16 bit) uid's and gid's
Mke2fs is supposed to set the uid/gid ownership of the root directory when
a non-rooot user creates the filesystem.  This wasn't working correctly
if the uid/gid was > 16 bits.   In additional, debugfs wasn't displaying
large uid/gid's correctly.  This patch fixes these two programs.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-08 00:10:54 -04:00
Jim Garlick 81cae650b7 e2fsck: Count the root directory as found if it has shared blocks in pass1c
Another small bug I think: if the root directory contains shared
blocks, e2fsck pass1c search_dirent_proc() will be looking for
one more containing directory than it will ever find, and thus
loses an opportunity to terminate early.

Signed-off-by: Jim Garlick <garlick@llnl.gov>
2007-04-20 08:14:27 -04:00
Theodore Ts'o a4d7d90deb Fix minor typo in e2fsck.conf.5.in man page
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-18 22:12:50 -04:00
Theodore Ts'o d5b753ee4d Remove unused variable in e2fsck/pass2.c:check_dir_block()
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-18 22:11:31 -04:00
Bryn M. Reeves 3f4c46e3f9 Correct byteswapping for fast symlinks with xattrs
Fix a problem byte-swapping fast symlinks inodes that contain extended
attributes.

Addresses Red Hat Bugzilla: #232663
Addresses LTC Bugzilla: #27634

Signed-off-by: "Bryn M. Reeves" <breeves@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-14 14:00:31 -04:00
Theodore Ts'o 0eeb154937 Fix e2fsck's check_is_really_dir logic
Fix a typo which could cause e2fsck to throw an I/O error while doubling
checking whether or not a special device file was really an inode.
Also, don't do this tests on symbolic links since for filesystems with a
large numbers of symlinks it could degrade performance and increases the
risk for false positives.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-14 12:01:39 -04:00
Theodore Ts'o e94bc63164 Improve I/O error messages in e2fsck
Add better ehandler_operation() markers so it is clearer what e2fsck was
doing when an I/O error is reported.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-14 09:29:02 -04:00
Jim Garlick 3d51ff876e e2fsck: pass1c terminates early if hard links
I think this is a small buglet in e2fsck:  if a file has multiple hard
links, e2fsck pass1c search_dirent_proc() doesn't maintain its count
properly and may return DIRENT_ABORT before it has found containing
directories for all inodes sharing blocks.

Signed-off-by: Jim Garlick <garlick@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-10 22:55:09 -04:00
Theodore Ts'o 39efa4c500 Update the e2fsck.conf(5) man page to document the [scratch_files] section
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-06 23:32:06 -04:00
Theodore Ts'o a1f642728f Fix memory leaks from using the tdb library
We weren't freeing allocated memory from calls to tdb_fetch, tdb_firstkey,
and tdb_nextkey.  Oops.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-06 23:28:30 -04:00
Theodore Ts'o 25a9fe2894 Enable e2fsck to use the tdb library to store the dirinfo abstraction
If e2fsck.conf configures a scratch_files directory which is available,
and the number of directories exceeds scratch_files.numdirs_threshold,
then try to use the tdb library to store the directory information
abstraction.  This allows us to check very large filesystems without
needing as much physical memory.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-06 18:44:37 -04:00
Theodore Ts'o 34b9f79639 Enable e2fsck to use the tdb library for the inode count abstraction
If e2fsck.conf configures a scratch_files directory which is available,
and the number of directories exceeds scratch_files.numdirs_threshold,
then try to use the tdb library to store the inode count abstraction.
This allows us to check very large filesystems without needing as much
physical memory.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-06 18:43:11 -04:00
Theodore Ts'o 28db82a84a Rework e2fsck's dirinfo abstraction to be more friendly for databases
Change the iterator abstraction and replace e2fsck_get_dir_info() with
e2fsck_dir_info_{set,get}_{parent,dotdot} so that we can support an
on-disk dirinfo implementation.  This allows e2fsck to check very large
filesystems on systems with smaller amounts of memory and/or address
space.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-04 22:33:31 -04:00
Theodore Ts'o 86bc90f4f1 Fix potential reference (and free) to an uninitialized pointer in e2fsck
This was introduced recently when fixing a problem noted by Coverty.
Oops!

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-04 21:42:42 -04:00
Theodore Ts'o fbc3f90194 e2fsck: Recover a special file which looks an awful lot like a directory
This is probably only useful in artificial test cases, but it will be
useful if we ever do the "inodes in directory" idea for ext4.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-02 10:08:59 -04:00
Theodore Ts'o ccfbb266d6 e2fsck: Add support for %It in problem description messages
Add support for the %It expansion, which will print the type of the inode
in the problem context.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-31 19:53:53 -04:00
Theodore Ts'o 56c8c592ac Fix e2fsck to set the filetype of '..' when connecting a dir, to lost+found
If there is an orphaned inode whose '..' entry is pointing at a special
file, the filetype of the '..' entry will set to the type of the special
file.  When the orphaned directory is reconnected to /lost+found, the
filetype of the '..' field is not reset to EXT2_FT_DIR, so a second
e2fsck is required to repair the filesystem.

We address this situation by setting the filetype of '..' when we
reconnect the inode to /lost+found.

Addresses Lustre Bug: #11645

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-31 19:18:24 -04:00