Previously we used a hard-coded test where for the Alpha and the IA64,
we used lseek instead of llseek(). Generalize this to whenver
sizeof(long) is the same as sizeof(long long).
It turns out this fixes a FTBFS problem on the x86_64 for Debian,
since dietlibc doesn't provide llseek() on that architecture.
Addresses-Debian-Bug: #459614
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
/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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>