When looking for the start of the hugefile range, the 'next' variable
is incorrectly decremented. If we happened to find a single free
block, the effect of this decrement is that blk == next, which means
that we never modify the loop control variable, so get_start_block
never returns.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
When we use ext2fs_open_inode_scan() to iterate inodes and finish
jobs, we also need a ext2fs_close_inode_scan(scan) operation, but in
inode_scan_and_fix(), we forgot to call it, fix this error.
Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If the user doesn't provide any arguments, the guard fails to run and
the whole thing segfaults on ext2fs_open2(). Don't do that.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The metadata_csum feature (really, the journal checksum disk format)
didn't stabilize until the 3.18 kernel, at which point the companion
journal_csum feature was turned on by default if metadata_csum was
enabled. Therefore, warn the user if they try to create such a
filesystem on a pre-3.18 kernel.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Don't let users change metadata_csum on a mounted filesystem because
there's no way to tell the kernel to turn on the feature; there's no
way to prevent the kernel from rewriting on-disk structures while
tune2fs is also rewriting them; and there's no way to tell the kernel
to reload them after tune2fs is finished.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
When enabling checksums, tune2fs naively rewrites every extent in the
entire tree! This is unnecessary since we only need to rewrite each
extent tree block; therefore, only rewrite the extent if it's the
first one in an internal extent tree block.
Also, don't bother iterating the extent tree when clearing checksums.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If we get as far as calling libmagic, return the correct error code so
that mkfs asks for confirmation if libmagic finds something and
doesn't ask if nothing is found.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Exercise fuzzed metadata blocks more aggressively by expanding up to
50000 files (instead of just test.1, which might not hit anything).
Fix a typo while we're at it.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Debugfs (unlike all of the other programs in e2fsprogs) is not set up
to use translated strings. So when building misc/plausible.c for
debugfs, we need to disable NLS.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Convert all call sites that write zero blocks to disk to use
ext2fs_zero_blocks2() since it can use Linux's zero out feature to do
the writes more quickly. Reclaim the zero buffer at freefs time and
make the write-zeroes fallback use a larger buffer.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The man page description of the file system size thresholds used by
mke2fs to select a usage type when not otherwise specified by the -T
switch does not match the code.
Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If magic.h is not present, there will be unresolved references to the magic_t
type in plausible.c. Fix that by moving the protecting #ifdef directive.
Signed-off-by: Artemiy Volkov <artemiyv@acm.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The existing error message can be made more helpful by more clearly
implying the attempt to make a file system with undersized inodes is
failing and suggesting a corrective action.
Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
large_file (> 2G) support has been around since at least kernel 2.4;
mkfs of any sufficiently large filesystem sets it "accidentally"
when the resize inode exceeds 2G. This leaves very small
filesystems lacking the feature, which potentially changes
their behavior & codepaths the first time a > 2G file gets
written.
There's really no reason to be making fresh filesystems which
strive to keep compatibility with 10 year old kernels; just
enable large_file at mkfs time. This is particularly obvious
for ext4 fielsystems, which set huge_file by default, but not
necessarily large_file.
If old-kernel compatibility is desired, mke2fs.conf can be
modified locally to remove the feature.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This prevents the libmagic library from being a hard dependency; if
it's not there, we can simply do without it.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: Darrick J. Wong <darrick.wong@oracle.com>
If we're using check_plausibility() to try to identify something that
obviously isn't an ext* filesystem and libblkid doesn't know what it
is, try libmagic instead.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If any of these utilities detect a bad superblock magic, call
check_plausibility to see if blkid can identify the passed-in argument
as something else (xfs, partition, etc.) in the hopes of catching a
user error.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Move check_plausibility() into a separate file so that various
programs can use it without having to declare useless global variables
that the util.c functions seem to require.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Spit out just the group descriptor data in a machine readable format.
This is most useful for testing and scripting purposes.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The create_inode.h header file is pulled in by debugfs, which is not
internationalized. It had no business pulling in nls-enable.h; that
header file should only be used in specific .c files that support
internationalization.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Define the KERNEL_VERSION macro explicitly instead of using
<linux/version.h>, since it's not available when using dietlibc.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Erase s_jnl_blocks when removing an external journal, or adding an
internal journal online. We can't add the backup for the internal
journal because we have no good way to get the indirect block or ETB
addresses, so the best we can do is hope that the user runs e2fsck,
which will correct that. We are motivated to erase during external
journal removal to state emphatically that there's no journal.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: thomas_reardon@hotmail.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Enhance disable_uninit_bg() to return error codes -- if something goes
wrong, we want to flag the FS as needing a fsck and exit. Mr. Reardon
discovered that tune2fs -O ^metadata_csum on a FS with a corrupt
bitmap would leave the FS in a weird state.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
When we're removing the internal journal (broken journal, turning it
off, or adding an external journal), zero s_jnl_blocks so that they
can't be picked up by accident later.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Cc: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Display the feature flags of an external journal.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Spit out a more specific error if someone tries to modify an
external journal device.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Enable mke2fs to create an external journal device with a superblock
checksum.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Cc: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If there aren't enough blocks in the FS to allocate all of the
hugefiles, return ENOSPC, not ENOMEM.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
It turns out that there are some serious problems with the on-disk
format of journal checksum v2. The foremost is that the function to
calculate descriptor tag size returns sizes that are too big. This
causes alignment issues on some architectures and is compounded by the
fact that some parts of jbd2 use the structure size (incorrectly) to
determine the presence of a 64bit journal instead of checking the
feature flags. These errors regrettably lead to the journal
corruption reported by Mr. Reardon.
Therefore, introduce journal checksum v3, which enlarges the
descriptor block tag format to allow for full 32-bit checksums of
journal blocks, fix the journal tag function to return the correct
sizes, and fix the jbd2 recovery code to use feature flags to
determine 64bitness.
Add a few function helpers so we don't have to open-code quite so
many pieces.
Switching to a 16-byte block size was found to increase journal size
overhead by a maximum of 0.1%, to convert a 32-bit journal with no
checksumming to a 32-bit journal with checksum v3 enabled.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If the starting partition offset is incompatible with the bigalloc
cluster size, complain and exit, instead of creating a file which
would have a logical to physical block mapping which breaks the
cluster alignment requirement.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The chattr(1) manpage now refers users to filesystem-specific
manpages for details on supported attributes, so add those to
ext4.5.
I've left out oddities like being able to set the compressed
or no-tail-packing flags, or setting data journaling on ext2.
That behavior seems like a bug, not a feature.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If the user does not specify the file system size, and the file does
not exist, give an error message like this:
The file /tmp/foo.img does not exist and no size was specified.
instead of this:
Creating regular file /tmp/foo.img
mke2fs: Device size reported to be zero. Invalid partition specified, or
partition table wasn't reread after running fdisk, due to
a modified partition being busy and in use. You may need to reboot
to re-read your partition table.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Select pwrite64 or pwrite depending on what autoconf finds. This
makes e2fuzz find a suitable pwrite variant regardless of platform.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The extent count calculation works correctly with the FIBMAP ioctl in
verbose (-v) mode, but without the verbose option, the calculation was
broken because we weren't properly updating the fm_ext data structures
in non-verbose mode.
Addresses-Launchpad-Bug: #1356496
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Fix clang warnings about forgotten header files, dead code, and pwrite
support on OS X. The unistd.h inclusion also fixes a parameter
truncation bug on i386.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Warn the user to run e2fsck if the superblock or bitmaps fails
checksum verification.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Fix the handling of 'fs' when closing the FS fails so that we don't
dereference a NULL pointer. Adapt to use ext2fs_close_free while
we're at it.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Fixes-Coverity-Bug: 1229241
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
When do_freefrag() is called from debugfs, the value of optind is
not reset. Rectify that by calling reset_getopt().
Signed-off-by: Artemiy Volkov <artemiyv@acm.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Print filefrag_fiemap() error message to stderr instead of stdout.
Only call ioctl(EXT3_IOC_GETFLAGS) for ext{2,3,4} filesystems to
decide if the ext2 indirect block allocation heuristic shold be used.
Properly handle the the force_bmap (-B) option.
Exit with a positive error number instead of a negative one.
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Quiet warnings about signed vs. unsigned character mismatch.
Use __u8 for storing UUIDs instead of char to match the superblock
s_uuid field.
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This bug was introduced by commit 7dfefaf413 ("tune2fs: update
journal super block when changing UUID for fs").
Fixes-Coverity-Bug: 1229243
Reported-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Using -U option you can change the UUID for fs, however it will not work
for journal device, since it have a copy of this UUID inside jsb (i.e.
journal super block). So copy UUID on change into that block.
Here is the initial thread:
http://comments.gmane.org/gmane.comp.file-systems.ext4/44532
You can reproduce this by executing following commands:
$ fallocate -l100M /tmp/dev
$ fallocate -l100M /tmp/journal
$ sudo /sbin/losetup /dev/loop1 /tmp/dev
$ sudo /sbin/losetup /dev/loop0 /tmp/journal
$ mke2fs -O journal_dev /tmp/journal
$ tune2fs -U da1f2ed0-60f6-aaaa-92fd-738701418523 /tmp/journal
$ sudo mke2fs -t ext4 -J device=/dev/loop0 /dev/loop1
$ dumpe2fs -h /tmp/dev | fgrep UUID
dumpe2fs 1.43-WIP (18-May-2014)
Filesystem UUID: 8a776be9-12eb-411f-8e88-b873575ecfb6
Journal UUID: e3d02151-e776-4865-af25-aecb7291e8e5
$ sudo e2fsck /dev/vdc
e2fsck 1.43-WIP (18-May-2014)
External journal does not support this filesystem
/dev/loop1: ********** WARNING: Filesystem still has errors **********
Reported-by: Chin Tzung Cheng <chintzung@gmail.com>
Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Use EXT2_MIN_BLOCK_SIZE, JFS_MIN_JOURNAL_BLOCKS, SUPERBLOCK_SIZE, and
SUPERBLOCK_OFFSET instead of hardcoded 1024 when it is okay, and also
add a helper ext2fs_journal_sb_start() that will return start of
journal sb with special case for fs with 1k block size.
Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
When creating a file system using a source directory, also copy any extended
attributes that have been set.
[ Add configure tests for Linux-specific xattr syscalls and add fallback
when compiling on non-Linux systems. --tytso ]
Signed-off-by: Ross Burton <ross.burton@intel.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
ioctl(FIGETBSZ) was used to get block size earlier but 2508eaa7
(filefrag: improvements to filefrag FIEMAP handling) moved to fstatfs
f_bsize which doesn't work well for many files systems.
Block size returned using fstatfs isn't block size but "optimal
transfer block size" as per man page. Even stat st_blksize is
"preferred I/O block size" and in may file systems it may even vary
from file to file (POSIX). This patch changes filefrag to use
FIGETBSZ preferentially over f_bsize.
[ Modified by tytso to add the fallback to f_bsize if FIGETBSZ fails
for some reason ]
Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
29758d2 broke -B option which is useful for filesystems not supporting
FIEMAP. Also, fix extents calculation for -B which is broken since
2508eaa7.
Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Provide an API to set i_size in an inode and take care of all required
feature flag modifications. Refactor the code to use this new
function.
[ Moved the function to lib/ext2fs/blk_num.c, which is the rest of
these sorts of functions live, and renamed it to be
ext2fs_inode_size_set() instead of ext2fs_inode_set_size() to be
consistent with the other functions in in blk_num.c -- tytso ]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
There are a number of places where we need convert groups to blocks or
clusters by multiply the groups by blocks/clusters per group.
Unfortunately, both quantities are 32-bit, but the result needs to be
64-bit, and very often the cast to 64-bit gets lost.
Fix this by adding new macros, EXT2_GROUPS_TO_BLOCKS() and
EXT2_GROUPS_TO_CLUSTERS().
This should fix a bug where resizing a 64bit file system can result in
calculate_minimum_resize_size() looping forever.
Addresses-Launchpad-Bug: #1321958
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Fix a few warnings about unused and uninitialized variables.
Also fix util/subst.c to include <sys/time.h> to avoid using
undeclared functions gettimeofday() and futimes().
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Creates a program that fuzzes only the metadata blocks (or optionally
all in-use blocks) of an ext* filesystem. There's also a script to
automate fuzz testing of the kernel and e2fsck in a loop.
[ Modified by tytso to add e2fuzz to the clean makefile rule ]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Port tune2fs' -e flag to mke2fs so that we can set error behavior at
format time, and introduce the equivalent errors= setting into
mke2fs.conf.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The third argument to strncat is the maximum number of characters to
copy out of the second argument; it is not the maximum length of the
first argument.
Therefore, code in a check just in case we ever find a /sys/block/X
path long enough to hit the end of the buffer. FWIW the longest path
I could find on my machine was 133 bytes.
Fixes-Coverity-Bug: 1252003
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Currently, e4defrag avoids increasing file fragmentation by comparing
the number of runs of physical extents of both the original and the
donor files. Unfortunately, there is a bug in the routine that counts
physical extents, since it doesn't look at the logical block offsets
of the extents. Therefore, a file whose blocks were allocated in
reverse order will be seen as only having one big physical extent, and
therefore will not be defragmented.
Fix the counting routine to consider logical extent offset so that we
defragment backwards-allocated files. This could be problematic if we
ever gain the ability to lay out logically sparse extents in a
physically contiguous manner, but presumably one wouldn't call defrag
on such a file.
Reported-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
There were other protections which would prevent a buffer overflow
from happening, but we should fix this nevertheless.
Addresses-Coverity-Bug: #1225003
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The single quote character must not be in the first character in a
line, or else it can get mistaken as a macro call.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Add the mke2fs.conf configuration option which causes the hugefiles to
be aligned to the beginning of the disk. This is important if the the
reason for aligning the hugefiles is to support hard-drive specific
features such as Shingled Magnetic Recording (SMR).
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
We can set flex_bg count only up to 2^30 with profile
because get_int_from_profile can handle it to 2^31-1.
Add get_uint_from_profile to read unsigned int value
so that mke2fs with profile can handle up to 2^31 flex_bg same as -G option.
Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
mke2fs -G option allows root user to set flex_bg count (power of 2).
However ext4 has bad metadata layout if we specify more than or equal to
2^32 to mke2fs -G, because of the 32bit shift operation
in ext2fs_allocate_group_table().
And the maximum block group count of ext4 is 2^32 -1 (ext4_group_t
s_groups_count), so diallow more than 2^32 flex_bg count.
Steps to reproduce:
# mke2fs -t ext4 -G 4294967296 DEV
# dumpe2fs DEV
...
Flex block group size: 1 <----- flex_bg is 1!
...
Group 0: (Blocks 0-32767)
Checksum 0x4afd, unused inodes 7541
Primary superblock at 0, Group descriptors at 1-1
Reserved GDT blocks at 2-59
Block bitmap at 60 (+60), Inode bitmap at 61 (+61)
Inode table at 62-533 (+62)
32228 free blocks, 7541 free inodes, 2 directories, 7541 unused inodes
Free blocks: 540-32767
Free inodes: 12-7552
Group 1: (Blocks 32768-65535) [INODE_UNINIT]
Checksum 0xc890, unused inodes 7552
Backup superblock at 32768, Group descriptors at 32769-32769
Reserved GDT blocks at 32770-32827
Block bitmap at 32828 (+60), Inode bitmap at 32829 (+61)
Inode table at 32830-33301 (+62)
32234 free blocks, 7552 free inodes, 0 directories, 7552 unused inodes
Free blocks: 33302-65535
Free inodes: 7553-15104
...
Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: "Darrick J. Wong" <darrick.wong@oracle.com>
Currently is used did not specified lazy_itable_init option we rely on
information from ext4 module exported via sysfs interface. However if
the ext4 module is not loaded it will not be enabled even though kernel
might support it.
With this commit we set the default according to the kernel version,
however we still allow it to be set manually via extended option or be
enabled in case that ext4 module advertise that it supports this
feature.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Currently there are many uses of ext2fs_close() which might be wrong.
First of all ext2fs_close() does not set the ext2_filsys pointer to NULL
so the caller is responsible for clearing it, however there are some
cases there we do not do it.
Second of all very small number of users of ext2fs_close() actually
check the return value. If there is a problem in ext2fs_close() it will
not even free the ext2_filsys structure, but majority of users expect it
to do so.
To fix both problems this commit introduces a new helper
ext2fs_close_free() which will not only check for the return value and
free the ext2_filsys structure if the call to ext2fs_close2() failed,
but it will also set the ext2_filsys pointer to NULL.
Replace every use of ext2fs_close() in e2fsprogs tools with
ext2fs_close_free() - there is no real reason to keep using
ext2fs_close().
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
This is a straight cut and paste from the util-linux
mount manpage to ext4.5 (with commented-out lines
removed).
It's pretty much impossible for util-linux to keep up
with every filesystem out there, and Karel has more than
once expressed a wish that mount options move into fs-specific
manpages.
So, here we go.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The chattr(1) manpage and chattr usage() output were missing some flags.
Add those, and make some other minor cosmetic fixes.
(I've left out the 'B' (EXT2_COMPRBLK_FL) flag, because
it's not actually used anywhere, and I can't figure out
how it differs from 'c' (EXT2_COMPR_FL))
Also, because the matrix of filesystems & flags is quite large,
refer to filesystem-specific manpages for detailed discussion
of flags supported by those filesystems, rather than trying to
cover it all in this manpage. I'll send those manpage
updates to the appropriate lists a bit later.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
The flags described in chattr usage() and the chattr(1) manpage
were in semi-random order, which makes it hard to ascertain
which flags might be missing or undocumented, and to locate
flags within the manpage.
Re-order the list of flags in alphanumeric order, and do
the same for the flag descriptions in the body of the manpage.
There should be no content changes here, just reordering
for consistency.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
It's a bit strange to accept revision levels higher than
the code creating the filesystem can understand, so don't
allow it.
At least the kernel will mount the fs readonly if it's too
high, but no other utility will touch it, so you can't
fix the error.
Just reject anything > EXT2_MAX_SUPP_REV at mkfs time.
Signed-off-by: Frank Sorenson <fsorenso@redhat.com>
[sandeen@redhat.com: Add more verbose commit log]
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Quiet a couple of build warnings in tst_libext2fs.c
Add missing unistd.h header for misc/util.c.
Ignore generated files for lib/ext2fs/tst_libext2fs and intl/ files.
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
29758d2 filefrag: exit with error code if an error is hit
introduced a couple errors; in one case it missed returning
a value, and possibly picked up errno from (unchecked) close(),
and in the other used a test where it needed an
assignment. So capture the error, move perror() directly
after the failed call in both cases, and fix the assignment.
Also fix a precedence problem with:
if (fe_flags & mask == 0)
which is equivalent to:
if (fe_flags & (mask == 0))
but we need:
if ((fe_flags & mask) == 0)
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Fix compile warnings found on the master branch when using LLVM.
- Add missing format string when using the libintl _() macro
- include <limits.h> header to get PATH_MAX definition
- fix format vs. variable mismatches
- add header block for create_inode.c file
- remove use of bzero(), use ext2fs_get_memzero() instead
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Fix various small resource leaks and error code handling issues that
Coverity pointed out.
Fixes-Coverity-Bugs: 1215250, 1193379, 119194[2-4], 1049160
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If an error is hit during filefrag operation, it will continue to run
(if multiple files are specified on the command-line), but will exit
with a non-zero value, so that callers can determine that some error
was hit.
Clean up the printing of FIEMAP flags and print some newer flags that
were missing. Also print unknown flags as hex values.
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Fix name clash in do_mknod_internal() due to local variables named
"major" and "minor" shadowing identical macro names.
Also, no need to set the major and minor device for a FIFO inode.
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
The commit:
802146c mke2fs: create a regular file if necessary
caused a regression on 32-bit machines; the open() fails if
the file size is > 4G.
Using ext2fs_open_file() fixes it.
Addresses-Red-Hat-Bugzilla: #1099892
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
When we're creating a fs with metadata blocks packed at the beginning
(packed_meta_blocks=1 in mke2fs.conf), set the group descriptor
checksum or else we create DOA filesystems with checksum errors.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
We no longer need to reference https://ext4.wiki.kernel.org/index.php/Quota
since we've fixed the nasty bugs associated with e2fsck and the quota
feature. The wiki page will be updated once we've done a release that
includes these fixes indicated the verison which these problems have
been fixed.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Aditya Kali <adityakali@google.com>
There are interfaces that are used by mke2fs.c and tune2fs.c which are
in quotaio.h, and some future changes will be much simpler if we can
combine the two header files together. Also the guard #ifdef for
mkquota.h was incorrect, which caused problems when both header files
needed to be included.
Also remove quota.pc and installation rules for libquota, since this
library is never going to be something that we can export externally
anyway. Eventually we'll want to clean up the interfaces and move the
external publishable interfaces to the libext2fs library, and then
rename what's left from libquota.a to libsupport.a for internal use
only.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Aditya Kali <adityakali@google.com>
The combination of 128-byte inodes and inline_data is silly, since
there's no room in the inode table. Unfortunately, if neither
mke2fs.conf nor the mkfs command line options specify an inode size,
the default inode size is set to 128 bytes (by libext2fs) and the
warning isn't printed. Therefore, always do the check-and-warning.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Since the code to copy-in a socket when creating a filesystem is
fairly simple, just do it here.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Fix various small resource leaks and error code handling issues that
Coverity pointed out.
Fixes-Coverity-Bugs: 11919{39-45}, 1174118, 1049160, 1049144
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Fix some minor bugs relating to passing CFLAGS to cppcheck, and
package the cppcheck output into nicer looking reports.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This supercedes the "whole disk" check, since it does a better job and
there are times when it is quite legitimate to want to use the whole
disk.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The basic idea is to provide a bit more context in this situation:
% ./misc/mke2fs -t ext4 /dev/sdc3
mke2fs 1.42.9 (4-Feb-2014)
/dev/sdc3 contains a ext4 file system
Proceed anyway? (y,n)
... by adding this bit of context:
% ./misc/mke2fs -t ext4 /dev/sdc3
mke2fs 1.42.9 (4-Feb-2014)
/dev/sdc3 contains a ext4 file system
last mounted on /SOX-backups on Mon May 5 08:59:53 2014
Proceed anyway? (y,n)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
We've added the ability to automatically recreate a file if it doesn't
exist prior to creating the file system, since this is often used (for
example) when managing file system images for use in virtual machines.
We should at least notify the user that this is going on to avoid
surprises in the case of misspelled device/file names.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Filefrag doesn't catch and print the shared extent flag. Add this for
users of filefrag on file systems with shared extents (such as btrfs).
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Warn the system administrator if there is an existing file system on
the block device, and give the administrator an opportunity to abort
the mkfs operation.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If mke2fs needs to ask the user for permission, and the user doesn't
type anything the specified delay in the /etc/mke2fs.conf file,
proceed as if the user had said yes. The default is to do what we
currently do, which is to wait until the user answers the question one
way or the other.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Don't ask the user if it's OK that a regular file is smaller than the
requested size. This test only makes sense if we are creating the
file system on a block device. This allow users to not need to
manually answer the "proceed?" question when creating a file system
backed by a simple file.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Move the call to proceed_question() from check_plausibility() to its
caller. This allows more fine grained control by mke2fs about when it
might want to call check_plausibility().
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Very often people are creating file systems using regular files, so we
shouldn't ask the user to confirm using the proceed question.
Otherwise it encourages users to use the -F flag, which is a bad
thing.
We do need to continue to check if the external journal device is a
block device.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Fix various unused variable and use-uninitialized warnings.
Add generated files into .gitignore.
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
We need return retval when "mke2fs -d" failed, otherwise the "$?"
would be 0 which is misleading.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
This allows e4defrag to work with 64-bit and bigalloc file systems.
Signed-off-by: Jon Ernst <jonernst07@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
When calling populate_fs, the map for hardlink detection is not
cleaned up between populate_fs invocations, which could lead to
unexpected results if anyone calls populate_fs twice in the same
client program). This doesn't happen right now, but we might as well
clean it up.
The detctor fails if the external directory crosses mountpoints,
so fix that too.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Since create_inode.c is shared between debugfs and mke2fs, don't
spread debugfs internal state into mke2fs.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Fix a couple of small style issues in the create_inode files.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
do_write_internal returns errno when ext2 library calls fail; since
errno only reflects the outcome of the last C library call, this will
result in confused callers. Eliminate the naked return since
this results in an undefined return value.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Update the manual for the -d option
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Create the inode and save the native inode number when we meet the hard
link (st_nlink > 1) at the first time, use ext2fs_link() to link the
name to the target inode number when we meet the same native inode
number again.
This algorithm is referred this from the genext2fs.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This option is used for adding the files from a given directory (the
root-directory) to the filesystem, it is similiar to genext2fs, but
genext2fs doesn't fully support ext4.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Set the uid, gid, mode and time for inode.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The do_mkdir_internal() is used for making dir on the target fs, most of
the code are from debugfs/debugfs.c, the debugfs/debugfs.c will be
modified to use this function.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The do_write_internal() is used for copying file from native fs to
target, most of the code are from debugfs/debugfs.c, the
debugfs/debugfs.c will be modified to use this function.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The do_symlink_internal() is used for creating symlinks, most of the
code are from debugfs/debugfs.c, the debugfs/debugfs.c will be modified
to use this function.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The do_mknod_internal() is used for creating special file which is
block, character and fifo, most of the code are from debugfs/debugfs.c,
the debugfs/debugfs.c will be modified to use this function.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Use opendir() and readdir() to read the native directory, then use
lstat() to identify the file type and call the corresponding function to
add the file to the filesystem, call the populate_fs() recursively if it
is a directory.
NOTE: the libext2fs can't create the socket file.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
We will add a -d option which will be used for adding the files from a
given directory to the filesystem, it is similiar to genext2fs, but
genext2fs doesn't fully support ext4.
* We already have the basic operations in debugfs:
- Copy regular file
- Create directory
- Create symlink
- Create special file
We will move these operations into create_inode.h and create_inode.c,
then let both mke2fs and debugfs use them.
* What we need to do are:
- Copy the given directory recursively, this will be done by the
populate_fs()
- Set the owner, mode and other informations
- Handle the hard links
TODO:
- The libext2fs can't create the socket file (S_IFSOCK), do we have a
plan to support it ?
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Since auto_64-bit_support is on by default, resize_inode feature will
be disabled when creating a >16T ext4 according to mke2fs.conf(5).
This should also be done when making ext4 with "-O 64bit" to enable
64bit feature explicitly. Otherwise online resize to enlarge a
over-16T fs to larger would fail.
[root@localhost resize]# truncate -s 50t fs.img
[root@localhost resize]# losetup /dev/loop0 fs.img
[root@localhost resize]# mkfs -t ext4 -O 64bit /dev/loop0 30t
[root@localhost resize]# mount /dev/loop0 mnt
[root@localhost resize]# resize2fs /dev/loop0
resize2fs 1.42.7 (21-Jan-2013)
Filesystem at /dev/loop0 is mounted on /root/resize/mnt; on-line resizing required
old_desc_blocks = 3840, new_desc_blocks = 6400
resize2fs: Invalid argument While checking for on-line resizing support
And dmesg shows
[688378.442623] EXT4-fs (loop0): resizing filesystem from 6710886400 to 13421772800 blocks
[688378.443216] EXT4-fs warning (device loop0): verify_reserved_gdb:700: reserved GDT 3201 missing grp 177147 (5804756097)
[688378.443222] EXT4-fs (loop0): resized filesystem to 8858370048
[688378.528451] EXT4-fs warning (device loop0): ext4_group_extend:1710: can't shrink FS - resize aborted
With this fix resize2fs could do the online enlarge correctly.
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Now inline_data doesn't depend on ext_attr. Hence we don't need to do
this sanity check. But if the inode size is too small (128 bytes),
inline_data will be useless because we couldn't save data in ibody
extented attribute. So we need to report this error.
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
After applied this commit (a7f4c635), we have banned to traverse blocks
for an inode which has inline data because no block belongs to it. But
before calling this function, we need to check inline data flag. This
commit add a sanity check ext2fs_inode_has_valid_blocks2() to fix them
except that ext2fs_expand_dir because it will be fixed by another patch.
Meanwhile in this commit it fixes a bug that when we kill a file we
could leak an inode.
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
To check the coverage of e2fsprogs's regression test, do the
following:
configure --enable-gcov
make -j8 ; make -j8 check ; make coverage.txt
The coverage information will be the coverage.txt and *.gcov files in
the build directories.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Jim pointed out that "tune2fs -f -O ^has_journal" won't remove the
journal if the needs_recovery flag is set; the manpage seems to indicate
that it should. And if you've lost an external journal and can no longer
replay it, how should one proceed?
Change tune2fs so that two "-f" options will allow removal of a dirty
journal from a filesystem, even if the filesystem needs recovery.
e2fsck can then do its best to pick up the pieces.
Addresses-Debian-Bug: #559301
Reported-by: Jim Faulkner <james.faulkner@yale.edu>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The locally defined versions of both sync_file_range and fallocate are broken
on 32bit systems. On these systems two 32bit registers are needed for each
64bit parameter. Also, sync_file_range on MIPS32 needs a dummy parameters
after the fd parameter. Just leave all these subtleties to the C library.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Fix a number of non-literal string format warnings from LLVM due
to the use of _() that were not fixed in commit 45ff69ffeb.
Fix mismatched int vs. __u64 format warnings in blkmap64_rb.c.
There were also some comparisons of __u64 start or count <= 0.
Change them to be comparisons == 0, or start + count overflow.
Fix operator precedence warning for (value & (value - 1) != 0)
introduced in 11d1116a7c. It seems "&" is lower precedence
than "!=", so the above didn't fail for power-of-two values,
but only odd values. Fortunately, either s_desc_size nor
s_inode_size is valid if odd.
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Ext4 file system also supports to set/clear 'j' attribute, but it just
say that this option is only useful for ext3 in manpage. This commit
fixes it.
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Refactor the running kernel version checks to hide the details of
version code checking, etc.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
When meta_bg feature is enabled, group descriptor block is allocated
every 128 block group (or every 64 block group if 64bit feature is
enabled).
In such situation, files in block group more than #128 will be removed
if sparse_super feature is enabled with tune2fs and afterwards
necessary e2fsck running.
Because tune2fs does not reallocate group descriptor blocks but just
set sparse_super feature. If ext4 has sparse_super,
ext2fs_descriptor_block_loc2() called by e2fsck thinks the block group
(e.g. #128) that it has group descriptor block at the head offset. But
that offset is used as backup super block before. So e2fsck fixes
ext4 based on invalid group descriptor blocks and this cause data
lost.
The patch avoids this problem simply by disallow tune2fs enabling
sparse_super if meta_bg is enabled.
Steps to reproduce:
1. Create ext4 which has meta_bg, ^sparse_super and 129+ block groups.
# mke2fs -t ext4 -O meta_bg,^resize_inode,^sparse_super DEV 17G
# mount DEV /MP
2. Create direcotry and files which use block group #128's metadata.
# echo $((8192*128+1)) > /sys/fs/ext4/DEV/inode_goal
# mkdir /MP/DIR
# for i in $(seq 1 100); do dd if=/dev/urandom of=/MP/DIR/file$i bs=1024 count=10; done
3. Enable sparse_super with tune2fs then execute e2fsck.
Data in block group #128 will be lost!!
# umount DEV
# tune2fs -O sparse_super DEV
# e2fsck/e2fsck -yf DEV
Signed-off-by: Akira Fujita <a-fujita@rs.jp.ne.cocm>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Interpret "zero_hugefiles" relation in mke2fs.conf as a boolean value,
as documented in the man page.
If the hugefile is larger than 2GB, set the large_file file system
feature so e2fsck doesn't complain.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The getopt() function will never let optarg be NULL (at least without
using the GNU double-colon extension, which we don't use because it's
not portable), so don't bother checking for that case. It's harmless,
but it triggers a Coverity warning elsewhere, since it thinks optarg
could in fact be NULL.
Addresses-Coverity-Id: #1049156
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Add the extended options packed_meta_blocks and journal_location_front
which causes mke2fs to place the metadata blocks at the beginning of
the file system.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
In practice, it is **extremely** rare for users to try to use more
than the first backup superblock located at the beginning of block
group #1. (i.e., at block number 32768 for file systems with a 4k
block size). This new compat feature restricts the backup superblock
to block group #1 and the last block group in the file system.
Aside from reducing the overhead of the file system by a small number
of blocks, by eliminating the rest of the backup superblocks, it
allows us to have a much more flexible metadata layout. For example,
we can force all of the allocation bitmaps and inode table blocks to
the beginning of the disk, which allows most of the disk to be
exclusively used for contiguous data blocks.
This simplifies taking advantage of certain HDD specific features,
such as Shingled Magnetic Recording (aka Shingled Drives), and the
TCG's OPAL Storage Specification where having a simple mapping between
LBA block ranges and the data blocks used by the file system can make
life much simpler.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Instead of iterating over the allocation bitmap using
ext2fs_test_block_bitmap2(), bit by bit, use
ext2fs_find_first_set_block_bitmap2() instead.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Newer versions of autoconf pull in AC_PROG_GCC as part of
AC_CANONICAL_HOST. So we need check for WITH_DIET_LIBC earlier in
configure.in.
Also, e2fsprogs now needs functions which are found in diet libc's
compat library. So add support for autoconf's LIBS function, and
automatically set libs to include -lcompat.
Finally, disable compiling e4defrag by deault if --with-diet-libc is
specified because the program has too many glibc dependencies.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Use posix_fadvise64() when available. This allows 64bit offsets on
32bit systems.
[ Modified by tytso to try to use fadvise64() as well, and to remove
the attempt to call the syscall directly, since because and
complexities caused by required dummy arguments on some
architectures, it's not worth the hair. ]
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
It's highly unlikely after five seconds that zero blocks would have
been written, but let's silence the Coverity warning.
Addresses-Coverity-ID: 1147780
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Dividing a floating point number by zero is undefined in C. It
happens to work with gcc/glibc, but it's not something that's
guaranteed.
Addresses-Coverity-ID: #1147781
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
An integer overflow could happen if the file system is large and has
very large contiguous chunks of free space.
Addresses-Debian-Bug: #718205
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>