Commit Graph

1357 Commits (26c09eb8145a16dcba6c40810d46a78712d253f2)

Author SHA1 Message Date
Theodore Ts'o 214580a339 Merge branch 'maint' into next
Conflicts:
	misc/mke2fs.conf.5.in
2011-02-20 21:54:43 -05:00
Eric Sandeen 6a426c97ec e2fsprogs: enable user namespace xattrs by default
User namespace xattrs are generally useful, and I think extN
is the only filesystem requiring a special mount option to
enable them, when xattrs are otherwise available.  So this
change sets that mount option into the defaults, via a
mke2fs.conf option.

Note that if xattrs are config'd off, this will lead to a
mostly-harmless:

   EXT4-fs (sdc1): (no)user_xattr options not supported

message at mount time...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-02-20 21:36:26 -05:00
Eric Sandeen 3daf592646 e2fsprogs: turn off enforced fsck intervals by default
The forced fsck often comes at unexpected and inopportune moments,
and even enterprise customers are often caught by surprise when
this happens.  Because a filesystem with an error condition will
be marked as requiring fsck anyway, I submit that the time-based
and mount-based checks are not particularly useful, and that
administrators can schedule fscks on their own time, or tune2fs
the enforced intervals if they so choose.  This patch disables the
intervals by default, and I've added a new mkfs.conf option to
turn on the old behavior of random, unexpected, time-consuming
fscks at boot time.  ;)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-02-20 20:45:12 -05:00
Eric Sandeen b6d274f7c6 e2fsprogs: create com_err.h link in includedir
After debian bug #192277, debian/rules started making a symlink
to com_err.h in /usr/include.  Now I have Fedora bug #550889
for the same issue, and perhaps it's time to make this link
by default, rather than fixing it up in packaging steps?

[ Changed by tytso to remove the explicit -s option; this will default
  to creating a hard link by default, which slightly faster.  If
  people want to use symlinks for all links during the install
  process, they can use configure option --enable-symlink-install.
  The reason for this change is that some file systems, like AFS,
  don't support symlinks, and AFS users complain when they can't build
  or install into AFS.  So I don't want to use symlinks
  unconditionally without a way of switching things back and forth,
  and it's easier if we just make all links made during the install
  process to be hard links or sym links. ]

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-02-20 18:10:21 -05:00
Theodore Ts'o da2a5a4bae Merge branch 'maint' into next
Conflicts:
	resize/resize2fs.c
2010-12-22 19:00:21 -05:00
Theodore Ts'o a4fdf09414 libext2fs: Don't use the extended rec_len encoding for standard file systems
If the file system has a blocksize less than 64k, then don't use the
extended rec_len encoding, to be consistent with what the kernel will
do.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-22 13:53:02 -05:00
Namhyung Kim 91dc3f0db0 libext2fs: fix possible memory leak in write_journal_inode()
ext2fs_zero_block2() allocates static buffer if needed so it
should be freed at last (call it again with 0 args).

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-22 10:43:01 -05:00
Theodore Ts'o 58caabc37d ext2fs: fix memory leak in an error case in inode_open()
Reported-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-21 18:05:07 -05:00
Theodore Ts'o 2150278fa2 libext2fs: fix potential free() of garbage in ext2fs_update_bb_inode()
There was a potential of freeing an uninitialized pointer in
rec.block_buf, which was pointed out by Namhyung Kim <namhyung@gmail.com>

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-20 10:58:58 -05:00
Namhyung Kim f57e64a851 libext2fs: fix dubious code in ext2fs_unmark_generic_bitmap()
Looks like a copy & paste problem to me.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-20 10:54:27 -05:00
Namhyung Kim 877d1dc0ab libext2fs: remove unnecessary casts to ext2fs_generic_bitmap
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-20 10:50:33 -05:00
Namhyung Kim 3ece37ea0a libext2fs: fix dubious code in ext2fs_numeric_progress_init()
Looks like a copy & paste problem to me.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-20 10:07:10 -05:00
Namhyung Kim beb4295ca4 libext2fs: fix potential build failure with OMIT_COM_ERR
This fixes following build failure when OMIT_COM_ERR is defined:

 lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_clear_generic_bitmap’:
 lib/ext2fs/gen_bitmap.c:437: error: invalid storage class for function ‘ext2fs_test_clear_generic_bitmap_range’
 lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input
 lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_get_generic_bitmap_end’:
 lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input
 lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_get_generic_bitmap_start’:
 lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input
 lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_unmark_generic_bitmap’:
 lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input
 lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_mark_generic_bitmap’:
 lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input
 lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_test_generic_bitmap’:
 lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input
make[2]: *** [gen_bitmap.o] Error 1
make[2]: Leaving directory e2fsprogs/lib/ext2fs'
make[1]: *** [all-libs-recursive] Error 1
make[1]: Leaving directory e2fsprogs'
make: *** [all] Error 2

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-20 10:07:10 -05:00
Theodore Ts'o 562f264243 Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/block.c
	lib/ext2fs/csum.c
	resize/main.c
2010-12-20 10:06:58 -05:00
Theodore Ts'o 9098c986b6 libext2fs: Fix compile bug on big-endian architectures
Addresses-Sourceforge-Bug: #3138115

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-16 22:11:43 -05:00
Theodore Ts'o 94ded6c16b libext2fs: fix ref_offset callback with sparse files in ext2fs_block_iterate2()
Addresses-Sourceforge-Bug: 3081087

Reported-by: vmo@users.sourceforge.net
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-16 19:34:24 -05:00
Eric Sandeen c816ecb204 e2fsprogs: fix type-punning warnings
Flags used during RHEL/Fedora builds lead to a couple type-punning
warnings:

  recovery.c: In function 'do_one_pass':
  recovery.c:539: warning: dereferencing type-punned pointer will break strict-aliasing rules
  ./csum.c: In function 'print_csum':
  ./csum.c:170: warning: dereferencing type-punned pointer will break strict-aliasing rules

The two changes below fix this up.

Note that the csum test binary output changes slightly, but this does
not break any tests.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-16 17:15:30 -05:00
Lukas Czerner efa1a355a1 e2fsck: Discard free data and inode blocks.
In Pass 5 when we are checking block and inode bitmaps we have great
opportunity to discard free space and unused inodes on the device,
because bitmaps has just been verified as valid. This commit takes
advantage of this opportunity and discards both, all free space and
unused inodes.

I have added new set of options, 'nodiscard' and 'discard'. When the
underlying devices does not support discard, or discard ends with an
error, or when any kind of error occurs on the filesystem, no further
discard attempt will be made and the e2fsck will behave as it would
with nodiscard option provided.

As an addition, when there is any not-yet-zeroed inode table and
discard zeroes data, then inode table is marked as zeroed.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-11-22 21:01:41 -05:00
Lukas Czerner d866599ab4 e2fsprogs: Add CHANNEL_FLAGS_DISCARD_ZEROES flag for io_manager
When the device have discard support and simultaneously discard zeroes
data (and it is properly advertised), then we can take advantage of such
behavior in several e2fsprogs tools.

Add new flag CHANNEL_FLAGS_DISCARD_ZEROES for struct_io_channel so
each io_manager can take advantage of this. The flag is properly set
according to BLKDISCARDZEROES ioctl in unix_open.

Also remove old mke2fs_discard_zeroes_data() function and substitute it
with helper which test this flag.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-11-22 20:41:46 -05:00
Lukas Czerner e90a59ed43 e2fsprogs: Add discard function into struct_io_manager
In order to provide generic "discard" function for all e2fsprogs tools
add a discard function prototype into struct_io_manager. Specific
function for specific io managers can be crated that way.

This commit also creates unix_discard function which uses BLKDISCARD
ioctl to discard data blocks on the block device and bind it into
unit_io_manager structure to be available for all e2fsprogs tools.
Note that BLKDISCARD is still Linux specific ioctl, however other
unix systems may provide similar functionality. So far the
unix_discard() remains linux specific hence is embedded in #ifdef
__linux__ macro.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-11-22 20:41:00 -05:00
Justin Maggard 4fca2b9c07 Fix EXT4_FEATURE_RO_COMPAT_HUGE_FILE check
Creating a 4TB file on a filesystem with the 64bit flag set results in
e2fsck consistently complaining about i_blocks being wrong, with
confusing messages like this:

