Commit Graph

674 Commits (977ac8731bf3bd934421dd8107e77325ec7e6de7)

Author SHA1 Message Date
Eric Sandeen 3efc3a04fc Check for potential 64-bit overflow in ext2fs_get_device_size()
Check for potential overflow for filesystems contained in regular files
where the filesystem image size is returned by stat64().

Signed-off-by: Eric Sandeen <esandeen@sandeen.net>
2006-10-02 09:30:41 -04:00
Theodore Ts'o fa2d516fb3 Fix build problem if byte swapping has been disabled.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-10-01 21:42:21 -04:00
Theodore Ts'o 23bb9b106a Fix e2p_percent() crash if percentage was zero.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-09-29 10:23:16 -04:00
Theodore Ts'o 5b984ab51f blkid_devno_to_devname(): Avoid recursive loops due to symlinks in /dev
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-09-24 22:33:38 -04:00
Karel Zak 633f453db1 Fix blkid bug with correctly reporting FAT filesystem labels that are empty
Signed-off-by: Karel Zak <kzak@redhat.com>
2006-09-17 21:23:46 -04:00
Karel Zak b5517ca667 Add GFS/GFS2 support to the blkid library.
Signed-off-by: Karel Zak <kzak@redhat.com>
2006-09-17 21:10:58 -04:00
Eric Sandeen f335864338 Add checks to make sure inode counts don't overflow a 32-bit value
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-09-12 14:56:17 -04:00
Eric Sandeen abf23439d5 Create new ext2fs library inlines: ext2fs_group_{first,last}_block()
Create new ext2fs library inline functions in order to calculate
the starting and ending blocks in a block group.

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-09-12 14:56:16 -04:00
Eric Sandeen d0ff90d520 Fix signed vs unsigned printf format strings for block and inode numbers
There were still some %d's lurking when we print blocks & inodes; also
many of the counters in the e2fsck_struct were signed, and probably
need to be unsigned to avoid overflows.

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-09-12 14:56:15 -04:00
Eric Sandeen 62c6d1403e Remove unused variables
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-09-12 14:56:12 -04:00
Eric Sandeen bb1a46a430 Fix loops over group descriptors to prevent 2**32-1 block number overflows
For loops iterating over all group descriptors, consistently define
first_block and last_block in a way that they are inclusive of the
range, and do not overflow.

Previously on the last block group we did a test of <= first +
dec_blocks; this would actually wrap back to 0 for a total block count
of 2^32-1

Also add handling of last block group which may be smaller.

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-09-12 14:55:22 -04:00
Theodore Ts'o a02fa9beb8 Fix bug in device mapper scanning; probe_one() doesn't want a leading /dev
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-09-12 01:30:53 -04:00
Theodore Ts'o a8862d9e90 Fix potential 2**32-1 overflow by using e2p_percent()
Add a new functiom, e2p_percent(), which correct calculates the percentage
of a number based on a given percentage, without worrying about overflow
issues.  This is used where we calculate the number of reserved blocks using
a percentage of the total number of blocks in a filesystem.

Based on patches from Eric Sandeen, but generalized to use this new function.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-08-30 03:08:13 -04:00
Eric Sandeen 5830d6be9c Detect overflows in loop counters
For loops such as:

for (i=1; i <= fs->super->s_blocks_count; i++) {
        <do_stuff>
}

if i is an int and s_blocks_count is (2^32-1), the condition is never false.
Change these loops to:

for (i=1; i <= fs->super->s_blocks_count && i > 0; i++) {
        <do_stuff>
}

to stop the loop when we overflow i

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-08-30 02:16:55 -04:00
Theodore Ts'o 69022e029f Fix potential 2**32-1 overflow problems by ext2fs_div_ceil()
Add a new function, ext2fs_div_ceil(), which correctly calculates a division
of two unsigned integer where the result is always rounded up the next
largest integer.   This is used everywhere where we might have
previously caused an overflow when the number of blocks
or inodes is too close to 2**32-1.

Based on patches from Eric Sandeen, but generalized to use this new function

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-08-30 01:57:00 -04:00
Andreas Dilger f776a2354d blkid.8.in: Fix description of the -l option to be more accurate
This patch fixes the blkid.8.in description of the "-l" option.  The man
page gives the impression that the first match is the one that is returned.
However, the blkid_find_dev_with_tag() function returns the device with
the highest priority (which is good, because that is what people really want).

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
2006-08-19 21:12:15 -04:00
Andreas Dilger cc6d1a9ef7 This patch fixes up an error in the lib/blkid/Makefile.in which was causing
all lib/blkid/tst* files to be removed with "make clean", in particular
tst_types.c.  That was causing a failure of "make check" in an RPM source
tree.  Fix is to explicitly list the test binaries, as lib/ext2fs/Makefile.in
does.

