Commit Graph

1013 Commits (0eeec8ac61bf1eaa31533b2be825cd75580829c9)

Author SHA1 Message Date
Theodore Ts'o 6cb27404f5 Add support for the test_fs flag
The test_fs flag is an "ok to be used with test kernel code" flag.  It
makes it easier for us to determine whether a filesystem should be
mounted using ext4 or not.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-01-26 21:47:40 -05:00
Theodore Ts'o 153439222e Define helper functions ext2fs_set_i_{u,g}id_high() for MacOS compatibility
This is needed for all non-Linux/Hurd/Masix systems...

Addresses-Sourceforge-Bug: #1863819

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-01-21 09:46:05 -05:00
Pixel c40ad3674c blkid: have ntfs's UUID compatible with vol_id
Ensure the length of the UUID is always the same

without the patch:

% blkid /tmp/a /tmp/b
/tmp/a: UUID="7130E4771519577F" TYPE="ntfs"
/tmp/b: UUID="7E9B4A7CCE99CA" TYPE="ntfs"

with the patch:

% blkid /tmp/a /tmp/b
/tmp/a: UUID="7130E4771519577F" TYPE="ntfs"
/tmp/b: UUID="007E9B4A7CCE99CA" TYPE="ntfs"

ie same as:

% vol_id --uuid /tmp/a ; vol_id --uuid /tmp/b
7130E4771519577F
007E9B4A7CCE99CA

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-01-14 10:22:33 -05:00
Theodore Ts'o 42c0b61ca5 Fix profile, checker, and shared-library building on non-Linux platforms
Approximately two years ago a revamp of the e2fsprogs build
infrastructure broke the Makefile fragments for building BSD, Solaris,
and Darwin shared libraries, as well as profiling and checker
libraries.  Apparently no one had noticed except for
pierre42@users.sourceforge.net.

Addresses-Sourceforge-Bug: #1819034

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-01-01 16:48:09 -05:00
Theodore Ts'o fef2b38d8e Merge branch 'maint' into next
Conflicts:

	configure
	debian/rules
	e2fsck/swapfs.c
	lib/ext2fs/ext2_fs.h
2008-01-01 12:41:35 -05:00
Theodore Ts'o 7132d48d83 Fix build failure on non-Linux/non-Hurd/non-Masix systems
The previous fix didn't quite work, but this one should!

Addresses-Sourceforge-Bug: #1861633

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-01-01 12:25:36 -05:00
Theodore Ts'o 0cfde3d15a libss: Remove unnecessary Makefile dependency for test_ss
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-01-01 01:19:19 -05:00
Theodore Ts'o 904dad55e6 Update dependencies in lib/uuid/Makefile.in
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-31 23:12:35 -05:00
Theodore Ts'o 9320c6ffcd Fix build error in blkid/tst_types.c when using diet libc
When compiling with diet libc, <sys/types.h> must be included in order
to define the types used in asm/types.h.  Strange choice, but
workable.  This doesn't cause much problems for e2fsprogs except
blkid/tst_types.h, which needed a #include of <sys/types.h>.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-31 22:35:18 -05:00
Theodore Ts'o 29dd9d1e90 Test for sys/syscall.h in configure to fix dietlibc build problem
When compiling with dietlibc, sys/syscall.h isn't supported; as of
dietlibc 0.30, it exists but it references a non-existent asm/unistd.h
header file.  So we have to test for its existence and avoid using it
in lib/uuid/gen_uuid.c if it is not supported.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-31 22:34:25 -05:00
Theodore Ts'o 5610f9924b Add --disable-uuidd configure option
Add a configure option which causes the uuidd helper daemon not to be
built or used by the uuid library.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-31 22:34:19 -05:00
Theodore Ts'o 3306861158 Fix build failure on non-Linux/non-Hurd/non-Masix systems
inode_uid() and inode_gid() weren't getting defined on systems that
were not Linux, Hurd, or Masix.

Addresses-Sourceforge-Bug: #1859778

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

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-27 10:08:13 -05:00
Theodore Ts'o f79fb4976c libuuid: Fix bug which caused uuidd to fail if sizeof(int) != sizeof(int *)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-21 11:32:48 -05:00
Theodore Ts'o 3166c58dc0 Add #define needed for Hurd ioctl definitions
Addresses-Debian-Bug: #437720

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-17 23:03:53 -05:00
Theodore Ts'o d37a4fa788 libuuid: Only try to start the uuidd daemon a limited number of times
If we fail to create the uuidd daemon after 5 or 6 tries, another
10,000 tries probably won't be successful.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-17 15:26:47 -05:00
Theodore Ts'o 9d8c203a46 libuuid: When starting uuidd, use waitpid() to reap the zombie process
The uuidd process will fork and let the parent process exit to create
the daemon.  So use waitpid to reap the zombie, as well as using it to
time when it is safe to try to connect to the daemon.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-17 15:16:44 -05:00
Theodore Ts'o 2165003bd5 uuidd: Use /var/lib/libuuid instead of /var/run/uuidd
/var/run can get completely removed at reboot, and uuidd doesn't have
permissions to recreate /var/run/uuidd.  So instead use
/var/lib/libuuidd for the unix domain socket and pid files.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-17 15:12:04 -05:00
Theodore Ts'o b689b8dd14 Merge branch 'maint' into next
Conflicts:

	lib/ext2fs/closefs.c
2007-12-17 10:28:01 -05:00
Theodore Ts'o 740837def7 Add uuidd daemon to prevent duplicate time-based UUID's
Also store the clock sequence information in a state file in
/var/lib/misc/uuid-clock so that if the time goes backwards the clock
sequence counter can get bumped.  This allows us to completely
correctly generate time-based (version 1) UUID's according to the
algorithm specified RFC 4122.

Addresses-Sourceforge-Bug: #1529672
Addresses-Red-Hat-Bugzilla: #233471

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-16 17:28:46 -05:00
Theodore Ts'o 6b6c27fb8a libcom_err: Fix sign-extension problem on 64-bit systems in error_message()
On 64-bit systems (or anything with sizeof(long) > sizeof(int)), we
sometimes get error codes passed to error_message which have been cast
from an (int) to an (unsigned int). This almost always happens if
you're using libgssapi_krb5, which returns an error code which is less
than 0 but is returned in an (unsigned int).

For example, -1765328377L gets cast to 2529638919, which is
0x96c73a07, not 0xffffffff96c73a07, so error_message() fails to find a
matching error table.

When error_message() then calls the error_table_name() function to get a
name to use in the "unknown code" message, it gets a correct value back.

This happens because error_table_name() drops most of the higher bits of
the parameter it's passed before doing anything else with it (& 077777777f,
or & 0xffffff). If we did the same thing in error_message(), we wouldn't
have a problem there, either.

Problem reported and fixed by: Nalin Dahyabhai

Addresses-Sourceforge-Bug: #1809658

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-15 22:31:03 -05:00
Theodore Ts'o 20c10a7667 blkid: Avoid division by zero error when probing an invalid FAT filesystem
Addresses-Sourceforge-Bug: #1831627

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-15 22:21:31 -05:00
Theodore Ts'o bef406047d libss: Fix "make check" test case to work portably
The "make check" test in lib/ss would fail if '.' is not in the user's
PATH, and if the libss shared library had not yet been installed yet.

