This fixes a cosemtic issue where we don't complete the progress bar
and issue a newline before printing the final resize successful
message.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
In the rare case where new blocks are needed while mutating an extent
tree, supply a specialized block allocator so that extent_node_split()
allocates valid blocks for the interior nodes of the extent tree.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If the filesystem has the uninit_bg feature, then parts of the block
and inode bitmap may not be initialized. Teach resize2fs how to deal
with these case appropriately. (Most of these fixes were fortunately
not necessary for the common case where the resize_inode is present to
reserve space, and where the filesystem is being expanded instead of
being shrunk.)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
When moving directories into new block groups (which would only happen
when shrinking a filesystem), resize2fs would increase the directory
in-use count by 2 times the necessary value, due to a change in
ext2fs_inode_alloc_stats() made in e2fsprogs 1.26. This is largely
harmless, but it does result in a filesystem corruption for e2fsck to
fix.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
These were caused by multi-line strings missing a space at the line
break. Thanks to translator Phillipp Thomas for noticing these typo's.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If the filesystem is grown to the point where the resize_inode is no
longer needed, clean it up properly so e2fsck doesn't have to.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
When calculating the number reserved blocks, use floating point for
better accuracy, since for big filesystems it really makes a
difference. In addition, mke2fs and tune2fs accepts a floating point
number from the user, so they should provide that level of accuracy.
Addresses-Debian-Bug: #452639
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Allow the old name of uninit_groups when converting feature names for
backwards compatibility for scripts running mke2fs and tune2fs.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Add the -P option to print the minimum filesystem size and exit.
Add the -M option to force resizing the filesystem to the minimum
filesystem size.
Signed-off-by: Josef Back <jbacik@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Use ext2fs_get_next_inode_full() in resize2fs and clean up large inode
handling; previous attempt was not properly handling all cases, and
was incorrectly setting i_extra_isize. This caused some extended
attributes to get removed or randomly assigned to other inodes as a
result of the resize, which can be unfortunate on systems using
SELinux.
The previous commit didn't fix things completely on big-endian systems
like PowerPC.
Addresses-Red-Hat-Bugzilla: #434893
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
inode_scan_and_fix() in resize2fs needs to do read/write of the full
inode to be sure it gets all data from larger (>128 byte) inodes.
Addresses-Red-Hat-Bugzilla: #434893
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Apparently Mac OS 10.5 defines fstat64(), but not ftruncate64(),
causing resize2fs to fail to build. So check explicitly for
ftruncate64(), and fall back to ftruncate() if necessary.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If we can't use ftruncate64(), and have to use ftruncate() instead,
make sure that we don't accidentally truncate the size when we chop it
down to an off_t before calling ftruncate(), lest we severely damage a
filesystem image file.
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>
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>
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>
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>
Found 2 of the three places where a return code for ext2fs_write_inode() was
not being checked.
The second fix in e2fsck/emptydir.c is basically just to shut coverity up even
though it really is unnecessary.
Coverity ID: 1: Checked Return
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>
Check to make sure the filesystem has a resize inode if it is needed to
grow the filesystem. Print the correct error message if the kernel
returns an ENOTTY error to the group extend ioctl
Addresses Debian Bug: #380548
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
There were still some %d's lurking when we print blocks & inodes; also
many of the counters in the e2fsck_struct were signed, and probably
need to be unsigned to avoid overflows.
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
Add a new functiom, e2p_percent(), which correct calculates the percentage
of a number based on a given percentage, without worrying about overflow
issues. This is used where we calculate the number of reserved blocks using
a percentage of the total number of blocks in a filesystem.
Based on patches from Eric Sandeen, but generalized to use this new function.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
For loops such as:
for (i=1; i <= fs->super->s_blocks_count; i++) {
<do_stuff>
}
if i is an int and s_blocks_count is (2^32-1), the condition is never false.
Change these loops to:
for (i=1; i <= fs->super->s_blocks_count && i > 0; i++) {
<do_stuff>
}
to stop the loop when we overflow i
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Add a new function, ext2fs_div_ceil(), which correctly calculates a division
of two unsigned integer where the result is always rounded up the next
largest integer. This is used everywhere where we might have
previously caused an overflow when the number of blocks
or inodes is too close to 2**32-1.
Based on patches from Eric Sandeen, but generalized to use this new function
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
Resize2fs will now automatically determine the RAID stride parameter that
had been used to create the filesystem, and use that for newly created
block groups. The RAID stride parameter may also be manually specified
on the command line using the new -S option to resize2fs.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Change the format string(%d, %ld) for a block number and inode number
to %u or %lu.
Signed-off-by: Takashi Sato <sho@tnes.nec.co.jp>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If the filesystem is mounted, open it in read-only mode since the userspace
program should not try to modify it directly. If the filesystem is not mounted,
open it in exclusive mode to avoid potential problems (such as someone
trying to mount the filesystem while it is being resized).
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
There was a off-by-one fencepost error in the logic used to check if
we avoid copying zero-filled blocks when moving an inode table down by
a block or two. Thanks to valgrind for catching it. As far as I know
this fencepost error wasn't causing any actual problems, but it was
definitely a bug.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
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.
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.
non-empty bad block list. Resize2fs now discards any blocks on the
badblock list which are no longer part of the filesystem as the result
of a filesystem shrink. (Note: this means that shrinking and then
enlarging a filesystem is no longer a reversible operation;
information about bad blocks in the part of the filesystem
which is to be chopped off will be lost.)
parameter, and make the error and information messages
display explicitly the blocksize used by the filesystem,
to avoid confusion. (Addresses Debian bug: #189814)
Fix typo's in README.subset
Change debian control file so it doesn't bomb out if the EVMS FSIM
is not there, since it is not built on the Hurd. Resolves Debian
bug #189687.
moving an inode, set the ctime field so that people using
dump/restore will backup the changed inode. Also update
the mtime and ctime of directories which get updated when
we need to move an inode.
release the bmap table. This significantly speeds up
resize2fs when shrinking or expanding a filesystem by a
very small number of blocks (which EVMS will do).
than the requested size, then we will attempt to
transparently extend the filesize in a sparse fashion by
writing a block at the end of the requested part of the
filesystem.
main.c (main), resize2fs.c (resize_fs), resize2fs.h: Change the
function prototype of resize_fs() so that it can modify
the new_size parameter with the actual new size of the
filesystem after the resize operation. (This can
sometimes be less than the requested new size if there
isn't enough space to create the necessary block group
metadata for that last bit of disk space.) Resize2fs now
prints the actual new size of the filesystem when it finishes.
Makefile.in: Move include/asm/types.h.in to lib/ext2fs/ext2_fs.h.in.
wordwrap.pl: Add some rules which help fix up the dependencies.
Many files:
Move include/asm/types.h.in to lib/ext2fs/ext2_fs.h.in.
badblocks.c, chattr.c, dumpe2fs.c, e2image.c, findsuper.c, lsattr.c,
mke2fs.c, mklost+found.c, tune2fs.c, util.c: Change location of
ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, resize2fs.h:
resize2fs.h: Change location of ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, debugfs.h:
debugfs.h: Change location of ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, e2fsck.h, scantest.c:
e2fsck.h, scantest.c: Change location of ext2_fs.h to be
ext2fs/ext2_fs.h
ChangeLog, Makefile.in, tst_uuid.c, uuid_time.c:
tst_uuid.c, uuid_time.c: Remove unneeded #include of ext2_fs.h
ChangeLog, Makefile.in, e2p.h:
e2p.h: Change location of ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, test_icount.c, test_rel.c:
test_icount.c, test_rel.c: Change location of ext2_fs.h to be
ext2fs/ext2_fs.h
ext2fs.h: Remove definition of ext2fs_sb. Note: this may break source
(but not binary) compatibility of some users of the ext2 library.
They should just simply do a global search and replace of struct
ext2fs_sb with struct ext2_super_block, and use their own private copy
of ext2_fs.h if they aren't already.
closefs.c, initialize.c, link.c, newdir.c, openfs.c, swapfs.c: Replace
use of ext2fs_sb with ext2_super_block.
ChangeLog, main.c:
main.c (main): Replace use of struct ext2fs_sb with struct ext2_super_block.
jfs_e2fsck.h, jfs_user.h: Replaces jfs_compat.h. The jfs.h file has
been moved to the include/linux directory.
journal.c, revoke.c, recovery.c: Updated files from Stephen to support
the V2 superblock and revoke processing. The journal.c and revoke.c
files are copies from the ext3 kernel source.
Makefile.in: Added revoke.c to the list of source/object files.
Makefile.in:
Fix up some mistakes in the source file list, and regenerate the
dependencies.
Update Makefile dependencies.
ChangeLog, jfs.h:
jfs.h: Remove excess #include of JFS_DEBUG. Not needed for e2fsprogs,
since we optioanlly define it in the configuration file system.
Commit this file for future use; contains a configure.in script for when
libuuid gets separtead out into its own package.
libext2fs.texinfo:
Update version numbers for 1.19 release.
TODO:
Commit TODO list for 1.19 release.
README:
Update file for 1.19 release.
ChangeLog, e2fsprogs.spec:
e2fsprogs.spec: Merge in a few changes from the Red Hat 6.2 spec file,
now that we're using a modern rpm to build e2fsprogs. Also updated
version number to 1.19.
version.h:
Update version number for 1.19 release.
ChangeLog:
Check in changes for 1.19 release.
Makefile.in (install): Install resize2fs in /sbin, not /usr/sbin.
ChangeLog, unix.c:
unix.c: Also, re-arrange the logic so that we do the time check only
after doing the percentage check, and we only advance the spinner if
we're about to display it.
ChangeLog:
Fix minor wording error in Chagelog.
Update copyright of files in preparation for release of resize2fs.
Also removed the (obsolete) beta-test check that had been in the code,
as well as the old spec files used to package the separate
distribution of resize2fs.
Makefile.in: No longer build resize2fs.static, since there's no real
point in it any more.
Modified Files:
ChangeLog Makefile.in extent.c main.c resize2fs.8.in
resize2fs.c resize2fs.h sim_progress.c test_extent.c
Removed Files:
e2fsprogs-1.12.spec pq.gif resize2fs.spec version.h
badblocks.c, dumpe2fs.c, e2label.c, mke2fs.c, tune2fs.c, uuidgen.c:
For platforms that don't define optarg.h, manually define optarg and
optind.
ChangeLog, main.c:
main.c: For platforms that don't define optarg.h, manually define
optarg and optind.
ChangeLog, unix.c:
unix.c: For platforms that don't define optarg.h, manually define
optarg and optind.
Makefile.in (distclean): Remove TAGS and Makefile.in.old from the
source directory. Also, when making the .exclude file for the
source_tar_file, exclude those two files as well.
Makefile.in (distclean): Remove TAGS and Makefile.in.old from the
source directory.
message.c (safe_print): New function which prints strings, converting
non-printable characters using the '^' and M-notation. This function
is now used to print directory name entries and pathnames.
ChangeLog:
Update for release of E2fsprogs 1.14.
mk_cmds.sh.in: Fix error message so that it says mk_cmds's template
files instead of compile_et's template files.
ChangeLog, resize2fs.h:
resize2fs.h: Protect include of unistd.h with HAVE_UNISTD_H.
e2fsprogs.lsm:
Updated for 1.12 release.
pass1.c (process_inode_cmp): Use EXT2_QSORT_TYPE to define the
appropriate return type for comparison functions for qsort.
e2fsck.h: Add #ifdef protection for unistd.h
super.c: Remove header files already included by e2fsck.h
ChangeLog, dblist.c, ext2fs.h:
ext2fs.h: Define EXT2_QSORT_TYPE appropriately for the return type for
comparison functions for qsort.
dblist.c (dir_block_cmp): Use EXT2_QSORT_TYPE in function declaration.
ChangeLog, extent.c:
extent.c (ext2fs_create_extent_table): Use ext2fs_free_mem instead of
free().
(extent_cmp): Use EXT2_QSORT_TYPE to define the appropriate return
type for comparison functions for qsort.
ext2fs.h, bitops.h: Add support for the Watcom C compiler to do inline
functions.
ext2fs.h, dosio.c: Use asm/types.h instead of linux/types.h to evade a
potential problem with glibc's header files trying to spike out
linux/types.h.
ext2fs.h (ext2fs_resize_mem): Change the function prototype to include
the old size of the memory, which is needed for some braindamaged
memory allocation systems that don't support realloc().
badblocks.c (ext2fs_badblocks_list_add):
bb_inode.c (clear_bad_block_proc):
dblist.c (ext2fs_add_dir_block):
icount.c (insert_icount_el):
irel_ma.c (ima_put):
rs_bitmap.c (ext2fs_resize_generic_bitmap): Update functions to pass
the old size of the memory to be resized to ext2fs_resize_mem().
ChangeLog, dirinfo.c:
dirinfo.c (e2fsck_add_dir_info): Update function to pass the old size
of the memory to be resized to ext2fs_resize_mem().
ChangeLog, extent.c, resize2fs.c:
resize2fs.c (adjust_superblock):
extent.c (ext2fs_add_extent_entry): Update functions to pass the old
size of the memory to be resized to ext2fs_resize_mem().
Add substitution for @datadir@
ChangeLog, Makefile.in:
Change to use new installation directory variables convention. Fix
uninstall rules to take $(DESTDIR) into account. Remove cat8dir from
the installdirs target, since modern man package don't necessarily put
the cat directory in /usr/man/cat?.
ChangeLog, .del-types.h.in~7a460879:
types.h.in: Add a signed keyword to the __s64 definition.
main.c (main): Check to make sure we can really resize this
filesystem. If there are compatible feature sets that we don't
support, we need to abort.
resize2fs.c: Change to use the new prototype required by
block_iterate2 (which uses blkcnt_t for the blockcount).
version.h, RELEASE-NOTES:
Interim commit of changes to date.
resize2fs.c (inode_scan_and_fix): If we are expanding the filesystem,
temporarily set rfs->old_fs->super->s_blocks_count to ultimate size of
the filesystem, to avoid catching an error on the block iterator.
Change the name of the complete source file that we built (that
includes resize2fs) to be e2fsprogs-ALL-<version>.tar.gz. Don't link
with libuuid, since it's not needed.
resize2fs.8.in:
Add copyright statement.
Many files:
Update packaging for the resize2fs program.
resize2fs.c (blocks_to_move): Create the meta_bmap using the old
filesystem, not the new filesystem.
(get_new_block): Don't try checking the old block bitmap if the block
we're testing is beyond the boundaries of the old filesystem.
Makefile.in: Add rule to build a static version of resize2fs. Update
dependency rules.
main.c: #include ../version.h, instead of using a hard-coded version
string.
main.c (check_mount, main): Resize2fs now checks the size of the
partition, and uses this as a default new_size of the partition if one
is not specified. Resize2fs will not let you resize a mounted
partition.
resize2fs.c: Change how the progress function for the INODE_SCAN pass
is performed, so that the maximum size is never zero.
resize2fs.8.in: Updated man page.
Major reoganization of how resizing works. Functions in
ext2_block_move.c, and ext2_inode_move.c moved into resize2fs.c.
Multiple passes in those two files also combined into a single inode
scanning pass. Made the inode table moving function better handling
the case where it needs to abort mid-operation. When moving blocks
around, made the block allocation function preferentially avoid the
old group descriptor blocks, to make resize2fs more robust.
resize2fs.h: If EXT2_FLAT_INCLUDES is defined, then assume all
of the ext2-specific header files are in a flat directory.
ext2_block_move.c, ext2_inode_move.c, extent.c, resize2fs.c,
resize2fs.h: Rename variables named "new" to "new_block",
"new_inode", or "new_loc" to avoid C++ reserved word
clash.
ext2_block_move.c, ext2_inode_move.c, extent.c, resize2fs.c,
sim_progress.c: Use ext2fs_get_memory(),
ext2fs_free_memory(), et. al., instead of malloc() and
free().
ext2_block_move.c, ext2_inode_move.c, extent.c: Explicitly cast
all assignments from void * to be compatible with C++.
banalysis.c, banalysis.h, ext2_inode_move.c, ext2_block_move.c:
Change private to priv_data to avoid C++ namespace clash.
ChangeLog, badblocks.8.in:
badblocks.8.in: Add documentation for the -s option.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c: Add calls to the progress
indicator function.
pass1.c (scan_callback): Add call to the progress feedback function
(if it exists).
super.c (check_super_block): Skip the device size check if the
get_device_size returns EXT2_EXT_UNIMPLEMENTED.
iscan.c (main): Don't use fatal_error() anymore.
pass1b.c, swapfs.c, badblocks.c: Set E2F_FLAG_ABORT instead of calling
fatal_error(0).
problem.c, pass3.c (PR_3_ROOT_NOT_DIR_ABORT,
PR_3_NO_ROOT_INODE_ABORT): New problem codes.
problem.c, pass2.c (PR_2_SPLIT_DOT): New problem code.
problem.c, pass1.c (PR_1_SUPPRESS_MESSAGES): New problem code.
problemP.h: New file which separates out the private fix_problem data
structures.
util.c, dirinfo.c, pass1.c, pass1b.c, pass2.c, pass5.c, super.c,
swapfs.c util.c: allocate_memory() now takes a e2fsck context as its
first argument, and rename it to be e2fsck_allocate_memory().
problemP.h:
New file which contains the private problem abstraction definitions.
Makefile.pq:
Remove include of MAKEFILE.STD, which doesn't exist at this point.
resize2fs.c, ext2_block_move.c ext2_inode_move.c: Only include printf
statements if RESIZE2FS_DEBUG is defined.
main.c: Don't read in the bitmaps since resize2fs.c does that.
e2label.c, mke2fs.c:
Adjust header files.
Rename new error codes to _ET_ in them for consistency.
ChangeLog, et_c.awk, et_h.awk:
Remove support for non STDC compilers, since the workarounds caused
problems with the header file.
Makefile.pq:
Checkpoint of powerquest work.
Allow people to set the version.h to something like 1.10-PLUS.
.del-inodemap.c~24510e64, main.c, resize2fs.c, resize2fs.h:
More interim work. All is functioning except progress meter.
bmove.c (ext2fs_move_blocks): New function which takes a bitmap of
blocks which need to be moved, and moves those blocks to another
location in the filesystem.
rs_bitmap.c (ext2fs_resize_generic_bitmap): When expanding a bitmap,
make sure all of the new parts of the bitmap are zero.
bitmaps.c (ext2fs_copy_bitmap): Fix bug; the destination bitmap wasn't
being returned to the caller.
alloc_tables.c (ext2fs_allocate_group_table): Add new function
ext2fs_allocate_group_table() which sets the group tables for a
particular block group. The relevant code was factored out of
ext2fs_allocate_tables().
dblist.c (make_dblist): Adjust the initial size of the directory block
list to be a bit more realize (ten plus twice the number of
directories in the filesystem).
Check in interim work.
configure.in (rmakefile): Added (optional) private directory for resize2fs.
Makefile.in: Change recursive descent rules to check to see if a
directory exists before trying to make it.
Many files:
Initial checkin of work done to date.