Inode 29818882, i_blocks is 8388608816, should be 8388608816.  Fix? no

That appears to be caused by ext2fs_inode_i_blocks() checking for the
EXT4_FEATURE_RO_COMPAT_HUGE_FILE in the wrong place.  Fix it.

Signed-off-by: Justin Maggard <jmaggard10@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-11-22 17:32:28 -05:00
Theodore Ts'o 9d92a201de Merge branch 'maint' into next
Conflicts:
	configure
	configure.in
	lib/ext2fs/ext2fs.h
	misc/mke2fs.c
2010-09-24 22:40:21 -04:00
Theodore Ts'o 73fbe2323a libext2fs: Change EXT2_FLAG_DIRECT_IO to avoid conflict with devel branch
The development branch of e2fsprogs already has a code point assigned
in conflict with EXT2_FLAG_DIRECT_IO.  Fix this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-09-24 22:22:09 -04:00
Theodore Ts'o 00f0b14118 ext2fs: Optimize for Direct I/O
Allocate various memory structures to be properly aligned to avoid
needing to use a bounce buffer when doing direct I/O read/writes.
This should also help on FreeBSD systems which require aligned buffers
unconditionally.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-09-24 10:06:45 -04:00
Theodore Ts'o 7f1a1fbf85 ext2fs: Add Direct I/O support to the ext2fs library
This adds the basic support for Direct I/O to unix_io.c, and adds a
new flag EXT_FLAG_DIRECT_IO which can be passed to ext2fs_open() or
ext2fs_open2() to request Direct I/O support.

Note that device mapper devices in Linux don't support Direct I/O, and
in some circumstances using Direct I/O can actually make performance
*worse*!

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-09-24 10:02:25 -04:00
Theodore Ts'o faafdb765b libext2fs: Fix memory leak in the Unix I/O layer when changing block size
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-09-23 16:38:26 -04:00
Theodore Ts'o 023a1df091 ext2fs: add ext2fs_get_memalign() function
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-09-23 16:38:22 -04:00
Theodore Ts'o 9345f02671 tune2fs, debugfs, libext2fs: Add support for ext4 default mount options
Add support for 2.6.35's new default mount options which can be
specified in the superblock.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-09-18 19:38:22 -04:00
Theodore Ts'o ccc7cf0328 libext2fs: fix obvious big-endian bugs introduced by 64-bit changes
These patches fix obvious bone-headed mistakes, so e2fsprogs will now
build and mostly work on powerpc.  The m_meta_bg, u_mke2fs, and
u_tune2fs tests are still failing, however, so there's still work to do...

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-07-30 18:41:47 -04:00
Theodore Ts'o 27a0e958e6 libext2fs: Add ext2fs_file_size_size2() and truncate the file if necessary
This adds a 64-bit interface for ext2fs_file_size_size() and enhances
it to trunate the file if necessary.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-07-30 15:40:53 -04:00
Renzo Davoli 6dc058bd12 libext2fs: Add new function ext2fs_file_get_inode()
This patch adds a very simple function:

	struct ext2_inode *ext2fs_file_get_inode(ext2_file_t file);

which is useful for fuse-ext2 when it needs to read the inode of an
open file.

Signed-off-by: renzo davoli <renzo@cs.unibo.it>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-07-22 09:40:25 -04:00
Theodore Ts'o 3adb9374fb libext2fs: Add new function ext2fs_punch()
This function deallocates a range of blocks from a passed-in file.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-07-22 09:37:35 -04:00
Theodore Ts'o f03bb73ceb libext2fs: Don't make a copy of the inode in ext2fs_extent_open2()
Previously, ext2fs_extent_open2() copied the passed-in inode structure
into the extent handle, and the extent functions modified the copy of
the inode structure if necessary due to extent splits, etc.  Change
ext2fs_extent_open2() so that the extent functions use the inode
structure passed into ext2fs_extent_open2().  Otherwise the passed-in
inode structure could become out of date due to changes made by the
extent functions.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-07-22 09:27:45 -04:00
Theodore Ts'o 47e155df57 libext2fs: Fix ext2fs_iblk_{add,sub}_blocks() when the i_blocks_hi is non-zero
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-07-21 16:10:10 -04:00
Theodore Ts'o 92e2d79cfb tst_extents: Fix 64-bit bugs in do_goto_block()
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-07-20 11:36:34 -04:00
Theodore Ts'o db0bdb49f4 Merge branch 'maint' into next
Conflicts:
	resize/extent.c
2010-07-19 02:37:41 -04:00
Theodore Ts'o c5726f1ad7 Enhance tst_super_size so that it checks the superblock fields as well
The test now checks to make sure the superblock fields are correctly
aligned and prints them out so they can be manually checked to make
sure they are where we expect them to be.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-07-05 14:50:17 -04:00
Theodore Ts'o 993988f655 Add superblock fields which track first and most recent fs errors
Add superblock fields which track where and when the first and most
recent file system errors occured.  These fields are displayed by
dumpe2fs and cleared by e2fsck.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-07-05 14:45:55 -04:00
Theodore Ts'o 8c084167ee Fix Makefile dependencies for test programs in lib/ext2fs
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-24 21:11:01 -04:00
Theodore Ts'o f5448c19ac Add support for Next3 snapshot superblock fields to dumpe2fs and debugfs
We also support for byte-swapping the Next3 fields, although the
current Next3 implementation doesn't support big-endian systems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-24 21:08:37 -04:00
Eric Sandeen efe0b40146 libext2fs: make fs->group_desc opaque
To prevent direct array indexing of fs->group_desc[i] (because the
group_desc may be a different size for different filesystems) make it
an opaque pointer that may only be accessed through the accessor
functions in blknum.c.  The type itself is still available in a public
header; if we have a group_desc that we know is one type or another,
it's ok to access its fields directly.  This change only prevents us
from indexing off fs->group_desc[i] directly.

Old-style applications who don't want to change their source code can
(as a temporary short-term hack) #define EXT2FS_OLD_32_COMPAT before
including ext2fs.h.

Change the accessors in blknum.c to use ext4fs_group_desc(), a version
of ext2fs_group_desc() which returns a ext4_group_desc pointer.

This simplifies and collapses a fair bit of code in blknum.c

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-13 21:00:00 -04:00
Jose R. Santos 02d6f47e96 mke2fs: Fix up mke2fs to be able to make 64-bit file systems
Use 64-bit interfaces in mke2fs.  This should be most most of whats
needed to support creating a 64-bit filesystem. 

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-13 13:00:00 -04:00
Valerie Aurora Henson 6d8b37fa76 libext2fs: More random 64-bit fixes, lots of block_iterate3
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-13 11:00:00 -04:00
Theodore Ts'o ab13b5a979 libext2fs: Create 64-bit dblist functions
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-13 10:00:00 -04:00
Theodore Ts'o da3fc25bce libext2fs: Teach *_initialize and *_allocate_group to be 64-bit safe
This is needed to enable 64-bit mke2fs to work correctly.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-13 09:00:00 -04:00
Theodore Ts'o 97d26ce9e3 Merge branch 'maint' into next
Conflicts:
	e2fsck/journal.c
	e2fsck/pass1.c
	e2fsck/pass2.c
	misc/mke2fs.c
2010-06-07 12:42:40 -04:00
Theodore Ts'o 6d0ed67802 Reserve feature flags and fields needed for the Next3 snapshot feature
The documentation is not (as of this writing) fully complete, but
there is some documentation here:

http://sourceforge.net/apps/mediawiki/next3/index.php?title=Code_documentation
http://sourceforge.net/apps/mediawiki/next3/index.php?title=On-disk_format
http://sourceforge.net/projects/next3/files/Next3_Snapshots.pdf/download

... which will hopefully be updated soon to be fully up to date with
these assignments and more details about how things work.