Addresses-Sourceforge-Bug: #1848974

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-15 22:09:48 -05:00
Theodore Ts'o daecda1cad Fix uuid_unparse man page to give a correct example UUID output string
Addresses-Debian-Bug: #444883

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-15 21:13:42 -05:00
Theodore Ts'o 9a083af71a ext2fs_flushfs: Remove the NEEDS_RECOVERY from the backup superblocks
Now that e2fsck tries to backup the primary superblock to the backups
when the feature sets ar different, it's important when tune2fs writes
out a changed superblock, that we filter out the
EXT3_FEATURE_INCOMPAT_RECOVER feature to the backup superblocks, since
it will be removed from the primary superblock either when the
filesystem is mounted uncleanly or when journal is replayed.

Addresses-Debian-Bug: #454926

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-15 19:39:37 -05:00
Theodore Ts'o e6a4571eec Merge branch 'maint' into next
Conflicts:

	lib/ext2fs/closefs.c
2007-12-09 17:03:01 -05:00
Theodore Ts'o ee01079a17 libext2fs: Add checks to prevent integer overflows passed to malloc()
This addresses a potential security vulnerability where an untrusted
filesystem can be corrupted in such a way that a program using
libext2fs will allocate a buffer which is far too small.  This can
lead to either a crash or potentially a heap-based buffer overflow
crash.  No known exploits exist, but main concern is where an
untrusted user who possesses privileged access in a guest Xen
environment could corrupt a filesystem which is then accessed by the
pygrub program, running as root in the dom0 host environment, thus
allowing the untrusted user to gain privileged access in the host OS.

Thanks to the McAfee AVERT Research group for reporting this issue.

Addresses CVE-2007-5497.

Signed-off-by: Rafal Wojtczuk <rafal_wojtczuk@mcafee.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-05 21:01:35 -05:00
Theodore Ts'o 1113bf706f libss: Fix parallel build failure
A missing dependency on ss_err.h meant that std_rqs.o could fail when
e2fsprogs was being built using make -j.

Thanks to Robert Kerr for reporting this bug.

Addresses-Sourceforge-Bug: #1842331

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-02 05:52:40 -05:00
Eric Sandeen 38361bbbb5 e2fsprogs: fix blkid whole-disk scanning heuristics
The heuristics in blkid/devname.c probe_all() for scanning whole disks
with no partitions assume that a device name with no digit on the end
will always be present as a delineator, i.e.:

sda
sda1
sdb
sdc

In this case, when sdc is seen, it's the clue to go back and scan sdb.
However, for something like:

sda
sda1
sdb
loop0

this falls down, and sdb is never scanned.
(thanks to Karel Zak for pointing this out).

Addresses-Red-Hat-Bugzilla: #400321

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-02 05:25:30 -05:00
Theodore Ts'o 7e5a86a660 libext2fs: Fix a corner case bug in ext2fs_unlink
We cannot merge a removed directory entry to just arbitrary previous
directory entry. The previous entry must be in the same block.  So
really bad things can happen when are deleting the first directory
entry in a block where the last directory entry in the previous
directory block is not in use.  We fix this bug by checking to see if
the current entry is not the first one in the block before trying to
merge it to the previous entry.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-02 05:25:30 -05:00
Andreas Dilger 8cdd6a6f34 fix check_mntent_file() to pass mode for open(O_CREAT)
On my FC8 install, ismounted.c fails to build because open(O_CREAT) is
used without passing a mode.  The following trivial patch fixes it.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2007-12-02 05:25:30 -05:00
Theodore Ts'o 33b92836cd Fix errors in test_ss.c so it can be an example application and test case
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-02 05:25:23 -05:00
Theodore Ts'o 5ea565fd37 Merge basic FLEX_BG support
Merge commit 'c2d4300b8a4a13d8a78b86c386f76259f23feec2' into next
2007-11-03 21:01:01 -04:00
Jose R. Santos c2d4300b8a Enable FLEX_BG feature support
Add FLEX_BG as a supported feature bit.

Add support to mke2fs to create filesystems with FLEX_BG.

Add support to tune2fs to add (and remove, if it won't break
filesystem consistency) the FLEX_BG feature.

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

 lib/e2p/feature.c   |    2 ++
 lib/ext2fs/ext2fs.h |    6 ++++--
 misc/mke2fs.c       |    7 ++++++-
 3 files changed, 12 insertions(+), 3 deletions(-)
2007-11-03 20:40:56 -04:00
Jose R. Santos 88b34b1f87 Relax group descriptor checking for FLEX_BG
The FLEX_BG feature allows the inode table, block bitmap, and inode
bitmaps to be located anywhere in the filesystem.  Update e2fsck and
libext2fs's checking code to recognize this.

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

 e2fsck/super.c          |   14 ++++++++++++--
 lib/ext2fs/check_desc.c |   15 +++++++++++++--
 2 files changed, 25 insertions(+), 4 deletions(-)
2007-11-03 20:13:16 -04:00
Jose R. Santos 4d5cb2ac91 lib/ext2fs/Makefile.in: Reorder some of the $(SRCS) in alphabetical order.
All files under $(OBJS) and $(SRCS) should be in alphabetical order
but this is not always the case.  Let fix some some of these before
applying new files to the list of $(SRCS).

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

 lib/ext2fs/Makefile.in |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
2007-11-03 13:56:56 -04:00
Jose R. Santos cf0eeec015 Reserve the INCOMPAT feature number for FLEX_BG.
Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
--

 lib/ext2fs/ext2_fs.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
2007-11-03 12:10:12 -04:00
Theodore Ts'o d9099eec8e Merge branch 'cl/remove-masix' into next 2007-11-01 01:54:22 -04:00
Coly Li c9548bc37e libext2fs: remove masix support
This patch remove masix support from lib/ext2fs.

Signed-off-by: Coly Li <coyli@suse.de>
2007-11-01 01:53:56 -04:00
Dmitry V. Levin 7b7370bd2e blkid.pc, ss.pc: Move private libs from "Libs:" to "Libs.private:"
According to pkg-config(1) manual page, private libraries should be
defined by "Libs.private:" line.  Private libraries are libraries which
are not exposed through our library, but are needed in the case of
static linking.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2007-11-01 00:32:32 -04:00
Dmitry V. Levin 710bac86a5 texinfo: Fix directory entries
According to texinfo documentation, @dircategory and
@direntry...@end direntry commands are more appropriate.

For details see
http://www.gnu.org/software/texinfo/manual/texinfo/html_node/Installing-Dir-Entries.html

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2007-11-01 00:25:02 -04:00
Dmitry V. Levin 3b06802bbb blkid/test_probe.in: Fix temporary files handling
Avoid placing files with predictable names in /tmp.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2007-10-29 10:59:01 -04:00
Dmitry V. Levin d9039ae0ff Check fgets(3) return value
When fgets() function fails, contents of the buffer is undefined.  That
is, fgets() return value needs to be checked, to avoid undefined behavior.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2007-10-29 10:59:01 -04:00
Theodore Ts'o 14bd240b46 libe2p: Change iterate_on_dir so that it counts non-zero returns
To allow error messages to be reflected up, if the callback function
returns a non-zero value, bump a counter and return the number of
times the callback function signals an error by returning a non-zero
status code.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-10-22 08:25:13 -04:00
Theodore Ts'o 1a4ce9df58 libe2p: Use lstat() instead of stat() in fsetflags() and fgetflags()
We can't set the flags on symbolic links, so check for them using
lstat().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-10-22 08:05:44 -04:00
Theodore Ts'o 042a27f823 Merge branch 'maint' into next 2007-10-15 16:24:56 -04:00
Eric Sandeen f493d4e0ac libblkid: recognize squashfs filesystems on BE systems.
squashfs has no uuid or labels, so all we need is the magic
(for big-endian too!)

