Commit Graph

684 Commits (927566a3abfdb576c53b42898affb78333e7299a)

Author SHA1 Message Date
Theodore Ts'o 05155f9bff Set local environment variables to C so mk_cmds and compile_et always work
Addresses SourceForge Bug: #1532177

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-12 10:43:31 -05:00
Theodore Ts'o 2aee23f325 Allow unix_io offsets greater than 2G
Addresses SourceForge Bug: #1547922

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-12 10:40:40 -05:00
Theodore Ts'o f77704e416 Add directory hashed signed/unsigned hint to superblock
The e2fsprogs and kernel implementation of directory hash tree has a
bug which causes the implementation to be dependent on whether
characters are signed or unsigned.  Platforms such as the PowerPC,
Arm, and S/390 have signed characters by default, which means that
hash directories on those systems are incompatible with hash
directories on other systems, such as the x86.

To fix this we add a new flags field to the superblock, and define two
new bits in that field to indicate whether or not the directory should
be signed or unsigned.  If the bits are not set, e2fsck and fixed
kernels will set them to the signed/unsigned value of the currently
running platform, and then respect those bits when calculating the
directory hash.  This allows compatibility with current filesystems,
as well as allowing cross-architectural compatibility.

Addresses Debian Bug: #389772

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-11 22:32:35 -05:00
Theodore Ts'o 6b3ce9871c On-disk format for controlling the inode size
- EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE (0x0040?) - add s_min_extra_isize and
  s_want_extra_isize fields to superblock, which allow specifying
  the minimum and desired i_extra_isize fields in large inodes
  (for nsec+epoch timestamps, potential other uses).  Needs RO_COMPAT
  flag handling, needs e2fsck support, patch complete, little testing.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-11 09:45:22 -05:00
Theodore Ts'o 8061d2c144 On-disk format definition for 64-bit support
- EXT4_FEATURE_INCOMPAT_64BIT (0x0080) - support for 64-bit block count
  fields in the superblock (s_blocks_count_hi, s_free_blocks_count_hi),
  large group descriptors (s_desc_size), extents with high 16 bits
  (ee_start_hi, ei_leaf_hi), inode ACL (i_file_acl_hi).  May also grow
  to encompass the previously proposed BIG_BG.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-11 09:44:47 -05:00
Theodore Ts'o bec6f49a46 On-disk format for large number of subdirectories
- EXT4_FEATURE_RO_COMPAT_DIR_NLINK (0x0020?) - allow directories to have
  > 65000 subdirectories (i_nlinks) by setting i_nlinks = 1 for such
  directories.  RO_COMPAT protects old filesystems from unlinking such
  directories incorrectly and losing all files therein.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-11 09:43:42 -05:00
Theodore Ts'o 8815fb8a00 On-disk format definition for group descriptor checksums
- EXT4_FEATURE_RO_COMPAT_GDT_CSUM (0x0010?) - store a crc16 checksum in
  the group descriptor (s_uuid[16] | __u32 group | ext3_group_desc
  (excluding gd_checksum itself)).  This allows the kernel to more safely
  manage UNINIT groups.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-11 09:41:52 -05:00
Theodore Ts'o 5d17119d14 On-disk format definition for huge files
- EXT4_FEATURE_RO_COMPAT_HUGE_FILE (0x0008) - change i_blocks to be
  in units of s_blocksize units instead of 512-byte sectors, use
  l_i_frag and l_i_fsize as i_blocks_hi (could also be part of 64BIT).

E2fsck and debugfs changed to support i_blocks_hi instead of l_i_frag and
l_i_fsize.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-11 06:32:03 -05:00
Theodore Ts'o ae2868acf0 Add failsafe against duplicate UUID's generated by threaded programs
Add in randomness based on Linux's thread id (gettid) to avoid race
conditions when two threads try to generate uuid's at the same time.
This shouldn't be an issue if /dev/urandom has proper locking and is
present, so this is just a failsafe.

Addresses SourceForge Bug: #1529672

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-10-22 00:18:49 -04:00
Theodore Ts'o b6b65c3de4 Add datarootdir definition for compatibility with autoconf 2.60
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-10-22 00:14:26 -04:00
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