For now, the assignments should avoid collisions with other new work
that people might want to do on ext3/4.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-02 10:42:16 -04:00
Andreas Dilger 30a7610edf Reserve the EXT4_FEATURE_INCOMPAT_DIRDATA feature flag
Reserve the EXT4_FEATURE_INCOMPAT_DIRDATA feature flag for adding
extra file data in ext2_dir_entry_2 entries.

This changes the on-disk layout in the following way.

Firstly, the ext2_dir_entry_2 file_type field now has a mask: that
limits the "filetype" information to the low 4 bits of this field.
Since these values are sequentially assigned, this allows for up to 7
more filetypes to be assigned.  When reading the "filetype" field, the
high 4 bits should be masked off when converting to DT_* filetypes for
userspace.

The high 4 bits of "filetype" are used as a bitmask to register up to
4 different "extended" directory entry fields.  Extended data fields
are packed without alignment into the directory entry after the "name"
field in order of increasing bitmask value, for each field where bit
is set.  In order to avoid the need to "understand" each of the
extended fields, the first byte of each extended data field holds the
size of that data field (including the size itself), so they can be
skipped if not understood.  For fields that change the semantics of
the filesystem it is expected that a separate ROCOMPAT or INCOMPAT
field is registered.

There is a single dirent data type defined currently, for Lustre:
which holds a 128-bit file identifier.  It is expected that if there
are 64-bit inode values that this will be assigned the 0x20 value.

Should a need ever arise to use all 4 of the extended dirent data
fields, it would be possible to keep the last bit (0x80) for use as a
multiplexor that stores a 1-byte aggregate data size, then a series of
"<u8_size><u8_type><data>" records in the last extended data record.
It is not expected that this will actually be needed in the lifetime
of ext4.

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-02 10:41:54 -04:00
Andreas Dilger cff9690f4e Reserve the EXT4_INCOMPAT_EA_INODE feature flag
Reserve the EXT4_INCOMPAT_EA_INODE feature flag for use with
large extended attributes that are stored in a separate inode.
This changes the on-disk format in several ways:

First, replace the e_value_block field with e_value_inum, so that
an xattr entry can reference an external inode.  This field is
currently unused, as all of the entries live in the same block.

struct ext2_ext_attr_entry {
 	__u8	e_name_len;	/* length of name */
 	__u8	e_name_index;	/* attribute name index */
 	__le16	e_value_offs;	/* offset in disk block of value */
>	__le32	e_value_inum;	/* inode in which the value is stored */
 	__le32	e_value_size;	/* size of attribute value */
 	__le32	e_hash;		/* hash value of name and value */
 	char	e_name[0];	/* attribute name */
}

Second, add a flag to the inode that indicates it is using a large
(external) extended attribute.  This is needed so that when unlinking
an inode the xattrs will be scanned to unlink the xattr inodes
referenced by the main inode.

Third, for inodes that have a number of xattrs that are larger than
a single block, but not large enough to justify an external inode
(less than 64kB total xattr size, due to e_value_offs limitation)
the ext2_ext_attr_header->h_blocks field can grow beyond a single
block to represent a contiguous allocation of blocks for the xattr.

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-02 10:41:37 -04:00
Theodore Ts'o effb344241 libext2fs: Remove #include of <linux/types.h> from fiemap.h
The system header file can end up causing type conflicts, and
including kernel header files is always dodgy/dangerous (and this case
not needed).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-05-31 18:50:50 -04:00
Theodore Ts'o bb1158b92e mke2fs: account for physical as well as logical sector size
Some devices, notably 4k sector drives, may have a 512 logical
sector size, mapped onto a 4k physical sector size.

When mke2fs is ratcheting down the blocksize for small filesystems,
or when a blocksize is specified on the commandline, we should not
willingly go below the physical sector size of the device.

When a blocksize is specified, we -must- not go below
the logical sector size of the device.

Add a new library function, ext2fs_get_device_phys_sectsize()
to get the physical sector size if possible, and adjust the
logic in mke2fs to enforce the above rules.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-05-17 23:04:40 -04:00
Theodore Ts'o 543547a52a libe2p, libext2fs: Update file copyright permission states to match COPYING
The top-level COPYING file states that the e2p and ext2fs libraries
are available under the LGPLv2.  The files were incorrectly labelled.
Alex Thomas/Luster has been consulted wrt to the ext3_extents.h file;
the rest of the files were primarily authored by Theodore Ts'o.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-05-17 23:04:39 -04:00
Theodore Ts'o 4d452afe47 Always build namei.o so that building with "configure --disable-debugfs" works
namei.o is also needed by e2initrd_helper.

Long term, if we care about reduced e2fsprogs builds, we need a more
general solution for deciding what .o files are needed for a
particular build.  Given that install floppies are going (gone?) the
way the dodo bird, we probably don't care, though.

Addresses-Sourceforge-Bug: #2911433

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-05-17 19:32:19 -04:00
Theodore Ts'o 5aa6c3f61c Add configure options --enable-symlink-build and --enable-symlink-install
These options allow e2fsprogs to be built using symlinks instead of
hard links, and to be installed using symlinks instead of hard links,
respectively.

Addresses-Sourceforge-Bug: #1436294

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-05-17 19:21:42 -04:00
Theodore Ts'o 822c10e84e libcom_err: Only output ^M when tty is in raw mode
This fixes a long-standing botch in the com_err library, and solves a
regression test problem for libss that gets tickled by source code
management systems (like Perforce) that don't preserve CRLF line
endings with fidelity.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-05-15 07:48:25 -04:00
Theodore Ts'o c5b23f6c0e Merge branch 'maint' into next 2010-03-15 18:53:45 -04:00
Theodore Ts'o 1601b10e65 libcom_err: Add support for Heimdal com_right_r function()
Addresses-Sourceforge-Bug: #2963865
Addresses-Debian-Bug: #558910

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-03-15 00:14:12 -04:00
Theodore Ts'o 8e2399d57a ext2fs: Optimize extending an extent-mapped file using ext2fs_block_iterate2()
When ext2fs_block_iterate2() is called on an extent-mapped file with a
depth > 1, it will erroneously calling the callback function starting
all over again with an offset of logical block 0.  It shouldn't do
this, and it cases mke2fs to become very slow when creating files with
very large journals.

Fix this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-03-11 15:58:54 -05:00
Eric Sandeen 4ffafee26c e2fsck: don't complain about i_size for known blocks past EOF
This is the userspace side of Jiaying's EOFBLOCKS patch.  With
Aneesh's patches for .33, Jiaying's patch, and this one, xfstests
013/fsstress (even with direct IO enabled) has held up through many
runs.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-02-24 11:24:37 -05:00
Theodore Ts'o 1d18a55c52 libext2fs: Fix byte swapping bugs
The 64-bit patches broke compiles on big endian systems.  In addition
the block group checksum test was failing, due to bugs in both the
test case and the checksum code itself.  This commit addresses these
problems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-02-15 09:51:28 -05:00
Theodore Ts'o cc84d866e2 Merge branch 'maint' into next
Conflicts:
	e2fsck/pass1.c
2010-02-10 18:20:58 -05:00
Eric Sandeen 4e79a19fe0 libss: add newer libreadline to dlopen path
Rawhide now has libreadline.so.6 ... add it to the ever-expanding
list of libs to look for.

Unfortunately without commit 06ef971be5
this fails in a rather cryptic way.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-02-05 22:50:10 -05:00
Theodore Ts'o 2d07b3ad98 Merge branch 'maint' into next
Conflicts:
	configure
	lib/ext2fs/alloc_tables.c
	misc/mke2fs.c
2010-01-31 18:49:08 -05:00
Theodore Ts'o c21cde9986 libext2fs: Add some fail-safe checks to the 32-bit bitmap code
If a 64-bit bitmap is passed to a 32-bit bitmap function, add some
checks to make sure that we print a useful error message so we can
better catch potential problems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-01-30 20:20:21 -05:00
Theodore Ts'o bbb60e4fef libext2fs: Improve flex_bg inode table placement algorithm
When trying to find the best place for the inode table in the last
flex block group, use the true size for the flex_bg's portion of the
inode table instead of the worst case required size of the inode table
fragment if the file system is resized.  This fixes a corner case
where if the size of the filesystem is just big enough that there is
only room for a single block group in the last flex_bg, and that
partial block group is too small for the full portion of the inode
table, the inode table is placed in the very first block group:

