When fgets() function fails, contents of the buffer is undefined. That
is, fgets() return value needs to be checked, to avoid undefined behavior.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The strtoul() function has a lot of messy error checking that needs to
be done; by factoring it out into one place we can make sure it's done
right in all of the places where it is called.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This will make it easier for us to support 64-bit block numbers when
the time comes. Not that running badblocks on a > 4TB machine is
anything I want to contemplate!
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Fix chattr so that if there are errors, it will report it via a
non-zero exit code. It will now explicitly give errors when
attempting to set files that are not files or directories (which are
currently not supported under Linux). The -f flag will suppress error
messages from being printed, although the exit status will still be
non-zero.
Addresses-Red-Hat-Bugzilla: #180596
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
The -R option is only used for backwards compatibility, and -E is
preferred, so change the usage message accordingly.
Signed-off-by: Coly Li <coyli@suse.de>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Add macros to support variable-length group descriptors for ext4.
Signed-off-by: Valerie Clement <valerie.clement@bull.net>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If a user specifies a bind mount with a non-zero fsck pass number, for
example:
/foo /bar ext3 bind,defaults 1 3
print a warning and ignore the fstab entry.
Addresses-Red-Hat-Bugzilla: #151533
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Fix up $(root_sysconfdir) handling misc/Makefile.in so that
make install and make uninstall works correctly when $prefix != /.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Create new functions ext2fs_{set,get}_{inode,block}_bitmap_range()
which allow programs like e2fsck, dumpe2fs, etc. to get and set chunks
of the bitmap at a time.
Move the representation details of the 32-bit old-style bitmaps into
gen_bitmap.c.
Change calls in dumpe2fs, mke2s, et. al to use the new abstractions.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
People are getting surprised by mke2fs creating filesystems with
different defaults than earlier versions of mke2fs if mke2fs.conf is
not present. Having gotten two complaints about ramdisks getting
created by with 4k blocksizes which then blow up when the ramdisk is
mounted with a "Magic mismatch, very weird" error message from the
kernel, let's fix this by making sure mke2fs has a built-in version of
mke2fs.conf file. People can still override the built-in version of
mke2fs.conf by editing /etc/mke2fs.conf, but this maintains the
previous behavior.
Addresses-Sourceforge-Bug: #1745818
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This patch changes ext2fs_open() to set EXT2_FLAG_MASTER_SB_ONLY by
default. This avoids some problems in e2fsck (reported by Jim Garlick)
where a corrupt journal can end up writing the bad superblock to the
backups. In general, only e2fsck (after the filesystem is clean),
tune2fs, and resize2fs should change the backup superblocks by default.
Most callers of ext2fs_open() should not be touching anything where the
backups should be touched. So let's change the defaults to avoid
potential problems.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
A quick patch to sanity check the inode ratio vs the inode size. In
some cases Lustre users have tried specifying an inode size of 4096
bytes, while keeping an inode ratio of one inode per 4096 bytes. I'm
sure more people will do this now that large inodes are available in
ext4 and documented in e2fsprogs.
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Store the RAID stride value when a filesystem is created with a requested
RAID stride, and then use it automatically in resize2fs.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Mke2fs is supposed to set the uid/gid ownership of the root directory when
a non-rooot user creates the filesystem. This wasn't working correctly
if the uid/gid was > 16 bits. In additional, debugfs wasn't displaying
large uid/gid's correctly. This patch fixes these two programs.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
One of our testers filed a bug that said "mkfs.ext3 is much slower
when mke2fs.conf is missing..."
This is because the shipped defaults in mke2fs.conf do not match the
shipped defaults in the mkfs code itself; he wound up making a 1k
block filesystem on a very large block device, for example.
So - How about this patch, to bring them back into line? Which makes
me wonder; having "defaults" in 2 different places is bound to get out
of sync; should we instead generate both code & config file defaults
(and maybe man page defaults) from a common source?
Anyway, here's a patch to bring mke2fs.conf and mke2fs.c into line for
current defaults...
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Increase the maximum size of the journal to 100 times the previous
maximum, but add a restriction that it can be no more than half the size
of the filesystem.
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The memory allocated by inst is not reclaimed. There also was a
call to exit that coverity did not catch the resource leak. This
might not really be a big issue since the memory will be freed when
fsck exits, but it should be done anyway imho.
Coverity ID: 32: Resource Leak
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
zero_buf and buf must be freed on return from the
output_meta_data_blocks() function.
Coverity ID: 26+27: Resource Leak
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
If the fs_type is not specified and we are creating a journal device, to
use a fs_type of "journal"; this used to be the behavior before we added
support for the /etc/mke2fs.conf file, so let's fix it to restore the
old behavior.
Coverity ID: 4: Deadcode
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Change all of the e2fsprogs programs to use the newer add_error_table()
and remove_error_table() interfaces instead of the much older
initialize_*_error_table() function.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Add support for the new flag EXT2_FLAG_SOFTSUPP_FEATURES flag to
ext2fs_open() , which allows application to open filesystes with features
which are currently only partially supported by e2fsprogs.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Badblocks now interprets last_block argument as the last block to check,
instead of the number of blocks to check, to be consistent with the
badblocks man page.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Fix revision 0 error checking so that it doesn't give spurious error
when the user gives a command-line option of "-O none".Add error
checking so that "-r 0 -j", "-r 0 -s 1", and "-r 0 -E resize=XXX" will
print an explanatory error message and abort.
Addresses Debian bug: #392107
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Make the smallest journal be 1400 blocks instead of 1024 blocks to
make sure there is enough room to support on-line resizing.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>