As "make check" was only calling test_probe and tst_types (and none
of the other tst_* tests) it was not clear what was going on, and an
"hg update" would always return the old tst_types.c file back so the
problem was only being seen intermittently...  It isn't clear whether
you want the other tst_* programs to be run as part of "make check".

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
2006-08-19 20:05:28 -04:00
Andreas Dilger a62e3f0378 Add 64-bit byte swapping functions
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
2006-08-06 01:39:30 -04:00
Andreas Dilger 8fe81a3d53 Rename EXT3_EXTENTS_FL to EXT4_EXTENTS_FL and make it visible to the user
lsattr will display the EXT4_EXTENTS_FL flag

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-08-05 18:50:22 -04:00
Andreas Dilger 3f5ef9642b Create the generated files read-only to remind developers not to edit them.
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-08-05 14:41:00 -04:00
Andreas Dilger 067911ae73 Allow default inode_size to be specified in mke2fs.conf and document mke2fs -I
This patch allows "inode_size" to be specified in the mke2fs.conf file,
and always compiles in the "-I" option.  In addition, it disallows
specifying the inode size on rev 0 filesystems, though I don't think
this was much of a danger anyways.

Clean up dead lines in ext2fs.h.

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-07-15 22:08:20 -04:00
Andreas Dilger 347e52de90 Protect ext2_ext_attr.h from multiple inclusion
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
2006-06-28 11:29:56 -04:00
Andreas Dilger 9a519c0284 fix comment for blkid_get_dev_size()
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
2006-06-21 00:04:08 -04:00
Matthias Andree aadac9b7bb Add parentheses and casts to make GCC happy.
Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
2006-05-30 16:29:49 +02:00
Matthias Andree df3e159870 Add missing #include <ctype.h>.
Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
2006-05-30 16:28:42 +02:00
Matthias Andree 406ba674fe Fix non-Linux compiler warning (missing return statement).
Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
2006-05-30 16:28:22 +02:00
Matthias Andree 94fa1108ee Fix SIGBUS through unaligned access to FAT superblocks.
SPARCs do not like unaligned halfword access and throw SIGBUS.
Read data "manually" instead.