Group 64: (Blocks 2097152-2099199) [INODE_UNINIT, ITABLE_ZEROED]
  Checksum 0xd305, unused inodes 8080
  Block bitmap at 2097152 (+0), Inode bitmap at 2097168 (+16)
  Inode table at 8626-9130 (+4292878770)
                 ^^^^^^^^^

Thanks to Vyacheslav Dubeyko for pointing this out.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-11-30 12:24:59 -05:00
Theodore Ts'o 4534f8bc3f debian: Fix FTBFS problem caused by texi2html changing its output location
Unfortunately, texi2html gratuitously changed its behavior of where
its output html files are placed when the -split_chapter is in effect.
(First it was in a subdirectory; then it was in the current directory;
now it's back to putting the output html files in a subdirectory
again.)

Support either way of doing things since the texi2html team seems to
be indecisive...

Addresses-Debian-Bug: #552934

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-11-29 20:19:10 -05:00
Theodore Ts'o 9c9e1d5fe5 libext2fs: Fix SET_BMAP bugs in ext2fs_bmap() and ext2fs_bmap2()
Don't byte-swap the block number when setting i_block[x], since the
write_inode function will take of byte swapping the inode.

The phys_blk parameter contains an input parameter in the SET_BMAP
case, so it must be passed to ext2fs_bmap2() from the legacy function
ext2fs_bmap().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-11-29 01:03:04 -05:00
Theodore Ts'o 4486af5b4c Merge branch 'maint' into next
Conflicts:
	misc/mke2fs.c
2009-11-16 00:30:57 -05:00
Karel Zak 5f91561ae7 libext2fs: handle <=linux-2.6.19 bug in /proc/swaps
Linux <= 2.6.19 contained a bug in the /proc/swaps code where the
header would not be displayed (the first line).

This issue has been reported by Mike Frysinger for swapon(8).

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-11-13 08:48:29 -05:00
Eric Sandeen 6eb229dc5d libext2fs: don't swap extent-based journal backup
The f_illitable_flexbg test was failing on ppc, because
e2fsck_move_ext3_journal is doing a direct memcmp of i_block with
s_jnl_blocks, and failing.

This is because we don't swap extent data on read from disk; rather
we do it when we access the extents.  However, ext2fs_swap_super
was swapping s_jnl_blocks unconditionally, so these didn't match.

Looks like we need to treat s_jnl_blocks the same as i_block, and
swap it on access, not on read.  Except for the last i_size bit...

Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-11-12 19:55:53 -05:00
Theodore Ts'o 06ef971be5 libss: initialize function pointer for readline_shutdown()
Clear the function pointer for readline_shutdown() so that if libss is
linking against a readline library which doesn't supply a
readline_shutdown() function, ss_delete_invocation() won't seg fault.

Thanks to Solar Designer <solar@openwall.com> for reporting this
problem to me.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-11-12 17:54:45 -05:00
Valerie Aurora Henson 054e5a9ccf Add 64bit option to known incompatible file system options
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25 22:16:19 -04:00
Theodore Ts'o b49f78fe6e Convert ext2fs_group_{first,last}_block() to *block2()
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25 21:24:06 -04:00
Theodore Ts'o 6493f8e85d Convert ext2fs_group_of_blk() to ext2fs_group_of_blk2()
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25 20:50:15 -04:00
Valerie Aurora Henson 48f23054bb Convert ext2fs_block_alloc_stats() calls to block_alloc_stats2()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25 21:46:58 -04:00
Theodore Ts'o cf828f1a72 libext2fs: Byte-swap 64-bit block group descriptors
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25 21:46:01 -04:00
Valerie Aurora Henson d7cca6b06f Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25 21:43:47 -04:00
Theodore Ts'o cd65a24e75 libext2fs: Convert ext2fs_bg_flag_test() to ext2fs_bg_flags_test()
After cleaning up ext2fs_bg_flag_set() and ext2fs_bg_flag_clear(),
we're left with ext2fs_bg_flag_test().  Convert it to
ext2fs_bg_flags_test().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25 21:42:12 -04:00
Eric Sandeen e633b58ac7 libext2fs: clean up ext2fs_bg_flags_ interfaces
The ext2fs_bg_flag* functions were confusing.

Currently we have this:

void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags);
void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group,__u16 bg_flags);

(_set (unused) sets exactly bg_flags; _clear clears all and ignores bg_flags)

and these, which can twiddle individual bits in bg_flags:

void ext2fs_bg_flag_set(ext2_filsys fs, dgrp_t group, __u16 bg_flag);
void ext2fs_bg_flag_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flag);

A better interface, after the patch below, is just:

ext2fs_bg_flags_zap(fs, group) /* zeros bg_flags */
ext2fs_bg_flags_set(fs, group, flags) /* adds flags to bg_flags */
ext2fs_bg_flags_clear(fs, group, flags) /* clears flags in bg_flags */

and remove the original ext2fs_bg_flags_set / ext2fs_bg_flags_clear.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25 21:41:32 -04:00
Theodore Ts'o 72a729dbf9 Merge branch 'maint' into next
Conflicts:
	configure
	configure.in
2009-10-24 15:14:54 -04:00
Theodore Ts'o 5d10807070 libext2fs: Fix FEATURE_RO_COMPAT_HUGE_FILE && !HUGE_FILE_FL
If the RO compat HUGE_FILE feature flag is set, but the inode's
HUGE_FILE_FL flag is not set, we should still pay attention to the
high 32 bits of the i_blocks filed.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-21 01:46:58 -04:00
Theodore Ts'o 95bcea9fc1 Merge branch 'maint' into next
Conflicts:
	configure
	configure.in
	misc/mke2fs.c
2009-10-04 20:40:46 -04:00
Theodore Ts'o f790bc33b2 libext2fs: Always build file_io.c
Commit 1d9b818: dumpe2fs: Print more information about the inline journal
caused dumpe2fs to use ext2fs_file_open2().  Previously the file_io
functions were only used by debugfs, so if debugfs was disabled,
file_io was not built.  Now that dumpe2fs is also using file_io, we
need to build it unconditionally.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-04 16:29:17 -04:00
Theodore Ts'o e1f0850795 Don't use in-tree header files if using system uuid or blkid libraries
This commit forces the use of the system-provided blkid or uuid header
files if we are using the system-provided blkid or uuid libraries.
This avoids using the in-tree header files with the system libraries.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-04 14:45:08 -04:00
Theodore Ts'o 7822f784f1 blkid: Avoid a potentially error message when running "make clean"
This error isn't terribly important, but apparently it causes some
users/developers distress.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-03 22:33:47 -04:00
Theodore Ts'o 04f13d6685 libext2fs: Add error table initialization to test programs
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-08 21:33:03 -04:00
Valerie Aurora Henson 4efbac6fed Convert uses of super->s_*_blocks_count to ext2fs_*_blocks_count()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 20:46:34 -04:00
Valerie Aurora Henson a63745e81c Use ext2fs_file_acl_block() instead of using .i_file_acl directly
This provides support for 48-bit file acl blocks.

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 22:29:45 -04:00
Valerie Aurora Henson c5b7b6babe Fix overflow in calculation of total file system blocks
Blocks per group and group desc count are both 32-bit; multiplied they
produce a 32-bit quantity which overflowed.

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 21:23:03 -04:00
Theodore Ts'o 51e6459491 libext2fs: Round up the bitmap size when allocating a new bitmap
The x86 BT assembly instructure can overshoot the end of a bit array
when testing a bit at the end of the bit array, even if it never needs
to look at those memory locations.  This can cause a spurious
segmentation fault.  If we allocate a little extra memory, it avoids
this problem.  See:

	http://faydoc.tripod.com/cpu/bt.htm

