mirror of https://github.com/vitalif/e2fsprogs
main.c (main): If we are resizing a plain file which is smaller
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.bitmap-optimize
parent
1acb01b4e2
commit
116db1b513
|
@ -1,3 +1,20 @@
|
|||
2002-03-31 <tytso@mit.edu>
|
||||
|
||||
* main.c (main): If we are resizing a plain file which is smaller
|
||||
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.
|
||||
|
||||
2002-03-08 Theodore Tso <tytso@mit.edu>
|
||||
|
||||
* Release of E2fsprogs 1.27
|
||||
|
|
|
@ -19,6 +19,7 @@ extern char *optarg;
|
|||
extern int optind;
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "resize2fs.h"
|
||||
|
||||
|
@ -119,6 +120,7 @@ int main (int argc, char ** argv)
|
|||
blk_t max_size = 0;
|
||||
io_manager io_ptr;
|
||||
char *tmp;
|
||||
struct stat st_buf;
|
||||
|
||||
initialize_ext2_error_table();
|
||||
|
||||
|
@ -223,6 +225,21 @@ int main (int argc, char ** argv)
|
|||
}
|
||||
if (!new_size)
|
||||
new_size = max_size;
|
||||
/*
|
||||
* If we are resizing a plain file, and it's not big enough,
|
||||
* automatically extend it in a sparse fashion by writing the
|
||||
* last requested block.
|
||||
*/
|
||||
if ((new_size > max_size) &&
|
||||
(stat(device_name, &st_buf) == 0) &&
|
||||
S_ISREG(st_buf.st_mode) &&
|
||||
((tmp = malloc(fs->blocksize)) != 0)) {
|
||||
memset(tmp, 0, fs->blocksize);
|
||||
retval = io_channel_write_blk(fs->io, new_size-1, 1, tmp);
|
||||
if (retval == 0)
|
||||
max_size = new_size;
|
||||
free(tmp);
|
||||
}
|
||||
if (!force && (new_size > max_size)) {
|
||||
fprintf(stderr, _("The containing partition (or device)"
|
||||
" is only %d blocks.\nYou requested a new size"
|
||||
|
@ -240,7 +257,7 @@ int main (int argc, char ** argv)
|
|||
device_name);
|
||||
exit(1);
|
||||
}
|
||||
retval = resize_fs(fs, new_size, flags,
|
||||
retval = resize_fs(fs, &new_size, flags,
|
||||
((flags & RESIZE_PERCENT_COMPLETE) ?
|
||||
resize_progress_func : 0));
|
||||
if (retval) {
|
||||
|
|
|
@ -66,7 +66,7 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs);
|
|||
/*
|
||||
* This is the top-level routine which does the dirty deed....
|
||||
*/
|
||||
errcode_t resize_fs(ext2_filsys fs, blk_t new_size, int flags,
|
||||
errcode_t resize_fs(ext2_filsys fs, blk_t *new_size, int flags,
|
||||
errcode_t (*progress)(ext2_resize_t rfs, int pass,
|
||||
unsigned long cur,
|
||||
unsigned long max_val))
|
||||
|
@ -95,10 +95,12 @@ errcode_t resize_fs(ext2_filsys fs, blk_t new_size, int flags,
|
|||
if (retval)
|
||||
goto errout;
|
||||
|
||||
retval = adjust_superblock(rfs, new_size);
|
||||
retval = adjust_superblock(rfs, *new_size);
|
||||
if (retval)
|
||||
goto errout;
|
||||
|
||||
*new_size = rfs->new_fs->super->s_blocks_count;
|
||||
|
||||
retval = blocks_to_move(rfs);
|
||||
if (retval)
|
||||
goto errout;
|
||||
|
|
|
@ -118,7 +118,7 @@ struct ext2_resize_struct {
|
|||
|
||||
|
||||
/* prototypes */
|
||||
extern errcode_t resize_fs(ext2_filsys fs, blk_t new_size, int flags,
|
||||
extern errcode_t resize_fs(ext2_filsys fs, blk_t *new_size, int flags,
|
||||
errcode_t (*progress)(ext2_resize_t rfs,
|
||||
int pass, unsigned long cur,
|
||||
unsigned long max));
|
||||
|
|
Loading…
Reference in New Issue