Tested on Solaris 8/SPARC with gcc 2.95.3.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
2006-05-30 15:47:12 +02:00
Matthias Andree 0ac93a00c9 Change more "echo -n" to "printf" to avoid screen clutter.
Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
2006-05-30 15:47:05 +02:00
Matthias Andree bdc3514af4 Switch endian detection from Linuxism to AC_C_BIGENDIAN.
This fixes all blkid test failures on FreeBSD 4.11 i386.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
2006-05-30 14:42:47 +02:00
Matthias Andree a0dfc6ea8c Revise DIOCGDINFO (sys/disklabel.h) related FreeBSD comment.
Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
2006-05-30 05:08:02 +02:00
Matthias Andree 5beaabb0f8 Enable sys/disklabel.h and DIOCGDINFO based getsize code.
Tested on FreeBSD 4.11-RELEASE i386.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
2006-05-30 04:26:13 +02:00
Matthias Andree 12a829dcdc Add a bunch of type fixes for debug/"make check" code paths.
Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
2006-05-30 01:48:51 +02:00
Matthias Andree 21261a0ea2 Cast time_t variable to long for fprintf to match %ld.
Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
2006-05-30 01:20:46 +02:00
Matthias Andree 66352fe200 Drop unused vector uuid[].
Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
2006-05-30 01:20:17 +02:00
Matthias Andree f72b8ff098 Implement DIOCGMEDIASIZE for FreeBSD's GEOM.
Try DIOCGMEDIASIZE ioctl() if defined, to obtain
the media size on FreeBSD 5.0 and newer.
The binary search fallback doesn't work, as FreeBSD
block devices are unbuffered and refuse reads below
the block size.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
2006-05-30 00:54:49 +02:00
Theodore Ts'o 85f93ffdc4 Fix type warning problem with sizeof() in ext2fs_open2()
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-05-21 19:26:45 -04:00
Theodore Ts'o 49487b79da Fixed signed vs. unsigned comparison warning in strncmp().
It's better to use memcmp() anyway given the code in question.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-05-14 17:29:00 -04:00
Theodore Ts'o bc2699f018 Change mke2fs's layout of RAID-optimized filesystems to be more optimal
When allocating space for the RAID filesystems with the stride parameter,
place each portion of the group's inode table right up after the superblock
(if present) in order to minimize fragmentation of the freespace.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-05-13 08:46:37 -04:00
Theodore Ts'o f5fa20078b Add support for EXT2_FEATURE_COMPAT_LAZY_BG
This feature is initially intended for testing purposes; it allows an
ext2/ext3 developer to create very large filesystems using sparse files
where most of the block groups are not initialized and so do not require
much disk space.  Eventually it could be used as a way of speeding up
mke2fs and e2fsck for large filesystem, but that would be best done by 
adding an RO_COMPAT extension to the filesystem to allow the inode table
to be lazily initialized on a per-block basis, instead of being entirely initialized
or entirely unused on a per-blockgroup basis.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-05-08 20:17:26 -04:00
Theodore Ts'o 1f2da2c011 Speed up mke2fs and e2fsck by writing bitmaps more efficiently
Reduce disk seeks by writing the inode and block bitmaps in an interleaved fashion.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-04-23 12:43:40 -04:00
Theodore Ts'o b116e781f6 Fix bug which could cause dumpe2fs to rarely fail to print a UUID
uuid.c (e2p_is_null_uuid): Fix really stupid bug which could cause dumpe2fs
to fail to display a the journal or hash seed UUID.  (Thanks to Guillaume
Chambraud for pointing this out.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-04-22 04:32:36 -04:00
Theodore Ts'o 4ea7ea007b Fix asm_types.h type conflicts
This caused FTBFS bugs on AMD64 platforms, since it uses a different
64-bit type when compared with IA64, so we need to make our
autoconfiguration system more intelligent.

Addresses Debian Bugs: #360661, #360317

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-04-09 08:41:55 -04:00
Theodore Ts'o cef2ac104d Fix ext2fs_add_journal_inode() when filesystem is opened in exclusive mode
If the filesystem is opened in exclusive mode, then device will be
busy by definition, so don't return -EBUSY.  This caused mke2fs -j to
fail on the 1.39-WIP (29-Mar-2006) release.  (Addresses Debian Bug:
#360652)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-04-04 19:23:41 -04:00
Theodore Ts'o 8ad26b08fa Fix the x86 asm constraints for ext2fs_set/clear_bit.
The assembly function reads/writes the data files, so make sure we
tell gcc that.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-29 14:23:00 -05:00
Theodore Ts'o f9bcce3be0 Fix the i386 bitmap operations so they are 32-bit clean
The x86 assembly instructures for bit test-and-set, test-and-clear,
etc., interpret the bit number as a 32-bit signed number, which is
problematic in order to support filesystems > 8TB.  

Added new inline functions (in C) to implement a
ext2fs_fast_set/clear_bit() that does not return the old value of the
bit, and use it for the fast block/bitmap functions.

Added a regression test suite to test the low-level bit operations
functions to make sure they work correctly.

Note that a bitmap can address 2**32 blocks requires 2**29 bytes, or
512 megabytes.  E2fsck requires 3 (and possibly 4 block bitmaps),
which means that the block bitmaps can require 2GB all by themselves,
and this doesn't include the 4 or 5 inode bitmaps (which assuming an
8k inode ratio, will take 256 megabytes each).  This means that it's
more likely that a filesystem check of a filesystem greater than 2**31
blocks will fail if the e2fsck is dynamically linked (since the shared
libraries can consume a substantial portion of the 3GB address space
available to x86 userspace applications).  Even if e2fsck is
statically linked, for a badly damaged filesystem, which may require
additional block and/or inode bitmaps, I am not sure e2fsck will
succeed in all cases.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-25 13:42:45 -05:00
Theodore Ts'o 292811f2aa Fix typo bug in previous commit (6ae1ed49c8c6)
"fd" should have been "probe.fd" so blkid/probe.c can compile without
errors.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-25 01:42:02 -05:00
Theodore Ts'o 2858c94e35 Fix file descriptor leak in blkid library in error paths
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-23 22:14:54 -05:00
Theodore Ts'o 9dc6ad1ecb Change mke2fs to use /etc/mke2fs.conf as a configuration file
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-23 22:00:01 -05:00
Theodore Ts'o f4f425b20b Prevent error messages to stderr caused by libblkid calling libdevmapper
Make the libdevmapper fail quietly if blkid is called without root
privileges or the kernel does not include device mapper support.
(What is the device mapper _library_ doing writing to stderr, anyway?)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-19 15:26:26 -05:00
Theodore Ts'o 39c47ce641 Add EXT2_FLAG_EXCLUSIVE to the ext2fs library.
This flag when specified to ext2fs_open or ext2fs_initialize indicates 
that the application wants the io_channel to be opened in exclusive mode.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-18 19:16:10 -05:00