This doesn't happen on Linux, probably because of the glibc's malloc()
function works, but apparently it's a major problem on the *BSD
operating systems.

Addresses-Sourceforge-Bug: #2328708

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 16:21:49 -04:00
Karel Zak 249c962ad8 blkid: support .ko.gz in modules.dep parser
The Linux kernel modules could be compressed, it means modules.dep
parser in libblid has to support .ko.gz extension too.

(Note, I've talked about this problem with Jon Masters and his
suggestion is to exec(/sbin/modinfo) rather than directly parse
modules.dep. BTW, the modules.dep file is deprecated.)

Address-Red-Hat-Bug: #518572
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-08-27 20:58:54 -04:00
Theodore Ts'o 8bafedbf4a tune2fs: Fix "tune2fs -j <dev>" for extent-enabled filesystems
For filesystms that have the extent feature enabled, we need to grab
the use EXT2_IOC_GETFLAGS so that we don't accidentally end up trying
to request clearing the EXT2_EXTENT_FL, which is not supported and
causes the tune2fs -j error out.

Also fix the error returning in ext2fs_add_journal_inode() so it
returns a proper error code if the fstat() or ioctl() calls fail.

Addresses-Launchpad-bug: #416648

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-25 10:07:16 -04:00
Valerie Aurora Henson 95fd65bb7f libext2fs: create generic numeric progress meters and use them
With 64-bit file systems, mke2fs can take a long time to do things
other than write inode tables.  I exported the mke2fs numeric progress
meter and used it for allocating group tables and the final file
system flush.

Signed-off-by: Valerie Aurora (Henson) <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-23 19:20:03 -04:00
Theodore Ts'o 732c8cd58f Use accessor functions fields for bg_flags in the block group descriptors
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 21:15:12 -04:00
Valerie Aurora Henson 24a117abd0 Convert to use io_channel_read_blk64() and io_channel_write_blk64()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 21:14:24 -04:00
Nick Dokos d62d218f11 libext2fs: Fix counting routines in blknum.c to take/return __u32 counts
Several routines in lib/ext2fs/blknum.c:

        ext2fs_bg_free_blocks_count()
        ext2fs_bg_free_inodes_count()
        ext2fs_bg_used_dirs_count()
        ext2fs_bg_itable_unused()

and their _set() counterparts, operate as if they are dealing with
blk64_t quantities, but they should be dealing with __u32 counts
instead.

Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-09-07 21:13:59 -04:00
Theodore Ts'o dc615a21c3 Merge branch 'maint' into next 2009-09-07 17:02:35 -04:00
Theodore Ts'o f4240c8d56 libext2fs: Treat uninitialized parts of bitmaps as unallocated
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-09 23:22:32 -04:00
Valerie Aurora Henson 8f82ef9860 Convert libext2fs to 64-bit bitmap interface
(Includes fixes from Nick Dokos)

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-05 00:27:10 -04:00
Theodore Ts'o 69365c689b Add support for 64-bit bitmaps
Initial design was done by Theodore Ts'o; implementation was fleshed
out by Valerie Aurora Henson.  Also includes some fixes from Nick Dokos.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
2009-08-22 13:27:40 -04:00
Theodore Ts'o 1d72214658 Merge branch 'maint' into next 2009-08-22 13:18:29 -04:00
Theodore Ts'o 88fca201ac Move declaration of FS_IOC_FIEMAP ioctl to fiemap.h
This helps e4defrag compile on systems where the system header files
don't yet define FS_IOC_FIEMAP.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-22 13:16:14 -04:00
Theodore Ts'o baa8dbeb4e Merge branch 'maint' into next
Conflicts:
	misc/Makefile.in
2009-08-01 20:43:00 -04:00
Theodore Ts'o 1451c20109 libext2fs: Use blk_t instead of int in ext2fs_allocate_group_table
We are using a signed int to store a block number in
ext2fs_allocate_group_table.  We don't actually do any computation or
comparisons using it, so it shouldn't cause any bugs, but it's
technically incorrect, and it's possible an overly clever compiler
might do something wrong with it.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-22 02:38:16 -04:00
Theodore Ts'o 8b5ed492de libext2fs: Avoid creating unneeded new extents in ext2fs_extent_set_bmap()
Avoiding inserting a new extent if it is possible to merge the new
block to the beginning or the end of the previous or next extent.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-19 23:37:44 -04:00
Theodore Ts'o 64cb68b3ea libext2fs: Improve debugging printf's in extent.c
Comment out less common debugging printf's, and fix some type
warnings.  Add high-level debugging printf's for ext2fs_extent_goto(),
ext2fs_extent_insert(), ext2fs_extent_delete(), ext2fs_extent_replace()

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-19 23:32:09 -04:00
Theodore Ts'o 16e470e650 libext2fs: Fix regression in ext2fs_extent_set_bmap()
Commit 0dc291611 introduced a regression when unmapping the first
block in an extent.  This caused e2fsck -fD to corrupt large
directories if the directory has to shrink by more than one block.
The problem was set_bmap should only go to a next leaf when setting a
first block in an extent, and not when it is unmapping the first block
in an extent.

Addresses-Debian-Bug: #537510

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-19 22:43:33 -04:00
Theodore Ts'o 9922c53a4d libext2fs: fix memory leak in error path in ext2fs_block_iterate2()
Reported-by: Nic Case <number9652@yahoo.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-18 10:02:41 -04:00
Theodore Ts'o 25c7e0c304 libext2fs: Fix minor gcc -Wall warnings
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-12 01:13:06 -04:00
Theodore Ts'o cf268fd484 Remove tst_csum.c from lib/ext2fs/Makefile.in's SRCS list
The tst_csum test is now part of csum.c, so there isn't a separate
tst_csum.c file that should be listed as one of the source files in
lib/ext2fs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-11 17:41:07 -04:00
Theodore Ts'o 0dc2916112 libext2fs: Make ext2fs_extent_set_bmap() more robust against ENOSPC
In the case where we ext2fs_extent_set_bmap() is replacing the block
mapping at the beginning of an already-existing extent, insert a new
extent if necessary before shrinking an existing extent, to avoid data
loss if the disk is full.

This mostly addresses the problem described in Red Hat Bugzilla's
statistics are still wrong, but at least the files on the filesystem
are not corrupted.  If there is a failure during the
inode_scan_and_fix pass, the simplest thing to do may be to tell the
user to run e2fsck -fy.

Addresses-Red-Hat-Bug: #510379

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-10 19:51:43 -04:00
Theodore Ts'o ef1a526dfb libext2fs: Add new function ext2fs_test_inode_bitmap_range()
Optimize ext2fs_test_block_bitmap_range() and add a new function,
ext2fs_test_inode_bitmap_range(), which works the same way as
ext2fs_block_bitmap_range() but for inode bitmaps.  It's needed for
some code in the development branch, so let's drop it into the maint
branch to make life easier in the future.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-09 14:32:52 -04:00
Eric Sandeen 4bd87f2290 libext2fs: reset handle after inserting new extent
Commit 53422e moved the new extent insertion in
ext2fs_extent_set_bmap() prior to the modification of the original
extent, but the insert function left the handle pointing to the new
extent.  This left us modifying the -new- extent, instead of the
original one, and winding up with a corrupt extent tree something
like:

BLOCKS:
(0-1):588791-588792, (0):588791

We need to move back to the previous extent prior
to modification, if we inserted a new one.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-07-07 23:24:09 -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 3381a63c54 libuuid: Don't run uuidd if it would fail due to permission problems
Some distributions don't like installing uuidd setuid or setgid.  So
if the setuid or setigid bit is not set with uuidd, and the current
process does not have write access to the UUIDD work directory, don't
try running uuidd, since it won't work properly.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-30 22:36:28 -04:00
Theodore Ts'o caa6003b64 libuuid, uuidd: Avoid infinite loop while reading from the socket fd
If for some reason the uuidd daemon or the process calling uuidd
exited unexpectely, the read_all() function would end up looping
forever, either in uuidd or in libuuid.  Fix this terminating the loop
if no data can be read after five tries to read from the file
descriptor.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-29 20:03:20 -04:00
Theodore Ts'o e8b9466fc9 libuuid: Make sure fd's 0, 1, and 2 are valid before exec'ing uuidd
When closing all of the file descriptors before starting uuidd, make
sure file descriptors 0, 1, and 2 are reserved by opening /dev/null.
This prevents strange bugs caused by assumptions regarding file
descriptors <= 2 as being special.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-29 19:06:45 -04:00
Nic Case 6a8da46d28 libext2fs: ensure validate_entry doesn't read beyond blocksize
ext2fs_validate_entry would read beyond the end of the block to get
dirent->rec_len for certain arguments (like if blocksize ==
final_offset).  This patch adds a check so that doesn't happen, and
changes the types of the arguments to avoid a compiler warning.