Addresses-Red-Hat-Bugzilla: #305151

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
2007-10-15 16:23:39 -04:00
Valerie Clement f2de1d38d0 libext2fs: Add EXT2_DESC_SIZE and EXT2_DESC_PER_BLOCK macros
Add macros to support variable-length group descriptors for ext4.

Signed-off-by: Valerie Clement <valerie.clement@bull.net>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-10-14 22:08:35 -04:00
Valerie Clement 5d38ef1d04 libext2fs: cleanup usage of unsigned int or __u32 and replace it with blk_t
Signed-off-by: Valerie Clement <valerie.clement@bull.net>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-10-14 21:54:28 -04:00
Valerie Clement 3bfca9a499 libext2fs: use ext2fs_group_first_block() instead of open-coded equivalent
Use ext2fs_group_first_block() instead of the open-coded equivalent in
ext2fs_super_and_bgd_loc() and ext2fs_descriptor_block_loc().

Signed-off-by: Valerie Clement <valerie.clement@bull.net>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-10-14 18:52:01 -04:00
Theodore Ts'o eac91b3537 Add blk64_t type definition
This will be used for all new functions so we can gradually move
e2fsprogs to support 64 bit blocks.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-10-14 11:23:20 -04:00
Eric Sandeen 5845efd123 libblkid: detect squashfs
libblkid: recognize squashfs filesystems

squashfs has no uuid or labels, so all we need is the magic.

Addresses-Red-Hat-Bugzilla: #305151

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
2007-10-14 10:11:52 -04:00
Theodore Ts'o 2628a1d3e1 Merge branch 'maint' 2007-10-06 12:41:26 -04:00
Theodore Ts'o f6341e9c70 ext2fs_dblist_dir_iterate: Fix ABORT propagation logic
ext2fs_dblist_dir_iterate() calls ext2fs_dblist_iterate(), which calls
ext2fs_process_dir_block(), which in turn calls the helper function
db_dir_proc() which calls callback function passed into
ext2fs_dblist_dir_iterate().  At each stage the conventions for
signalling requests to abort the iteration or to signal errors
changes, db_dir_proc() was not properly mapping the abort request back
to ext2fs_dblist_iterate().

Currently db_dir_proc() is ignoring errors (i/o errors or directory
block corrupt errors) from ext2fs_process_dir_block(), since the main
user of ext2fs_dblist_dir_iterate() is e2fsck, for which this is the
correct behavior.  In the future ext2fs_dblist_dir_iterate() could
take a flag which would cause it to abort if
ext2fs_process_dir_block() returns an error; however, it's not clear
how useful this would be since we don't have a way of signalling the
exact nature of which block had the error, and the caller wouldn't
have a good way of knowing what percentage of the directory block list
had been processed.  Ultimately this may not be the best interface for
applications that need that level of error reporting.

Thanks to Vladimir V. Saveliev <vs@clusterfs.com> for pointing out
this problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-09-23 11:39:24 -04:00
Theodore Ts'o 846be6db81 libblkid: Add more magic numbers that might mean there is a FAT filesystem
The FAT filesystem doesn't have its superblock with a set of magic
strings in a fixed location.  Therefore, we must also check for the
FAT filesystem if it looks like we have an MBR at the beginning of the
partition.  We previously checked if the first byte was a jump
instruction but that missed some USB disks with only one bootable
partition.  Now we check for the MBR signature (0x55AA at offset 510)
as well as any partition where byte 0 is \351 or \353.

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-09-23 09:50:11 -04:00
Theodore Ts'o ba9d929d91 Don't crash if s_inode_size is zero
Any attempt to open a filesystem with s_inode_size set to zero causes
a floating point exception.  This is true for e2fsck, dumpe2fs,
e2image, etc.  Fix ext2fs_open2() so that it returns the error code
EXT2_ET_CORRUPT_SUPERBLOCK instead of crashing.

Thanks to Dean Bender for reporting this bug.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-09-07 16:40:25 -04:00
Theodore Ts'o a5dda05422 Remove configure --enable-swapfs and associated support #defines
This removes the last vestiges of support for the legacy PowerPC
big-endian filesystem format.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-08-11 03:22:00 -04:00
Theodore Ts'o 126a291c76 Clean up libext2fs by byte swapping iff WORDS_BIGENDIAN
We don't need byte swapping to be a run-time option; it can just be a
compile-time option instead.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-08-11 01:59:13 -04:00
Theodore Ts'o ccbcc40e3b Remove PowerPC bitmap hackery since it's not been needed since Linux 2.1
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-08-11 01:59:13 -04:00
Theodore Ts'o a98b51e9dd Miscellaneous Cleanups
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: Girish Shilamkar <girish@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-08-03 20:10:46 -04:00
Theodore Ts'o 6d96b00d57 Add I/O statistics to e2fsck
This patch instruments the libext2fs unix I/O manager and adds bytes
read/written and data rate to e2fsck -tt pass/overall timing output.

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

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

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

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-23 04:32:48 -04:00
Theodore Ts'o 50448d3dff libext2fs: 32-bit bitmap refactorization, part 2
Move the contents of rs_bitmap.c and cmp_bitmaps.c into gen_bitmap.c
and bitmaps.c.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-22 23:42:14 -04:00
Theodore Ts'o a0553c9d6e libext2fs: 32-bit bitmap refactorization, part 1
Move the 32-bit specific bitmap code into gen_bitmap.c, and the
high-level interfaces into bitmaps.c.  Eventually we'll move the
new-style bitmap code into gen_bitmap64.c, but first we need to
isolate the code with knowledge of the bitmap internals in one place
first.

In this patch we move allocation, free, copy, clear, set_padding, and
fudge_end function into gen_bitmap.c, and make sure that the bitmaps.c
and bitops.c no longer have any knowledge of the bitmap internals.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-22 22:59:50 -04:00
Theodore Ts'o 271a375b59 Move ext2fs_get_{block,inode}_bitmap_{start,end}() to generic functions
Create ext2fs_get_generic_bitmap_{start,end}() and use them for inline
functions.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-22 19:16:08 -04:00
Theodore Ts'o 8df1827b55 Uninline ext2fs_{mark,unmark,test}_block_bitmap_range() to gen_bitmap.c
Also uninline ext2fs_fast_{mark,unmark,test}_block_bitmap_range() and
use the generic routines.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-22 18:54:10 -04:00
Theodore Ts'o 7bf257a9a0 Change fast ext2fs bitmap functions to use the generic bitmap functions
This changes ext2fs_fast_{mark,unmark,test}_{inode,block}_bitmap() to
be inline functions which calls ext2fs_{mark,unmark,test}_generic_bitmap().

This is part of the preparation to support the new-style bitmaps.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-22 17:57:13 -04:00
Theodore Ts'o b15beaaf38 Move ext2fs_test_generic_bitmap() to gen_bitmap.c
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-22 17:42:52 -04:00
Eric Sandeen bd828a27e2 Fix test in ext2fs_check_desc() for inode table within block group
The test in ext2fs_check_desc() is off by one; if the inode table
goes all the way to the last block of the block group, it will
falsely assert that it has extended past it.  The last block
of a range is start + len -1, not start + len.

