"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "fsremap/src/io/io_test.cc" between
fstransform-0.9.3-src.tar.gz and fstransform-0.9.4.tar.gz

About: fstransform is a tool to change a file-system from one format to another, for example from jfs, xfs, or reiser to ext2, ext3, or ext4, in-place and without the need for backup.

io_test.cc  (fstransform-0.9.3-src):io_test.cc  (fstransform-0.9.4)
skipping to change at line 46 skipping to change at line 46
#include "../misc.hh" // for ff_str2un_scaled() #include "../misc.hh" // for ff_str2un_scaled()
#include "extent_file.hh" // for ff_read_extents_file() #include "extent_file.hh" // for ff_read_extents_file()
#include "io_test.hh" // for fr_io_test #include "io_test.hh" // for fr_io_test
FT_IO_NAMESPACE_BEGIN FT_IO_NAMESPACE_BEGIN
/** constructor */ /** constructor */
fr_io_test::fr_io_test(fr_persist & persist) fr_io_test::fr_io_test(fr_persist & persist)
: super_type(persist) : super_type(persist)
{ {
/* mark fd[] as invalid: they are not open yet */ /* mark this_f[] as invalid: they are not open yet */
for (ft_size i = 0; i < FC_FILE_COUNT; i++) for (ft_size i = 0; i < FC_EXTENTS_FILE_COUNT; i++)
this_f[i] = NULL; this_f[i] = NULL;
} }
/** destructor. calls close() */ /** destructor. calls close() */
fr_io_test::~fr_io_test() fr_io_test::~fr_io_test()
{ {
close(); close();
} }
/** return true if this fr_io_test is currently (and correctly) open */ /** return true if this fr_io_test is currently (and correctly) open */
skipping to change at line 84 skipping to change at line 84
char const* const* io_args = args.io_args; char const* const* io_args = args.io_args;
ft_uoff dev_len; ft_uoff dev_len;
ft_size i = FC_DEVICE_LENGTH; ft_size i = FC_DEVICE_LENGTH;
err = ff_str2un_scaled(io_args[i], & dev_len); err = ff_str2un_scaled(io_args[i], & dev_len);
if (err != 0) { if (err != 0) {
return ff_log(FC_ERROR, errno, "error parsing %s '%s'", extents_label[i] , io_args[i]); return ff_log(FC_ERROR, errno, "error parsing %s '%s'", extents_label[i] , io_args[i]);
} }
if (!is_replaying()) { if (!is_replaying()) {
for (i = FC_DEVICE_LENGTH+1; i < FC_FILE_COUNT; i++) { for (i = FC_DEVICE_LENGTH+1; i < FC_EXTENTS_FILE_COUNT; i++) {
if ((this_f[i] = fopen(io_args[i], "r")) == NULL) { if ((this_f[i] = fopen(io_args[i], "r")) == NULL) {
err = ff_log(FC_ERROR, errno, "error opening %s ' %s'", extents_label[i], io_args[i]); err = ff_log(FC_ERROR, errno, "error opening %s ' %s'", extents_label[i], io_args[i]);
break; break;
} }
} }
} }
if (err == 0) { if (err == 0) {
dev_length(dev_len); dev_length(dev_len);
dev_path("<test-device>"); dev_path("<test-device>");
} else } else
skipping to change at line 125 skipping to change at line 125
{ {
close_extents(); close_extents();
super_type::close(); super_type::close();
} }
/** /**
* close the file descriptors for LOOP-FILE and ZERO-FILE * close the file descriptors for LOOP-FILE and ZERO-FILE
*/ */
void fr_io_test::close_extents() void fr_io_test::close_extents()
{ {
for (ft_size i = 0; i < FC_FILE_COUNT; i++) for (ft_size i = 0; i < FC_EXTENTS_FILE_COUNT; i++)
close0(i); close0(i);
} }
/** return true if this I/O has open descriptors/streams to LOOP-FILE and FREE-S PACE */ /** return true if this I/O has open descriptors/streams to LOOP-FILE and FREE-S PACE */
bool fr_io_test::is_open_extents() const bool fr_io_test::is_open_extents() const
{ {
ft_size i, n = FC_FILE_COUNT; ft_size i, n = FC_EXTENTS_FILE_COUNT;
for (i = FC_DEVICE_LENGTH+1; i < n; i++) for (i = FC_DEVICE_LENGTH+1; i < n; i++)
if (this_f[i] == NULL) if (this_f[i] == NULL)
break; break;
return i == n; return i == n;
} }
/** /**
* retrieve LOOP-FILE extents and FREE-SPACE extents and append them into * retrieve LOOP-FILE extents, FREE-SPACE extents and any additional extents to
* the vectors loop_file_extents and free_space_extents. be ZEROED
* the vectors will be ordered by extent ->logical. * and insert them into the vectors loop_file_extents, free_space_extents and to
_zero_extents
* the vectors will be ordered by extent ->logical (for to_zero_extents, ->physi
cal and ->logical will be the same).
* *
* return 0 for success, else error (and vectors contents will be UNDEFINED). * return 0 for success, else error (and vectors contents will be UNDEFINED).
* *
* implementation: load extents list from files * if success, also returns in ret_effective_block_size_log2 the log2()
* (for example they could be the job persistence files) * of device effective block size.
* the device effective block size is defined as follows:
* it is the largest power of 2 that exactly divides all physical,
* logical and lengths in all returned extents (both for LOOP-FILE
* and for FREE-SPACE) and that also exactly exactly divides device length.
*
* this implementation simply reads extents from persistence files.
*/ */
int fr_io_test::read_extents(fr_vector<ft_uoff> & loop_file_extents, int fr_io_test::read_extents(fr_vector<ft_uoff> & loop_file_extents,
fr_vector<ft_uoff> & free_space_extents, fr_vector<ft_uoff> & free_space_extents,
ft_uoff & ret_block_size_bitmask) fr_vector<ft_uoff> & to_zero_extents,
ft_uoff & ret_block_size_bitmask)
{ {
ft_uoff block_size_bitmask = ret_block_size_bitmask; ft_uoff block_size_bitmask = ret_block_size_bitmask;
int err = 0; int err = 0;
do { do {
if (!is_open_extents()) { if (!is_open_extents()) {
ff_log(FC_ERROR, 0, "unexpected call to io_test::read_extents(), I/O is not open"); ff_log(FC_ERROR, 0, "unexpected call to io_test::read_extents(), I/O is not open");
err = -ENOTCONN; // not open! err = -ENOTCONN; // not open!
break; break;
} }
/* ff_load_extents_file() appends to fr_vector<ft_uoff>, does NOT overwr fr_vector<ft_uoff> * ret_extents[FC_EXTENTS_FILE_COUNT] = {
ite it */ & loop_file_extents, & free_space_extents, & to_zero_extents,
if ((err = ff_load_extents_file(this_f[FC_LOOP_EXTENTS], loop_file_exten };
ts, block_size_bitmask)) != 0) { for (ft_size i = FC_LOOP_EXTENTS; i < FC_EXTENTS_FILE_COUNT; i++) {
err = ff_log(FC_ERROR, err, "error reading %s extents from save-file /* ff_load_extents_file() appends to fr_vector<ft_uoff>,
", label[FC_LOOP_FILE]); does NOT overwrite it */
break; if ((err = ff_load_extents_file(this_f[i], * ret_extents[
} i], block_size_bitmask)) != 0) {
if ((err = ff_load_extents_file(this_f[FC_FREE_SPACE_EXTENTS], free_spac err = ff_log(FC_ERROR, err, "error reading %s ext
e_extents, block_size_bitmask)) != 0) { ents from save-file", extents_label[i]);
err = ff_log(FC_ERROR, err, "error reading %s extents from save-file break;
", label[FC_FREE_SPACE]); }
break;
} }
} while (0); } while (0);
if (err == 0) if (err == 0)
ret_block_size_bitmask = block_size_bitmask; ret_block_size_bitmask = block_size_bitmask;
return err; return err;
} }
FT_IO_NAMESPACE_END FT_IO_NAMESPACE_END
 End of changes. 8 change blocks. 
25 lines changed or deleted 34 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)