Signed-off-by: Nic Case <number9652@yahoo.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-29 01:24:40 -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
Eric Sandeen 827c188711 libext2fs: initialize large inodes for journal & resize
I noticed that neither the journal nor resize inodes have
i_extra_isize set post-mkfs; while this isn't likely
to be a big problem, I think the below patch tidies
it up.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-06-17 19:49:00 -04:00
Eric Sandeen 125a367806 libext2fs: write only core inode in update_path()
The ext2_extent_handle only has a struct ext2_inode allocated on
it, and the same amount copied into it in that same function,
but in update_path() we're possibly writing out more than that -
for example 256 bytes, from that address.  This causes uninitialized
memory to get  written to disk, overwriting the parts of the
inode past the osd2 member (the end of the smaller structure).

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-17 18:49:01 -04:00
Theodore Ts'o 7b59b4a8ee libext2fs: Fix memory leak in the extents handling function
Each time an extent handle is opened and closed, if the inode has an
extent tree which does not fit in the inode's i_block structure, a
filesystem block buffer was not getting released.  Since e2fsck opens
an extent handle for every inode using extents, this can translate to
a very large amount of memory getting lost.

Thanks to Henrik 'Mauritz' Johnson for discovering and pointing out
this leak, which he ran into while running the "rdump" command in
debugfs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-15 01:34:43 -04:00
Theodore Ts'o 272631e4ba libext2fs: Add ext2fs_block_iterate3()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01 16:15:40 -04:00
Valerie Aurora Henson 8717c3a8f3 libext2fs: Add 64-bit bitops
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01 16:15:40 -04:00
Valerie Aurora Henson b4e0163d53 libe2p: Add new function parse_num_blocks2()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-21 19:34:42 -04:00
Theodore Ts'o 0180a05e74 e2p: Print 64-bit block numbers in the superblock
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01 16:15:40 -04:00
Theodore Ts'o 5635e75c91 Merge branch 'maint' into next 2009-07-21 17:07:33 -04:00
Theodore Ts'o 6a0ee32dcb Merge branch 'maint' into next 2009-07-12 01:14:39 -04:00
Jose R. Santos 73d0c4cce5 Add 64-bit mkjournal.c interface
Added 64-bit mkjournal.c interface.  Needed to zero inode tables.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01 16:15:40 -04:00
Jose R. Santos 743011fbac Add ext2fs_div64_ceil()
Add a new div_cell routine able to handle 64bit values

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01 16:15:40 -04:00
Jose R. Santos 4f8d6ab222 Add 64-bit openfs interface
Add new ext2fs_descriptor_block_loc2() routine that takes blk64_t as
an input.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01 16:15:40 -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
Jose R. Santos 71300f35de Add 64-bit closefs interface
Add new ext2fs_super_and_bgd_loc2() that returns blk64_t pointers.
The function now returns the number of blocks used by super block and
group descriptors since with flex_bg, it can no longer be assumed that
bitmaps and inode tables still resided within the block group.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01 16:15:40 -04:00
Jose R. Santos b91f14b870 Add 64-bit ext_attr interface
Add ext2fs_read_ext_attr2(), ext2fs_write_ext_attr2() and
ext2fs_adjust_ea_refcount2() that take blk64_t as an input.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01 16:15:40 -04:00
Jose R. Santos 8a5e1812ae Add 64-bit alloc interface
Add new ext2fs_new_block2(), ext2fs_get_free_blocks2() and
ext2fs_alloc_block2() that take and return blk64_t.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01 16:15:40 -04:00
Jose R. Santos e8328e31a9 Add 64-bit alloc_stats interface
Add new ext2fs_block_alloc_stats2() routine that takes blk64_t as an
input.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01 16:15:40 -04:00
Jose R. Santos 57e2467d62 Add 64-bit dirblock interface
Add new ext2fs_(read|write)_dir_block3() routines that take blk64_t as
an input.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01 16:15:40 -04:00
Jose R. Santos 319158f9bd Use blk64_t for blocks in struct ext2_file
The ext2_file structure is never exposed through the libext2fs API so
it is safe to use 64-bit blocks for blockno and physclock without
breaking the ABI.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01 16:15:40 -04:00
Jose R. Santos e3854b3b7c Add new blk64_t handling functions
Add new blknum.c file which contains funtions to handle blk64_t and
low/high values in super blocks and inodes.

(Includes fixes from Nick Dokos, and additions from Valerie Aurora Henson)

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-06 15:22:43 -04:00
Jose R. Santos f6b4c27562 libext2fs: Add ext2_off64_t type
The ext2_off_t type is u32.  Create a new 64-bit ext2_off64_t for
64bit offsets.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01 16:15:40 -04:00
Theodore Ts'o 1adc384bc5 libext2fs: Add 64-bit support to the undo manager
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-12 00:53:57 -04:00
Valerie Aurora Henson 3c4d4d7459 libext2fs: Define bg_itable_unused_hi in the ext4_group_desc structure
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-06 15:08:44 -04:00
Theodore Ts'o 337079375e Update lib/xt2fs/Makefile.in using "make depend" 2009-05-30 13:46:19 -04:00
Theodore Ts'o 470e737a87 libext2fs: Move test code for csum.c inline instead of in a separate file
Move the test code which is used to build the tst_csum progam from
tst_csum into csum.c under an #ifdef DEBUG to simplify things and to
avoid compile problems caused by not having a prototype for
ext2fs_group_desc_csum().

Addresses-Sourceforge-Bug: #2484331

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-29 11:01:22 -04:00
Theodore Ts'o 86522281f8 libext2fs: Add an explicit error code for missing mtab file
To reduce user confusion, if the /etc/mtab file is missing
ext2fs_check_mount_point and ext2fs_check_if_mounted will return a
new, explicit error code to indicate this case.

Addresses-Debian-Bug: #527859

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-29 00:11:52 -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
Eric Sandeen 312c2a404c chattr: manpage tidyups
Tidy up the chattr(1) manpage to completely document all
available options, and differentiate those which are read-only
early in the manpage as well.

* Remove "I" from settable attribute list
* add "e" to 2nd list of settable attributes & descriptions
* Note that h/E/I/X/Z are readonly
* Correct "H" to "h" for huge file attribute description
* fix long_name for indexed directory in flags_array

Addresses-Red-Hat-Bugzilla: BZ#502971

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-28 08:33:09 -04:00
Eric Sandeen 53422e8a56 resize2fs: fix ENOSPC corruption case
http://people.redhat.com/esandeen/livecd-creator-imagefile.bz2
contains an image (for now) which, when resized to 578639, corrupts
the filesystem.

This is a bit crazy, I guess, because the fs currently has only
1 free block, but still, we should be graceful about the failure.
Perhaps it would make sense to check the requested valuea against
the minimum value resize2fs would compute for "-P" and fail (at
least without a force).

But in any case, this exposed 2 bugs when moving that one block
required an extent split, which is what hit the ENOSPC.

For starters, ext2fs_extent_set_bmap() in the "(re/un)mapping last
block in extent" case was replacing the old extent before the
new one was created; when the new extent creation failed, it
left us in an inconsistent state.  Simply changing the order of
the two should fix this problem.

Next, ext2fs_extent_insert was calling ext2fs_extent_delete()
on *any* error, including one caused by failure to allocate a new
block to split the node to hold that extent ... the handle was left
unchanged, and we deleted the -original- extent.