You can create (valid) filesystems that will cause e2fsck to complain
via one of the following mkfs commands:

mkfs.ext3 -F -b 1024 /dev/sdb1 2046000000
mke2fs -j -F -b 4096 -m 0 -N 5217280 /mnt/test/fsfile2 327680
mkfs.ext2 -F -b 1024 -m 0 -g 256 -N 3744 fsfile 1024

Addresses-Red-Hat-Bugzilla: #214765

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-22 16:00:43 -04:00
Theodore Ts'o 5a92a627f1 Properly calculate overhead in ext2fs_initialize()
For some odd geometries*, mkfs will try to allocate inode tables off
the end of the block group and fail, rather than warning that too
many inodes have been requested.

This is because when ext2fs_initialize calculates metadata overhead,
it is only adding in group descriptor blocks and the superblock
if the *last* bg contains them - but the first bg also has all of
the various metadata bits taking up space.

We need to calculate the overhead both for the first block group and
the last block groups separately, since the two different tests need
to know what the overheads are for those two cases, which may be
different.

*for example "mke2fs  -b 1024 -m 0 -g 256 -N 3745 fsfile 1024"

(Note, the test here is a little funky; the expected output is
actually a mkfs failure - but a proper failure instead of the
allocator catching the problem at the last minute)

Addresses-Red-Hat-Bugzilla: #241767

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-22 15:14:38 -04:00
Eric Sandeen db9097caca Fix big-endian byte-swapping bug in ext2fs_swap_inode_full()
We need to set t->i_file_acl before we test it in
ext2fs_inode_data_blocks()

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-18 11:49:47 -04:00
Theodore Ts'o 0225face1b Add debugging printf to blkid's probe routine when original fs type failed
This particular bit of code has caused problems before, so make it
easier to debug problems caused by the probe verification looping
forever here.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-08 20:17:31 -04:00
Theodore Ts'o a2df22f1e9 Stop after the second '.' when parsing version numbers
Now that we are moving to x.y.z version number scheme for maintenance
releases, we ned to change ext2fs_parse_version_string and
blkid_parse_version_string to ignore the second period so we don't
have maintenance releases with a substantially bigger verison number
than the initial x.y release.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-08 12:37:13 -04:00
Theodore Ts'o 424a3e4a23 Remove Changelog files since they're not used after the git migration
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-08 08:50:41 -04:00
Theodore Ts'o ac7dd696d6 Fix bug which could cause libblkid to loop forever
When revalidating a partition where there is obsolete information in
/etc/blkid.tab, we end up freeing a the type tag without clearing
dev->bid_type, causing blkid_verify() to loop forever.

Addresses-Debian-Bug: #432052

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-08 08:50:41 -04:00
Theodore Ts'o 4b4df799f1 Make it clear in an error message that it is mk_cmds that is complaining
Obviates gentoo patch: e2fsprogs-1.32-mk_cmds-cosmetic.patch

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-30 20:05:41 -04:00
Theodore Ts'o becc391037 Release of e2fsprogs version 1.40
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-29 22:05:14 -04:00
Kalpak Shah 1ed49d2c2a Fix byte swapping bug in get_next_inode_full()
On big-endian systems, while swapping, ext2fs_swap_inode_full() swaps
only 128+extra_isize bytes and the EAs if they are present. Now if inode
N has EAs, (and this is the inode in the "scratch inode") then inode N+1
also carries seems to have them since the "scratch inode" was never
zeroed.

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-29 21:40:19 -04:00
Theodore Ts'o d7b64725ee Update Release Notes, Changelogs, version.h, etc. for 1.40 release
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-24 17:32:47 -04:00
Theodore Ts'o 30dd262235 Fix divide by zero error in blkid's NTFS probing logic
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-24 17:17:24 -04:00
Theodore Ts'o 0d8b6733c7 Fix the info-dir line for the com_err.texinfo file
Fix the info-dir line so that the menu name does not contain a .info
prefix.  First of all, it's ugly, secondly, it causes the install-info
command to fail to remove the com_err info file from the
/usr/share/info/dir file when the comerr-dev package is removed and
purged.

