Include ext2fsP.h in fileio.c for ext2fs_file_block_offset_too_big()
declaration. Fix up the declaration to mark it extern in the header.
Include <strings.h> header for strcasecmp() in tune2fs.c if available,
as described in the strcasecmp(3) man page, instead of doing this
indirectly by declaring _BSD_SOURCE and getting it from <string.h>.
If CONFIG_QUOTA is undefined, parse_quota_opts() is unused in
tune2fs.c so #ifdef it out.
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Compiling with LLVM generates a large number of warnings due
to the use of _() for wrapping strings for i18n:
warning: format string is not a string literal
(potentially insecure) [-Wformat-security]
./nls-enable.h:4:14: note: expanded from macro '_'
#define _(a) (gettext (a))
^~~~~~~~~~~~
These warnings are fixed by using "%s" as the format string,
and then _() is used as the string argument.
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Don't print a verbose configure error in parse-types.h if
<asm/types.h> missing and __[SU]*_TYPEDEF is unset. This is
always the case for non-Linux builds.
The printf formatting strings all use "%llu" for printing 64-bit
values and this it produces a large number of warnings if __u64
is defined as "unsigned long". If __U64_TYPEDEF isn't set use
"unsigned long long" for __u64 in ext2-types.h and blkid-types.h
by default instead of using "unsigned long".
Fix a few places where "%d" or "%u" or "%Lu" were used to print a
64-bit value, by converting them to use "%lld" or "%llu" instead.
Fix a few places where "%lu" was used to print .tv_usec, by casting
the variable to "(long)" since .tv_usec is "int" on some systems.
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The old uninit_bg checksums depend on the UUID, so prohibit changes to
the UUID if a checksumming filesystem is mounted, because this
introduces a nasty race where the kernel and tune2fs are both trying
to rewrite group descriptors at the same time, with different ideas
about what the UUID is.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Check the return values from ext2fs_get_block_bitmap_range2(); if an
error happened, print that and don't print garbage bitmap.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
sysconf(_SC_PAGESIZE) will probably never return an error, but just in
case it does, we shouldn't pass what looks like a huge number to
sync_file_range() and posix_fadvise().
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If someone umounts the filesystem between statfs64() and the getmntent()
iteration, we can exit the loop having never set mnt_type, and strcmp
can crash. Fix the potential NULL dereference.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
mke2fs has a series of checks to ensure that we don't create a
filesystem too big for its blocksize -- if auto-64bit is on, then it
turns on 64bit; otherwise it complains. Unfortunately, it performs
these checks before looking in mke2fs.conf for a blocksize, which
means that the checks are incorrect if the user specifies a non-4096
blocksize in the config file and says nothing on the command line.
The bug also has the effect of mandating a 4k block size on any block
device larger than 4T in that situation. Therefore, read the block
size from the config file before performing the 64bit checks.
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Use ext2fs_group_first_block2() instead of ext2fs_group_first_block()
to avoid dumpe2fs from printing crazy block offsets when we have block
numbers which are larger than 32 bits.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Commit bf0449b1a6, which added the ability to write qcow2 files,
generalized the write_header() file to take the size of the header
structure which it writes out. Unfortunately, it changed the call
which supported original e2image format to pass in fs->blocksize,
instead of the actual size of the e2image header structure (which is
substantially smaller than fs->blocksize). This meant that we copied
in stack garbage into the e2image file, and it made valgrind quite
unhappy.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Don't accept block numbers larger than 2^32 for the badblocks list,
and don't run badblocks on them either.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Passing the "-E resize=NNN" option to mke2fs sets the resize_inode
feature. However, resize_inode and meta_bg are mutually exclusive;
unfortunately, we check this constraint before we parse the extended
options. Fix this by moving this check after the calls
parse_extended_opts().
Reported-by: "Darrick J. Wong" <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The man page still said it was not possible to change the number of
inodes on a filesystem after creating it. You actually can by
resizing the fs, so clarify this language a bit.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Commit 44a2cca3 disabled tune2fs -O quota when the build
didn't have --enable-quota at configure time, but that
wasn't quite enough.
We need to exclude the "-Q" option as well from tune2fs
when --enable-quota isn't specified at configure time.
Otherwise, tune2fs -Q can set the quota feature, but no other
utility will touch the filesystem due to the unknown flag,
if buitl w/o --enable-quota.
So put everything related to "-Q" under #ifdef CONFIG_QUOTA;
usage output (was missing before) and option parsing.
Addresses-Red-Hat-Bugzilla: #1010709
Reported-by: Bert DeKnuydt <Bert.Deknuydt@esat.kuleuven.be>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If quota isn't turned on with --enable-quota, then comment
quota documentation out of the mke2fs manpage.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Run sparse against source files when building e2fsprogs with 'make C=1'. If
instead C=2, it configures basic ext2 types for bitwise checking with sparse,
which can help find the (many many) spots where conversion errors are
(possibly) happening.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Several users have used e2image on a mounted RW filesystem, resulting in
inconsistent, useless e2images for debugging purposes.
This commit will forbid this and print an error message, although the
user can override this using a new force option.
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
A 64bit filesystem without extents is not terribly useful, because the
old block map format does not support pointing to high block numbers.
Warn the user who tries to create such an animal.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Fix all the places where we should be using a blk64_t instead of a
blk_t. These fixes are more severe because 64bit values could be
truncated silently.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
We can calculate journal blocks as soon as blocksize is set.
It will help to figure out wrong journal blocks count earlier.
This will save some un-necessary initialization.
Without patch output =>
mke2fs /dev/sdc1 -J size=1048576
mke2fs 1.42.7 (21-Jan-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
61312 inodes, 244936 blocks
12246 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=251658240
8 block groups
32768 blocks per group, 32768 fragments per group
7664 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done
Writing inode tables: done
The requested journal size is 268435456 blocks; it must be
between 1024 and 10240000 blocks. Aborting.
With patch output =>
mke2fs /dev/sdc1 -J size=1048576
mke2fs 1.42.7 (21-Jan-2013)
The requested journal size is 268435456 blocks; it must be
between 1024 and 10240000 blocks. Aborting.
Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Don't change the root directory's UID/GID automatically just because
mke2fs was run as a non-root user. This can be confusing for users,
and is not flexible for non-root installation tools that need to
create a filesystem with different ownership from the current user.
Add the "-E root_owner[=uid:gid]" option to mke2fs so that the user
and group can be explicitly specified for the root directory. If
the "=uid:gid" argument is not specified, the current UID and GID
are extracted from the running process, as was done in the past.
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
A minor cleanup to order the command-line option parsing in
alphabetical order, except for "-E" and "-R", which need to
be co-located.
Print a message that the "-R" option is deprecated. It has
been deprecated since 2005 (commit c6a44136b9).
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
... or indeed by any mainline kernel, since the compression patches
were never stablized.
Addresses-Debian-Bug: #707609
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reported-by: "Creidieki M. Crouch" <creidieki@gmail.com>
All data cannot be included in normal image file so e2image should exit
in this case.
Signed-off-by: Tomas Racek <tracek@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Exit is called right after the install_image anyway so this one can
be removed.
Signed-off-by: Tomas Racek <tracek@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Disallow tune2fs command to set the inode size to be larger than the
block size. Without this patch, tune2fs makes the file system to be
unmountable.
Steps to reproduce:
1.Create ext4 without flex_bg (or just create ext3)
# mke2fs -t ext4 -O ^flex_bg DEV
2.Set inode size larger than block size
# tune2fs -I 8192 DEV
3. We failed to mount FS
# mount DEV MP
mount: wrong fs type, bad option, bad superblock on /dev/sda7,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
In order to support kernels which support conversion of extent-mapped
files to direct/indirect mapped files, remove the sanity check which
prevented clearing the extent flag in chattr. Kernels which don't
support this will simply give an Operation Not Supported error.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Normally the raw and QCOW2 images only contain fs metadata.
Add a new switch ( -a ) to include all data. This makes it
possible to use e2image to clone a whole filesystem.
Signed-off-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Bigalloc feature has been used for a long time, but the documentation
in mke2fs is still missing. So add it.
Addresses-Debian-Bug: #669730
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The -b and -C options now use parse_num_blocks2() instead of strtol,
so that users can specify -C 256M instead of the much less convenient
-C 268435456.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
If bigalloc is enabled, then -g will specify the clusters per block
group. (If bigalloc is not enabled, then a cluster == a block, so the
meaning of -g is not changed.)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
In addition, do not allow a cluster size of 1024, since that will be
interpreted by ext2fs_initialize() as requesting the default cluster
size.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Reported-by: Zheng Liu <wenqing.lz@taobao.com>
When cluster-size is specified without the bigalloc feature, mke2fs
will ignore this argument silently. But user might think bigalloc
feature has been enabled unless they use the dumpe2fs command. So now
we ask user to set bigalloc feature explicity when cluster-size is
enabled. This can make sure that users understand what they are doing
because bigalloc might impact the performance for some workloads.
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
When bigalloc feature is enabled in mkfs, extents feature also needs
to be enabled. But now when bigalloc feature is enabled without
extents feature, users will not get any warning messages until they
try to mount this file system.
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Update the filefrag program to allow displaying the extents in
some different formats. Try and stay within 80 columns.
* add -k option to print extents in kB-sized units (like df -k)
* add -b {blocksize} to print extents in blocksize units
* add -e option to print extent format, even when FIBMAP is used
* add -X option to print extents in hexadecimal format
Internally, the FIBMAP handling code has been moved into its own
function like FIEMAP, so that the code is more modular. Extent
offsets are now handled in bytes instead of in blocks, to allow
printing extents with arbitrary block sizes. The extent header
printing also moved into its own function so that it can be shared
between the FIEMAP and FIBMAP handling routines, since it got more
complex with the different output options.
Only print error about FIBMAP being root-only a single time.
Print the filesystem type if it changes between specified files.
Add fsync() for FIBMAP if "-s" is given.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Quiet a number of simple compiler warnings:
- pointers not initialized by ext2fs_get_mem()
- return without value in non-void function
- dereferencing type-punned pointers
- unused variables
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If the 64-bit file system feature is enabled, then mke2fs would crash
due to a divide-by-zero error caused by s_desc_size not being
initialized yet.
Reported-by: George Spelvin <linux@horizon.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Commit 44a2cca35e introduced a compile-time failure if --enable-quota
is not passed to the configure script.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>