As a quick fix for this, just don't do the delete if we fail the split,
though this may need to be smarter.  I don't think we have terribly
consistent behavior about where a handle is left on various errors.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-25 22:37:59 -04:00
Theodore Ts'o 5dd3311eeb blkid: Don't use a hard-coded path for /bin/rm in test_probe.in
Addresses-Sourceforge-Bug: #2780205

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-17 22:19:21 -04:00
Theodore Ts'o 5fdb89e30e Add missing file: lib/ext2fs/fiemap.h
This file is needed so the updated filefrag program will compile.  I
missed a "git add"; oops.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-04 07:39:56 -04:00
Karel Zak 46f3eeca59 blkid: use /sys/block/dm-<N>/dm/name
The Linux kernel (since 2.6.29, patch 784aae735d9b0bba3f8b9faef4c8b30df3bf0128)
exports the real DM device names in /sys/block/<ptname>/dm/name.

The sysfs based solution is nicer and faster than scan for devno in
/dev/mapper/.

CC: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-02 22:39:20 -04:00
Karel Zak 4271e23942 blkid: use /dev/mapper/<name> rather than /dev/dm-<N>
The libblkid (since v1.41.1) returns private device-mapper names (e.g.
/dev/dm-0). It's because the probe_one() function scans /dev before
/dev/mapper.

brw-rw---- 1 root disk 253, 0 2009-04-27 13:41 /dev/dm-0
brw-rw---- 1 root disk 253, 0 2009-04-27 13:41 /dev/mapper/TestVolGroup-TestLogVolume

Old version:
  # blkid -t LABEL="TEST-LABEL" -o device
  /dev/dm-0

Fixed version:
  # blkid -t LABEL="TEST-LABEL" -o device
  /dev/mapper/TestVolGroup-TestLogVolume

Addresses-Red-Hat-Bug: #497259
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-02 22:33:13 -04:00
Theodore Ts'o 6d67ee305c Avoid unneeded updates of block group descriptors in ext2fs_closefs()
If the superblock is clean, and we only need to update
s_kbytes_written, then we only need to update the superblock.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-02 20:59:04 -04:00
Theodore Ts'o 41aeae11a6 Update lib/ext2fs/Makefile.in using "make depend"
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-23 22:24:51 -04:00
Theodore Ts'o 8203fe506a libext2fs: read the block group descriptors more efficiently
When opening a filesystem, make ext2fs_open2() much more efficient by
reading the normal block group descriptors all at once, instead of one
block at a time.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-23 01:30:42 -04:00
Eric Sandeen 4e60e06847 blkid: remove whole-disk entries from cache when partitions are found
We can get into a situation in blkid where whole disks remain
in the cache, even though partitions are found.  For labels
such as sun disklabels which may have the first partition
beginning at sector 0, this is even somewhat likely.

1) create a sun disklabel w/partitions
2) mkfs the first partition (at sector 0)
3) remove the partition table
4) run blkid - this finds the fs on the whole disk, places in cache
5) recreate the partition table
6) run blkid - this finds the partition, places in cache

And now we have both /dev/sda and /dev/sda1 in cache.

There are heuristics in probe_all to avoid putting the whole disk
in cache if it has partitions, but there is nothing to remove the
whole-disk entry in the above case.  I think the below patch
suffices, although I haven't quite convinced myself that setting
the lens[which]=0; is the right logic for that bit of state...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 22:52:40 -04:00
Theodore Ts'o f9110f4480 libext2fs: Skip relative pathnames in /etc/mtab in ismounted.c
The functions which test to see if a device is mounted can get
confused by entries in /etc/mtab for virtual filesystems:

rootfs / rootfs rw 0 0
none /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0

If the device name doesn't start with a slash, ignore the /etc/mtab
entry, so that relative pathnames passed into functions such as
ext2fs_check_mount_point() or ext2fs_check_if_mounted() don't return
false positives.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 22:20:22 -04:00
Theodore Ts'o 46d6f84ebe libext2fs: Fix format string type warnings in alloc_stats.c
Fix gcc warnings caused by wrong types passed com_err() in
ext2fs_inode_alloc_stats2 and in ext2fs_block_alloc_stats().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 15:07:00 -04:00
Theodore Ts'o 935a123f3b libss: Fix warn_unused_result warnings from gcc
Fixed a potential bug where by partial returns from the write system
call could the fallback pager to drop characters.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 14:48:59 -04:00
Theodore Ts'o 9ea68828f3 libss: ss_execute_line: reflect any error codes from system() to the caller
This is primarily to silence a gcc warning, but it's better to reflect
the error from system() up to the caller.  In this case we don't
actually use it for anything, but that's OK.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 14:46:48 -04:00
Theodore Ts'o d3395ae71a libcom_err: Declare prototypes for et_list_lock/unlock in com_err.h
Define the prototypes for et_list_lock() and et_list_unlock() in
com_err.h.  This promotes better error checking and avoids warnings
when compiling the library and programs that call these functions.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 14:41:32 -04:00
Theodore Ts'o 022c925c5a libe2p: Declare prototypes for the journal feature name functions in e2p.h
Define the prototypes for e2p_jrnl_feature2string() and
e2p_jrnl_string2feature() in e2p.h.  This promotes better error
checking and avoids warnings when compiling the library and programs
that call these functions.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 14:41:12 -04:00
Theodore Ts'o 1207e36d0a libuuid: Close all file descriptors before running uuidd
This avoids problems when the calling program has open file
descriptors (especially sockets) open.

Also fix up some warn_unused_result warnings from gcc.

Addresses-Launchpad-bug: #305057

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-15 13:12:56 -04:00
Theodore Ts'o 341b52dfa8 libext2fs: external journal devices should not cause ext2fs_open2 to fail
This fixes a regression introduced in commit 79a9ab14 which caused
attempts to open external journals to fail due to overly strict
filesystem consistency checks.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-03-16 22:16:44 -04:00
Jim Meyering 671326f625 libss: Avoid leak upon failed realloc in ss_add_request_table()
Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-03-08 20:38:47 -04:00
Jim Meyering 4e711be8d0 libext2fs: don't leak strdup'd dev name in dosio.c upon error
Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-03-08 20:38:20 -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
Theodore Ts'o 1361821e7e blkid: Add fallback to ext4 for 2.6.29+ kernels if ext2 is not present
Starting in 2.6.29, ext4 can be used to support filesystems without a
journal.  So if ext2 is not present, and the kernel version is greater
than 2.6.29, and ext4 is present, return a filesystme type of ext4.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-03-08 18:56:41 -04:00
Eric Sandeen a90f5391dd blkid: recognize ext4(dev) without journal
ext4/ext4dev no longer require a journal.

w/o this blkid doesn't recognize after:

# mkfs.ext4 /dev/blah
# tune2fs -O ^has_journal
# blkid /dev/blah

We still must have one ext3-incompat-feature to flag
as ext4(dev) so we shouldn't ever mis-recognize it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-03-06 02:44:07 -05: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 b7c5b40308 Add support for a new superblock field: s_kbytes_written
This field tracks the lifetime amount of writes to the filesystem.  It
will be updated by the kernel as well as by e2fsprogs programs which
write to the filesystem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-03-06 01:59:23 -05:00
Theodore Ts'o cf4e06d665 libext2fs: Add sanity checks to ext2fs_{block,inode}_alloc_stats
If ext2fs_inode_alloc_stats2() or ext2fs_block_alloc_stats() is passed
an insanely large inode or block number, it's possible for these
functions to overrun an array boundary and cause the calling program
to crash with a memory error.