Addresses Debian Bug: #401711

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-24 16:59:36 -04:00
Kalpak Shah 915a2669ef Fix ext2fs_read_inode_full() so that the whole inode is byte-swapped
Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-22 22:32:43 -04:00
Theodore Ts'o c844010cc4 Fix byte-swapping issues for the i_extra_size field
Thanks to Andreas Dilger and Kalpak Shah for spotting this problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-22 19:53:21 -04:00
Karsten Hopp e382a7eade Add support for LUKS encrypted partitions
This patch adds support for cryptsetup-luks (http://luks.endorphin.org)
UUIDs to libblkid.  This is required p.e. to avoid hardcoding device
names for encrypted partitions.  Could you please take a look at it and
consider inclusion in the next e2fsprogs release ?

Signed-off-by: Karsten Hopp <karsten@redhat.com>
2007-06-21 13:43:33 -04:00
Theodore Ts'o 56d1236726 Add default journal size function
Factor out the code which sets the default journal size and move it
into libext2fs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-21 11:59:06 -04:00
Theodore Ts'o cb0c5d701a Add more paranoid NTFS probing and fetch UUID and LABEL information
Hopefully this addresses false positives by the blkid library when
detecting NTFS partitions.

Addresses Launchpad Bug: #110138

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

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-18 18:26:50 -04:00
Theodore Ts'o a2b2ff61c8 Add test to make sure the ext2 superblock structure is 1024 bytes
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-31 12:39:02 -04:00
Theodore Ts'o decb2a5b3a Reserve superblock field for the raid stripe width.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-31 12:30:09 -04:00
Andreas Dilger b62e88af6a Reserve superblock fields for multiple mount protection feature
There have been reported instances of a filesystem having been mounted
at 2 places at the same time causing a lot of damage to the
filesystem. This patch reserves superblock fields and an INCOMPAT flag
for adding multiple mount protection(MMP) support within the ext4
filesystem itself. The superblock will have a block number
(s_mmp_block) which will hold a MMP structure which has a sequence
number which will be periodically updated every 5 seconds by a mounted
filesystem. Whenever a filesystem will be mounted it will wait for
s_mmp_interval seconds to make sure that the MMP sequence does not
change. To further make sure, we write a random sequence number into
the MMP block and wait for another s_mmp_interval secs. If the
sequence no. doesn't change then the mount will succeed. In case of
failure, the nodename, bdevname and the time at which the MMP block
was last updated will be displayed. tune2fs can be used to set
s_mmp_interval as desired.

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
2007-05-31 12:25:46 -04:00
Andreas Dilger de8f3a7621 Fix gcc -Wall warnings, especially on 64-bit systems
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-25 11:18:11 -04:00
Theodore Ts'o 96c6a3acd3 Store the RAID stride value in the superblock and take advantage of it
Store the RAID stride value when a filesystem is created with a requested
RAID stride, and then use it automatically in resize2fs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-18 22:06:53 -04:00
Theodore Ts'o 6fb57a92d1 libblkid: Fix bug which could cuase bid_type to be corrupted
Fortunately bid_type isn't used much, and bid_label and bid_uuid is
only used by debugging code, so the impact of this bug was very
minor.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-18 21:44:29 -04:00
Theodore Ts'o 7292355283 Add new function blkid_gc_cache()
New function which performs a garbage collection pass on the
/etc/blkid.tab file.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-18 00:02:35 -04:00
Eric Sandeen 5113a6e32b Fix mke2fs and debugfs to support large (> 16 bit) uid's and gid's
Mke2fs is supposed to set the uid/gid ownership of the root directory when
a non-rooot user creates the filesystem.  This wasn't working correctly
if the uid/gid was > 16 bits.   In additional, debugfs wasn't displaying
large uid/gid's correctly.  This patch fixes these two programs.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-08 00:10:54 -04:00
Theodore Ts'o d362a3fb7e Define the l_i_iversion field in ext2_inode
The l_i_version field is now defined from the old l_i_reserved1 field in
the ext2 inode.  This field will be used to store high 32 bits of the
64-bit inode version number.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-19 01:53:53 -04:00
Theodore Ts'o d22c15a43e ext2fs_get_device_size(): Fix potential fd descriptor leak in an error case
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-18 21:37:42 -04:00
Bryn M. Reeves 3f4c46e3f9 Correct byteswapping for fast symlinks with xattrs
Fix a problem byte-swapping fast symlinks inodes that contain extended
attributes.

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

Signed-off-by: "Bryn M. Reeves" <breeves@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-14 14:00:31 -04:00
Sergey Vlasov c9105ffbe5 blkid: Report correct UUID from MD superblocks
The second part of UUID was copied to a wrong place in the buffer.
Now the UUID shown by blkid is the same as shown by /lib/udev/vol_id
(at least with udev-108), but is not in the same form as used by mdadm
(which prints UUID as 4 32-bit words and uses different endiannes).

Signed-off-by: Sergey Vlasov <vsu@altlinux.ru>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2007-04-10 12:00:38 -04:00
Sergey Vlasov 6b8be16e3a blkid: Fix MD 0.90 superblock detection on little endian systems
MD 0.90 superblock format is host endian - need to check for bith big
endian and little endian magic.  Without this change MD components
created on little endian systems were not detected as such, which
could then lead to false positives when detecting filesystems.

Signed-off-by: Sergey Vlasov <vsu@altlinux.ru>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2007-04-10 11:59:46 -04:00
Theodore Ts'o a1f642728f Fix memory leaks from using the tdb library
We weren't freeing allocated memory from calls to tdb_fetch, tdb_firstkey,
and tdb_nextkey.  Oops.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-06 23:28:30 -04:00
Theodore Ts'o 1b9d8cb705 Add support for using TDB to libext2fs's icount abstraction
Add support for using TDB to store the icount data, so we don't run out
of memory when checking really large filesystems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-06 14:30:39 -04:00
Theodore Ts'o 47e90ebd34 Add new TDB error codes
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-06 13:50:48 -04:00
Theodore Ts'o 1cb78d8433 Add a regression test suite for libext2fs's icount abstraction
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-06 08:52:49 -04:00
Jim Garlick cc37e0d3ae Fix memory leak in ext2fs_write_new_inode()
The following patch addresses a memory leak in libext2fs
that occurs when using ext2fs_write_new_inode() on a file system
configured with large inodes.

Signed-off-by: Jim Garlick <garlick@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-06 08:50:15 -04:00
Theodore Ts'o 106ad96dae Add tdb from Samba into libext2fs library.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-04 21:26:37 -04:00
Theodore Ts'o 4aec958561 Add #include's to avoid compiler warnings in lib/ext2fs/tst_types
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-04 21:09:49 -04:00
Theodore Ts'o 641b66bc7e Fix potential infinite loop in e2fsck on really big filesystems
Prevent floating point precision errors on really big filesystems from
causing the search interpolation algorithm in the icount abstraction
from looping forever.

Addresses Debian Bug: #411838

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-02 19:27:44 -04:00
Theodore Ts'o 51764fb104 resize2fs (libe2p): Fix resize2fs parsing of size parameter (in sector units)
This was actually a bug in libe2p's parse_num_blocks() function.  When
handling the 's' suffix, it was ignoring the blocksize information
passed in from the caller and always interpreting the number in terms of
a 1k blocksize.

Addresses Debian Bug: #408298

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-02 19:12:17 -04:00
Brian Behlendorf e0a700d45d [COVERITY] Fix (error case) memory leak in blkid library (parse_dev)
Coverity ID: 29: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-23 22:55:59 -04:00
Brian Behlendorf f93625b292 [COVERITY] Fix (error case) memory leak in libext2fs (ext2fs_image_inode_write)
Use pre-existing early exit label in function to handle proper
error code return and local memory allocation cleanup.

Coverity ID: 23: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2007-03-21 17:43:37 -04:00
Brian Behlendorf e649be9daa [COVERITY] Fix (error case) memory leak in libext2fs (ext2fs_write_inode_full)
Need to free w_inode on early exit if w_inode != &temp_inode.

Coverity ID: 22: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2007-03-21 17:38:47 -04:00
Brian Behlendorf f19c46dfbc [COVERITY] Fix memory leak in libss (ss_execute_line)
Fix a memory leak by freeing the argv[] array if ss_parse_line returns 0
for argc 0 (which will happen if the user his return and sends an empty
line to the application).

Potentially need to free argv before early return since it was allocated
memory. Need to be careful since it may be possible for ss_parse() to have
freed the memory allocated to it if it detects an unbalanced set of quotes
passed to it.

Coverity ID: 21: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2007-03-21 17:34:47 -04:00
Theodore Ts'o 5f7fe7fe0e [VALGRIND] Fix memory leak in libblkid (blkid_get_devname)
Nyah, nyah, Coverity didn't find this one.  :-)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-21 17:15:36 -04:00
Brian Behlendorf 61bf36ef2d [COVERITY] Fix memory leak in libe2p (e2p_edit_mntopts)
Need to free memory allocated to buf.

Coverity ID: 17: Resource Leak
Coverity ID: 18: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-21 17:14:10 -04:00
Brian Behlendorf 2711ca1c23 [COVERITY] Fix memory leak in libe2p (e2p_edit_feature)
Coverity ID: 15: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-21 16:48:47 -04:00
Brian Behlendorf d2021de5cf [COVERITY] Fix bad error checking for NULL parameter in ss library
Looks like flawed reasoning.  Here if info_dir is NULL then you are
guaranteed to blow up since you will dereference it.  It seems like the
correct thing to do here (what the code author meant to do) was to set
*code_ptr = SS_ET_NO_INFO_DIR if info_dir was NULL or if *info_dir was
an empty string (aka *info_dir == '\0').

Coverity ID: 8: Forward Null

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2007-03-19 08:39:32 -04:00
Theodore Ts'o d90be5b143 [COVERITY] Allow blkid_dev_has_tag to check if a tag exists when value==NULL
blkid_dev_has_tag() will immediately return -1 (an error if value is
NULL.  Thus at the test later on value cannot be NULL. There are two
possible ways to go about fixing this. The first would be to remove the
first NULL check for value.  The second one would be to remove the
second check (and the deadcode).

I chose the second path because the functionality added is something
which a programmer could reasonably expect given the function name, and
it is highly unlikely any existing code is depending on the fact that
blkid_dev_has_tag() will return an error if value is NULL.

Coverity ID: 3: Deadcode

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-18 11:21:44 -04:00
Theodore Ts'o 257ace82b7 Fix memory leak in blkid library
Addresses Debian Bug: #413661

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-06 19:56:18 -05:00
Theodore Ts'o ec84b746f5 Add debugging code to the com_err library
If the environment variable COMERR_DEBUG is set to 1, print out debugging
messages as error tables are added and removed from the com_err library.
If the COMERR_DEBUG_FILE environment variable is set (and the process is
not setuid) the debugging messages may be redirected to a file.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-12-22 13:38:38 -05:00
Theodore Ts'o d2a3bf2ccc Fix (as yet unused) struct ext4_group_desc to add a missing bg_pad field
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-30 14:48:48 -05:00
Theodore Ts'o 83732f11d6 Add libreadline.so.5 to the list of readline libraries used by libss
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-17 22:56:23 -05:00
Theodore Ts'o dec5cd13ff Fix gcc -Wall complaints in libext2fs
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-14 23:14:12 -05:00
Theodore Ts'o 2694f31946 Fix type punning bugs in ext2fs_get_mem() and ext2fs_free_mem()
This was causing dumpe2fs to crash on the ARM platform when examining
the badblocks list.

Also reverts an incorrect fix made by changeset 38078f692c20

Addresses Debian Bug: #397044
2006-11-14 00:34:34 -05:00
Theodore Ts'o cf8272e108 Allow debugfs and dumpe2fs to support fs features under development
Add support for the new flag EXT2_FLAG_SOFTSUPP_FEATURES flag to
ext2fs_open() , which allows application to open filesystes with features
which are currently only partially supported by e2fsprogs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-12 23:26:46 -05:00
Theodore Ts'o 89dd65704f Check in ext4 extent headers into the source tree
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-12 22:54:35 -05:00
Theodore Ts'o 477007e1b1 Add support for printing new filesystem features
Add support for printing the huge_file, gdt_checksum, dir_nlink,
extra_isize, extent, and 64bit features.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-12 22:50:18 -05:00
Theodore Ts'o 413a78f657 Work around GCC bug on the Arm platform
Addresses Debian Bug: #397044

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

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

Addresses Debian Bugs: #360661, #360317

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

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

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

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

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

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

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

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

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

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-18 19:16:10 -05:00
Theodore Ts'o fa6c653ec3 Add IO_FLAG_EXCLUSIVE flag to io_channel abstraction
Add a new io_channel open flag, IO_FLAG_EXCLUSIVE,which requests that 
the device be opened in exclusive (O_EXCL) mode.  Add support to the unix_io
implementation for this flag.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-18 18:57:44 -05:00
Theodore Ts'o 7447921dff Fix documentation: BLOCK_FLAG_TRAVERSE should be BLOCK_FLAG_DEPTH_TRAVERSE
Addresses Debian Bug #351268

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-18 08:26:36 -05:00
Theodore Ts'o cbb7f9c4f1 Fix build when not building any shared libraries.
Add missing real-subdirs:: line to lib/Makefile.library, so there is a 
default definition of the real-subdirs target.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-17 21:59:13 -05:00
Theodore Ts'o a612f3432e Fix a signed vs unsigned bug in calc_reserved_gdt_blocks()
This fixes mke2fs -O resize_inode for very large filesystems (i.e., 20GB).
Addresses Debian Bug #346580

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-17 20:39:52 -05:00
Theodore Ts'o bf69235ad0 Add support for on-line resizing to resize2fs
If the filesystem is mounted, attempt to use the on-line resizing
ioctls to resize the filesystem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-17 19:45:45 -05:00
Theodore Ts'o e324b25059 Fix blkid's last verification logic to work when the system clock is insane
Users have reported problems on newly installed systems when the
Macintosh's system clock battery is dead and the hardware clock is
returning a date of 1904.  Turns out there were some bugs in handling
dates before the Unix epoch.

Addresses Red Hat Bug: #182188

probe.c (blkid_verify): Fix the bid_time sanity checking logic,
	so that if last verification time is more recent than the
	current time, or the comparison between the last
	verification time and the current time causes an overflow,
	a device verification will take place.

devname.c (blkid_get_dev): Set the initial bid_time to be
	INT_MIN, to guarantee that blkid_verify will always be run
	even when the system clock is insane.

dev.c (blkid_debug_dump_dev), read.c (debug_dump_dev), 
	save.c (save_dev): Fix the printf format for dev->bid_time
	to match the fact that it is an signed type.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-12 23:25:15 -05:00
Theodore Ts'o 3f546fcc27 Fix the subdirs logic so it works with GNU make 3.80
The previous fix which fixed the problem with GNU make 3.81 building
all of the library object files caused GNU make 3.80 fail because the
subdirectories (such as elfshared) were not getting created.  This fix
should allow the Makefiles to work with both GNU make 3.80 and GNU
make 3.81.
2006-03-10 21:39:40 -05:00
Theodore Ts'o ba5e38494e Add EXT_JOURNAL to the blkid tag of ext3 filesystems.
If the filesystem has an external journal, store the UUID of the
external journal in the tag EXT_JOURNAL.

If the filesystem type has changed, clear all the tags on the device,
not just a preset list of LABEL, UUID, TYPE, and SEC_TYPE.

Fix a bug so that blkid_set_tag will work correctly when freeing a tag
when the input name parameter comes from the tag that we are freeing.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-10 18:11:35 -05:00
Karel Zak 4db2f59a71 Add device-mapper support to the blkid library
On systems where is multi-path storage device is problem with duplicated
filesystems. The solution is select "the best" device. This is possible
by device-mapper library.

Short quotation from RH bugzilla:

With my patch, all dm devices remains in libblkid cache.

Only the top level dm devices are given high priority
and more appropriate node names (i.e. /dev/mapper/*) are used.

For example, if we have linear mapped dm device "ov1" over
dm device "disk1p3" which is multipath mapped to /dev/sdd3 and /dev/sdh3:
  # dmsetup.static ls --tree
  ov1 (253:5) <-- /dev/mapper/ov1 or /dev/dm-5
   `-disk1p3 (253:4) <-- /dev/mapper/disk1p3 or /dev/dm-4
      `-disk1 (253:0)
         |- (8:112) <-- /dev/sdh
         `- (8:48) <-- /dev/sdd

Original version of blkid will show:
  # ./orig/blkid -t LABEL=mpdisk1p3 -l
  /dev/sdd3: LABEL="mpdisk1p3" ... TYPE="ext3"

With my patch, blkid will show:
  # ./deptree/blkid -t LABEL=mpdisk1p3 -l
  /dev/mapper/ov1: LABEL="mpdisk1p3" ... TYPE="ext3"

In blkid cache, all devices are listed:

  # ./orig/blkid -t LABEL=mpdisk1p3
  /dev/sdd3: LABEL="mpdisk1p3" ... TYPE="ext3"
  /dev/sdh3: LABEL="mpdisk1p3" ... TYPE="ext3"
  /dev/dm-4: LABEL="mpdisk1p3" ... TYPE="ext3"
  /dev/dm-5: LABEL="mpdisk1p3" ... TYPE="ext3"

  # ./deptree/blkid -t LABEL=mpdisk1p3
  /dev/mapper/ov1: LABEL="mpdisk1p3" ... TYPE="ext3"
  /dev/sdd3: LABEL="mpdisk1p3" ... TYPE="ext3"
  /dev/sdh3: LABEL="mpdisk1p3" ... TYPE="ext3"
  /dev/dm-4: LABEL="mpdisk1p3" ... TYPE="ext3"

For more details see discussion on:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=156324

Addresses Red Hat Bug: #156324

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-08 14:17:28 -05:00
Theodore Ts'o 2adc320f01 Set FD_CLOEXEC on the /dev/random file descriptor used by libuuid
This avoids a fd leak across an execve() which was causing problems
for the LVM tools.

(Addresses Debian Bug: #345832)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-01-06 18:10:02 -05:00
Theodore Ts'o 02ef196210 Avoid needlessly recompilation of library objection files
Fixing the problem of parallel builds sometimes not creating the library
subdirectories caused library object files to get constantly recompiled.
Fix this by remaping how the Makefile subdirectories decide to create
the subdirectories.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-12-29 22:45:29 -05:00
Theodore Ts'o 438961210d Add missing parameter to error printf in blkid test program.
The blkid tag.c's test driver program had  a missing parameter to an 
error message printf.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-12-29 14:07:45 -05:00
Theodore Ts'o 3985754378 Use $(LDFLAGS) when generating shared libraries
Makefile.elf-lib, Makefile.solaris-lib: Add $(LDFLAGS) to the command line 
	argument when generating the shared library, to allow cross-compile 
	and other builds that might need to specify -L paths to needed 
	libraries.

Addresses Sourceforge Bug #1261549

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-12-10 22:33:25 -05:00
Theodore Ts'o 3ded50b37c Address parallel build problem in the library Makefiles
Add a dependency to make sure that the subdirectories are created before 
creating all of the object files.

Addresses Sourceforge Bug: #1261553

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-12-10 22:23:01 -05:00
Theodore Ts'o 9b9a780f5a Fix various gcc -Wall complaints.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-12-10 21:50:30 -05:00
Theodore Ts'o bc47952f10 Add ext2fs_read_bb_FILE test to confirm proper detection of invalid block #'s
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-12-10 14:37:10 -05:00
Theodore Ts'o 125e084cef Fix gcc compilation on sparc architectures in bitops.h
We no longer have the sparc assembly code in the header file any more, so we 
shouldn't set _EXT2_HAVE_AS_BITOPS_.  This would break compiles on the sparc
architectures when using gcc.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-11-21 00:04:31 -05:00
Theodore Ts'o a82a57025c Add missing #include for string.h to ext2fs.h to fix GCC 4.01 complaints
#include <string.h> is needed since the inline functions use memcpy().  
(Addresses Sourceforge Bug #1251062)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-11-14 14:49:15 -05:00
Theodore Ts'o 0d961040fe Fix writing external journals on big-endian machines
Fix a bug when writing an external journal device on an big
endian machine (such as a S/390), where when the number of
block groups is zero, we never end up writing out the
primary superblock at all.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-11-12 23:30:39 -05:00
Theodore Ts'o 32138187f0 Add fs->now to override time(0) in libext2fs
If fs->now is non-zero, use that as the time instead of the system
time when setting various filesystem fields (last modified time, last
write time, etc.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-09-24 20:14:51 -04:00
Theodore Ts'o 2f79e5193f Search the root directory of FAT filesystems for the label information
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-09-10 21:51:20 -04:00
Theodore Ts'o ca7498596f Generic blkid library cleanup
Change superblock and generic i/o functions to be more generic.  Clean
up interface to the probe function.  Fix memory leak.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-09-10 21:07:23 -04:00
Theodore Ts'o 1e5630abab Add a regression test suite for the blkid library
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-09-10 15:55:14 -04:00
Theodore Ts'o 45a3fa8738 Add support to extract basic iso9660 label information to the blkid library
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-09-10 15:46:57 -04:00
Theodore Ts'o bb626bcd54 Add support for detecting the reiser4 filesystem in the blkid library.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-09-10 11:48:38 -04:00
Theodore Ts'o 038d2bedaa Improve blkid's VFAT/FAT filesystem probe code
Collapse vfat and fat code and make it more paranoid when probing for
vat/fat filesystems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-09-07 12:14:53 -04:00
Theodore Ts'o 45d1d889b9 Remove unneeded probe.h header file in lib/blkid/resolve.c
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-09-07 12:12:21 -04:00
Karel Zak c4c740ff48 Improve VFAT detection to support filesystems w/o a magic string in the superblock
The current libblkid code expects that there's magic string in FAT super
block (like "FAT12", "FAT16", ...). It's very often right, but valid FAT
super block may be without magic string too :-(

The patch from attachment fix this problem. It's inspired by HAL and
Linux kernel.

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-09-06 08:13:35 -04:00
Karel Zak abaa11240a Add support for detecting software suspend partitions to blkid
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-09-06 06:42:49 -04:00
Karel Zak 05a6edf4fd Fix blkid library so that the cache validation notices ext2 to ext3 conversion
There's mistake in blkid ext2 detection code. The libblkid doesn't
check for journal when revalidate the cache information about an ext2
device.

        # rm -f /etc/blkid.tab

        # mkfs.ext2 /dev/loop0 &> /dev/null
        # blkid -s TYPE /dev/loop0
        /dev/loop0: TYPE="ext2"

        # mkfs.ext3 /dev/loop0 &> /dev/null
        # blkid -s TYPE /dev/loop0
        /dev/loop0: TYPE="ext2"

That bug doesn't appear when libblkid creates new cache and checks for
all possible filesystems, because it tries ext3 before ext2. BUT when
the library only revalidate the cache it first probes for old cached
filesystem (e.g. ext2).

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-09-06 06:26:45 -04:00
Matthias Andree 68a7f959c0 Fix compiler warnings about missing memcpy prototypes.
Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-09-06 05:59:52 -04:00
Theodore Ts'o 583d1f8328 Fix false positives from valgrind: prctl(PR_GET_DUMPABLE)
Pass in zero to the unusued arguments of prctl(PR_GET_DUMPABLE) to
avoid false positives from valgrind.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-07-25 11:36:43 -05:00
Theodore Ts'o 29af314d3f Check for a busy device when creating a journal.
In ext2fs_add_journal_inode() check for the case where the filesystem
appears to be unmounted, but the device is still apparently busy.
This can happen when the luser doesn't bother to mount /proc and has a
bogus /etc/mtab, but still wants to mount the filesystem before using
tune2fs(?!?).  Add a safety check to save him from his own stupidity,
at least on 2.6 kernels.  (Addresses Debian Bug #319002)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-07-19 15:04:22 -05:00
Theodore Ts'o 5bf9b4cd51 Fix com_err bug in compile_et: # of error messages can be wrong
Fixed bug where error messages using continuations wouldn't increment
the message count.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-07-19 08:24:59 -05:00
Andreas Dilger 9b7d811dda This patch adds a check to use fstat or fstat64 in getsize.c if the
target is a regular file, instead of doing binary searching.  It also
fixes a couple of cases where a file descriptor is leaked in the
ext2fs_getsize() routine on error.

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
2005-07-09 22:06:59 -05:00
Theodore Ts'o 1f965c8d96 Update for e2fsprogs 1.38 release. 2005-06-30 20:06:45 -04:00
Theodore Ts'o 80af12e180 Change the function prototypes of ext2fs_set_bit, ext2fs_clear_bit, and
ext2fs_test_bit to take an unsigned int for the bit number.  Negative
bit numbers were never allowed (and didn't make any sense), so this should
be a safe change.  This is needed to allow safe use of block numbers
greater than or equal to 2**31.
2005-06-30 19:40:18 -04:00
Theodore Ts'o 55080a7637 Fix blkid's debugging/TEST_PROGRAM code so that it is sufficiently
standalone that "make check" will compile without errors even  
when configure "--enable-blkid-debug" is not specified.
2005-06-27 13:54:08 -04:00
Stephen Tweedie 39c191f5b3 ext2fs_resize_mem() is suffering from C99 strict type aliasing problems.
The trouble is that it is modifying pointers in place, but doing so via
"void *" types which alias the pointers passed in (which are typically
pointers to a struct.)  The inline ext2fs_resize_mem() code may update
the pointer, but the caller is not required to reload the old value it
may have cached in a register, according to the type aliasing rules.

This is causing the caller to dereference the old pointer when compiled
with -O2, resulting in reproducible SEGV, on at least one ia64
configuration.

The compiler *is* required to reload if it sees an update to a dereferenced
char value, though, as chars are defined to alias anything; and memcpy()
is defined to operate on chars.  So using memcpy() to copy the pointer
values is guaranteed to force the caller to reload.  This has been 
verified to fix the problem in practice.

Fixes Red Hat bug #161183.
2005-06-27 11:47:21 -04:00
Theodore Ts'o d51b819e54 error_message.c, init_et.c: Segregate error tables registered
via add_error_table() and the other dynamic methods from
	the ones allocated via initialize_xxx_error_table() so
	that we won't fail even for error tables created using old
	versions of compile_et.  Thanks to Nalin Dahyabhai for
	this suggested patch.
2005-06-20 17:59:06 -04:00
Theodore Ts'o e7d32fcb56 et_c.awk: Use a dynamically allocated structure in
initialize_xxx_error_table(), to prevent segfaults if an
	old library calls initialize_xxx_error_table, and another
	library/application calls add_error_table() on the same
	error table, and then calls remove_error_table().
	(Addresses Sourcefroge Bug #1150146)
2005-06-20 16:24:04 -04:00
Theodore Ts'o e37fbf1c19 getsectsize.c (BLKSSZGET): Clean up test for when to manually
define the BLKSSZGET ioctl.
2005-06-19 23:11:09 -04:00
Theodore Ts'o 7d9adefed8 Makefile.in: Add an include path specifier when building
tst_ostype so that "make check" will build correctly on
	systems without the include files from e2fsprogs installed
	in the system include directory.
2005-06-16 18:41:06 -04:00
Theodore Ts'o 2fa8f37fff On Linux 2.6 systems, mke2fs and badblocks will check to see whether
the filesystem appears to be busy; if so, the programs will print an
error message and abort.   (Addresses Debian Bug #308594).
2005-06-05 16:05:22 -04:00
Theodore Ts'o 3af0a45628 Fix bug in the secure getenv function so that the ss library will corrently
honor the PAGER and SS_READLINE_PATH environtment variables, and the 
test_io io_manager in the ext2fs library honors the TEST_IO_LOGFILE,
TEST_IO_FLAGS, TEST_IO_BLOCK, and TEST_IO_READ_ABORT environment variables.
2005-05-08 02:15:02 -04:00
Theodore Ts'o ed6acfa337 Add a new option to the blkid program, -l, which will more efficiently search
for a single device.

Add a new function to the blkid library, blkid_probe_all_new().

Optimize blkid_find_dev_with_tag() so that extraneous device validation are
skipped.  (Makes a difference for system with a large number of disks).
2005-05-07 17:06:27 -04:00
Theodore Ts'o 12b3c8ec1d Fix gcc -Wall nits in the blkid library. 2005-05-07 14:38:10 -04:00
Theodore Ts'o 78c7d0efae Clean up the debugging code in the blkid library so that we don't use
the inline functions DEB_DUMP_* and instead use the private functions 
blkid_debug_dump_*().
2005-05-07 14:22:38 -04:00
Theodore Ts'o c37543df2f Add new two new functions to the blkid library: blkid_dev_set_search(), and
blkid_dev_has_tag(), and change the blkid program to take advantage of these
functions.
2005-05-07 13:32:47 -04:00
Theodore Ts'o 153b4495c1 If the .c and .h file already exist, and they have not changed, use the
original versions of the files, so as to avoid rebuilding files when not
necessary.  Also fixes a potential SMP/Parallel build problem when one 
make process runs compile_et to generate the .h file, and a partially
generated .c file is compiled by another make process.  (Addresses
Sourceforge Bug: #1157933)
2005-05-06 09:42:34 -04:00
Theodore Ts'o 75e93ab097 Update "make depend" information. Fixes SMP parallel build problem.
(Addresses Sourceforge Bug: #1157933)
2005-05-06 09:37:58 -04:00
Theodore Ts'o 9be5ba91b8 Fix build of tst_ostype when doing a "make check" in lib/e2p; it was missing
CFLAGS in the compile rule.  (Addresses Sourceforge Bug: #1180572)
2005-05-06 00:38:26 -04:00
Theodore Ts'o 4c4e3f7843 Fix libblkid's magic number recognition for the cramfs filesystem,
and add support to pull out the label for cramfs filesystems.  
Thanks to Karel Zak (kzak at redhat.com) for the patch.
2005-05-05 18:06:04 -04:00
Theodore Ts'o 09f3eba28a Fix typo so that we actually ignore environment variables when gid != egid. 2005-04-16 13:56:03 -04:00
Theodore Ts'o b7e4eef304 ls.c: Add stdlib.h header file since list_super2() uses the
free() function.
2005-04-09 01:22:09 -04:00
Theodore Ts'o b1ae119729 Add missing return values in error return cases in the ext2fs library.
(Otherwise we return garbage instead of the error code.)
2005-04-09 01:21:21 -04:00
Theodore Ts'o 762c7c6510 Add paranoia checks into the blkid, ext2fs, and ss libraries to ignore
environment variables if the libraries are called from setuid or setguid 
programs, or if kernel believes that the process is not eligible to create
a core dump.  In addition, if the libc has __secure_getenv(), use it so that
the libc can also do any additional limitations regarding when libraries can
trust environment variables (i.e., to integrate with systems like SELinux 
and Posix capabilities).
2005-04-06 14:44:16 -04:00
Theodore Ts'o 813b901d41 ostype.c (e2p_os2string): Check to make sure malloc() is
successful before attempting to copy into it.  Add
	#include of stdlib.h to fix a core dump bug on the IA64
	architecture.  (Addresses Debian Bug #302200)
2005-03-31 00:01:33 -05:00
Theodore Ts'o fd4b28efd3 Update for the e2fsprogs 1.37 release. 2005-03-21 22:37:03 -05:00
Theodore Ts'o 65ffef3689 Ignore the BLKID_FILE environment variable if blkid_get_cache() is
called from a setuid program.
2005-03-21 22:13:32 -05:00
Theodore Ts'o cebe48a1ec Integrate code from Alex Thomas at Clusterfs to check extended attributes
stored in inodes into e2fsck.

There are a number of bug fixes and enhancements over the original lustre fsck
BK repository.  The biggest one is that this extended attribute values must
be aligned on 4-byte boundaries.
2005-03-21 13:15:45 -05:00