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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
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>
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>
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>
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>
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>
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>
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>
#include <string.h> is needed since the inline functions use memcpy().
(Addresses Sourceforge Bug #1251062)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
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>
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>
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>
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>
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>
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>
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>
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.
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.
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.
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)
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.
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).
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)
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).
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.
a new inode we make sure that the extra information in the inode (any extra
fields in a large inode and any ea-in-inode information) is cleared. This
can happen when e2fsck creates a new root inode or a new lost+found directory,
or when the user uses the debugfs write, mknod, or mkdir commands. Otherwise,
the newly create inode could inherit garbage (or old EA information) from
a previously deleted inode.
than the GCC 3.4 compile code and triggers compiler warnings on
sparc64. Thanks to Matthias Andree for his analysis and suggestions.
(Addresses Debian Bug #232326)
Remove support for the --enable-old-bitops configure option which
was only for very old sparc systems.
consistently when the blkid cache file is explicitly set
to /dev/null. (Addresses Debian Bug #292425)
Also expose blkid_verify() as a public function to the blkid library.
enough of the partition that the blkid probes can get
confused. Do the NTFS test first to deal with this
Windows misfeature. (Addresses Debian Bug #291990)
information from swap partitions.
Also make sure that if a partition has a label removed, that the label is
removed form the blkid cache as well.
Add support for detecting 32k and 64k pagesize swap files.
unspecified, to avoid doing something surprising (such as unconditionally
deleting the first directory entry). Directory entries are now deleted
by coalescing them with the previous directory entry if possible, to
avoid directory fragmentation. This is not an issue with the e2fsprogs suite,
but may be a problem for some of the users of libext2fs, such as e2tools.
that mount will try to use the vfat filesystem. (Addresses Debian bug #287455)
Similarly, the blkid library will now return an ext3 type for ext 2/3
filesystems that have the journal capability set.
We allow files to be probed by the blkid library, to make it easier to
test the library. However, we also added safety checks to avoid saving
relative pathnames to blkid.tab, and probe_one() will only check block device
files.
has its own copy of the orig_super data structure. (This
is a better way of fixing a double-free problem in
resize2fs which Fedora attempted to fix in
e2fsprogs-1.35-double_free.patch. Addresses Red Hat
Bugzilla #132707.)
byte-swapping options to e2fsck. This was the cause of some hard to
reproduce problems that had been reported in the past, and which the
resize_inode changes tickled in a much more repeatable fashion.
any debugging statements from within library code (always a bad idea), and
ext2fs_create_resize_inode() will return a proper error code if the
resize inode is corrupt, instead of returning -1.
res_gdt.c (list_backups), closefs.c (ext2fs_bg_has_super),
ext2fs.h: Move ext2fs_list_backups() to res_gdt.c, and
ext2fs_bg_has_super() back to closefs.c. There's no
reason for the new file, since list_backups() isn't being
used by any other functions, and can be made static, and
all users of the ext2fs filesystem will have to call
ext2fs_close() anyway.
correctly.
Update Makefile dependencies.
Update "make depend" production so that it filters out comments
inserted by newer gcc compilers.
Remove sync from e2fsck's "make all" target.
example, /tmp/test.img?offset=1024. Multiple options can separated using
the & character, although at the moment the only option implemented is
the offset option in the unix_io layer.
Change the maximum allowable blocksize to be 65536. This allows e2fsck to
check filesystems with a pagesize of 65536, and mke2fs to accept -b 65536.
Of course such a filesystem will not currently work on a Linux/x86 system,
at least not as of this writing!
and lib/ext2fs/getsize.c
In lib/blkid/getsize.c, include <sys/disk.h> if present since
this is where the DIOCGMEDIASIZE ioctl is defined on FreeBSD.
(Addresses Debian Bug #264630)
to deal with lame glibc's that define this function
without actually implementing it. Can you say "attractive
nuisance", boys and girls? I knew you could! (Thanks to
Pavel Troller for reporting this braindamage.)
written last, and only after other I/O has been flushed to
disk. Thanks to Junfeng Yang from the Stanford
Metacompilation group for pointing a potential ordering
constraint problem if we don't write things out in the
right order.
or writes to a particular block. The block is specified by
TEST_IO_BLOCK environment variable, and the read/write count
by the TEST_IO_READ_ABORT and TEST_IO_WRITE_ABORT environment
variables. The block data is now only dumped if the 0x10 bit
is set in TEST_IO_FLAGS.
some generated files, by having subst update the modtime on these
files even when the generated file hasn't changed. We do this with
generated files that do not have any downstream dependencies.
with permission from Andreas Dilger (the original author of the man
pages), email dated Mon, 29 Mar 2004 23:11:53 -0700, Message-ID
20040330061153.GD1177@schnapps.adilger.int.