Detect this case, and since these functions don't return an error
code, print a warning message, much like we do in ext2fs_warn_bitmap2().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-22 16:01:38 -05:00
Theodore Ts'o a93d406960 ext2fs_new_inode(): Add sanity check to assure a valid inode number
Add a sanity check to makesure that even if the superblock field
s_first_inode is insane, that we won't return an invalid inode number.
(The function will return the error EXT2_ET_INODE_ALLOC_FAIL in that
case.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-22 15:55:49 -05:00
Theodore Ts'o 9f7a1fc936 ext2fs_get_device_size: Fix error handling
The previous patch would return EFBIG for any failure called from
ext2fs_get_device_size2().  (I didn't merge this fix with the
preceeding commit to allow merges to happen more easily.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 13:37:47 -05:00
Jose R. Santos beab8de477 Add 64-bit getsize interface.
Added interface capable of opening 64-bit block device.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 13:35:15 -05:00
Theodore Ts'o 5299580c1c Use format strings directly to prevent -Werror=format-security failures
Gcc is too stupid to realize that:

    const char *usage="String which has no percent signs";

    com_err(progname, 0, usage);

is OK.  I refuse to bow to stupidity with:

   com_err(progname, 0, "%s", usage);

but I will use the string directly for the sake of people who like to
build with -Werror=format-security.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 13:05:25 -05:00
Theodore Ts'o 31e2a75484 blkid: Add support for detecting user-level suspend as a swsuspend signature
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 12:08:07 -05:00
Eric Sandeen 801b005333 blkid: recognize btrfs
Add btrfs detection to libblkid, now that the disk format should be
recognizable in the future.

# misc/blkid /tmp/fsfile
/tmp/fsfile: LABEL="mylabel" UUID="102b07f0-0e79-4b42-8a4e-1dde418bbe6d" TYPE="btrfs"

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-01-20 00:57:59 -05:00
Thiemo Nagel 79a9ab1454 ext2fs_open2: Add more checks for filesystem consistency
Add more checks to assure the filesystem is sane to avoid later
division by zero errors.

Patch adds consistency checks on superblock to fix serveral crashes:
* require EXT2_INODES_PER_GROUP != 0
* require EXT2_DESC_PER_BLOCK != 0
* require s_first_data_block < s_blocks_count
* require group_desc_count * EXT2_INODES_PER_GROUP == s_inodes_count

Signed-off-by: Thiemo Nagel <thiemo.nagel@ph.tum.de>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-19 23:16:10 -05:00
Theodore Ts'o a7843581f5 ext2fs_read_inode_full: Add safety check to avoid SEGV's on corrupted fs's
Thanks to Thiemo Nagel for suggesting this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-19 23:09:37 -05:00
Theodore Ts'o 07f1a070ff ext2fs_block_iterate2: Preserve the uninit flag in extents
When modifying a block via the block_iterate interface, preserve the
uninit flag in the extent.  Resize2fs uses this interface, so we have
to preserve the uninit status when relocating a block.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-19 19:30:59 -05:00
Theodore Ts'o d3a8fc5ae6 ext2fs_block_iterate2: Reflect errors from ext2fs_extent_set_bmap to caller
If the callback function tries to change a block, and
ext2fs_extent_set_bmap() fails for some reason (for example, there
isn't enough disk space to split a node and expand the extent tree,
make sure that error is reflected back up to the caller.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-19 14:29:08 -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 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
Eric Sandeen 9e7da0bdc1 blkid: recognize ext3 with test_fs set as ext3
It seems that if we have the test_filesystem flag set on an ext3
filesystem(!) on a system which provides ext4, blkid gets confused.

According to the current logic:

* It's not an ext4dev filesystem, because the system provides ext4.
* It's not an ext4 filesystem, because it has no ext4 features.
* It's not an ext3 filesystem, because the test flag is set.

In the end, it's nothing.

blkid should return *something* that is mountable... I'm inclined to
think that ext3 should be the right answer, if no ext4-specific features
are set.

This would mean just dropping the EXT2_FLAGS_TEST_FILESYS test in
probe_ext3(), because ext4 & ext4dev probes have come first already.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-10-18 17:19:56 -04:00
Theodore Ts'o fe144e11e9 libblkid: Refuse to create a device structure for a non-existent device
Fix blkid_get_dev() so it will never return a device structure if the
device file doesn't exist.

Addresses-Debian-Bug: #502541

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-10-18 16:47:46 -04:00
Theodore Ts'o 6964a17720 libblkid: Fix file descriptor leak when checking for a module
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-10-12 23:12:22 -04:00
Eric Sandeen 7ed7a4b6ed unix_io: check for read-only devices when opening R/W
When we open a device on linux, test whether it is writable
right away, rather than trying to proceed and clean up when
writes start failing.

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
Eric Sandeen 18f7343010 e2fsprogs: fix blkid detection of ext4dev as ext4
If only ext4 is available (as a module or in /proc/filesystems)
blkid wasn't properly testing for it, because the time checks
were backwards and always failed.  This caused old ext4dev
filesystems to fail to mount as ext4.  With this patch it works
fine.

Also, don't try to check for modules on a non-Linux system.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-10-12 23:11:44 -04:00
Theodore Ts'o d58d8320e8 Update Makefile depend information for crc16.o
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-10-02 08:59:09 -04:00
Theodore Ts'o 98e9fb9d53 libcom_err: Add missing type declarations to clean up -Wall warnings
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-10-02 08:52:38 -04:00
Theodore Ts'o 902be4ab7d libcom_err: Fix file descriptor leak after an exec
Some applications repeatedly re-exec themselves, and if they use the
com_err library, they can leak a file descriptor for each re-exec.
Fix this by setting the close-on-exec flag on the debug file
descriptor.  In addition, if the COMERR_DEBUG environment variable
isn't set, don't open the file handle at all.

Addresses-Red-Hat-Bugzilla: #464689

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-10-01 21:13:46 -04:00
Theodore Ts'o d7f45af802 libcom_err: Use sem_post/sem_init to prevent race conditions
SuSE has been carrying a patch for a long time to prevent a largely
theoretical race condition if a multi-threaded application adds and
removes error tables in multiple threads.  Unfortunately SuSE's
approach breaks compatibility by forcing applications to link and
compile with the -pthread option; using pthread mutexes has
historically been problematic.

This commit fixes things in a more portable way by using
sem_post/sem_wait instead, which is an older interface that doesn't
require the pthreads library.  Linux happens to implement
sem_post/sem_init using futexes, and -lrt ends up pulling in
-lpthread, but the advantage of using POSIX semaphores is that
applications don't have to be built using -pthread, unlike the use of
pthread mutexes.

The add_error_table() and remove_error_table() interfaces are the
preferred interfaces and locking protection have been added to only
these interfaces.  I have not added locking protection to the
generated initialize_xxx_error_table and initialize_xxx_error_table_r
interfaces, to avoid adding symbol dependencies that would cause a
library to fail to work when linking against older com_err libraries
that do not export et_list_lock() and et_list_unlock().  Threaded
applications shouldn't be using these interfaces in any case.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-12 10:15:26 -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 a846a6e0a7 Install with relative symlinks if $(root_libdir) == $(libdir)
When installing the ELF link library, avoid using absolute pathnames
if $(root_libdir) and $(libdir) are the same.

Addresses-Sourceforge-Bug: #1782913

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-07 03:17:22 -04:00
Theodore Ts'o 97be89b60b Fix pkg-config files: use Requires.private and fix the include directory
Addresses-Sourceforge-Bug: #2089537

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-02 21:20:44 -04:00
Theodore Ts'o e01f9be336 libext2fs: Compile ext2fs_swab64() for all platforms
Although nothing uses ext2fs_swab64() yet, debian's dpkg-gensymbols
picked up the fact that ext2fs_swab64() isn't getting defined on
non-x86 platforms.  Oops.  This patch moves the definition of
ext2fs_swab64() to a place where it will be compiled for all
architectures.

Addresses-Debian-Bug: #497515

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-02 08:49:10 -04:00
Theodore Ts'o 5c0255e8ad libext2fs: Remove unused ext2fs_find_{first,ext}_bit_set()
These functions were commented out for x86, but they were still being
defined for other architectures.  We now remove them entirely.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-02 08:47:19 -04:00
Theodore Ts'o af773654b2 Enable test_io debugging by default
Test I/O debugging is incredibly useful for rooting out problems, so
let's enable by default, especially now that its overhead is only
incurred when it is needed.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-01 11:36:59 -04:00