Function int commit_disks(struct final *fin, int (*process_progress)(float progress,ERR_PARAM), int check_only, ERR_PARAM)
checks and modifies
partition structure on disks according to struct final *fin
.
It can be called in two modes: `check-only' and `modification' mode.
It only checks correctness of operations demanded by data stored
in fin
in `check-only' mode. It does not make any modification
on disks. In `modification' mode it also modifies partition structure
if there are no fatal conflicts in data stored in fin
. It also
modifies partition structure case that there are just warnings.
Note that modification of partition structure with warnings is dangerous and
you should always call commit_disks
in `check-only' mode first and
then in `modification' mode to prevent lost of data.
Function comit_disks
is responsible for checking that there is enough
free space to successfully modified partition structure of the disks,
modified partitions are not mounted, there are no illegal operations
not supported by general converter etc. Thus the function is very complex
to ensure that all the conditions for successful conversion are satisfied.
Function commit_disks
processes in several steps:
check_online
of on-line conversion module to ensure that the support
for on-line conversion is compiled into the kernel.
commit_partitions
in `check-only' mode to
check that the partition structure is non-conflicting
with restrictions special for the selected partition type.
struct partition
for general converter now;
it opens the device, fills in struct partition
for imported and
exported partitions and deleted partitions are delcared as
free space (general converter can store there its data).
nomove
is determined. This flag is one if the only
modifications of partition structure are moves of some partitions.
nomove
is one filesystem info
(struct fs_info
) is filled for all the imported and
exported partitions. Then the validity of newly created
filesystem is checked by calling fc_check
.
nomove
is one number of blocks
available and needed for conversion is counted.
nomove
is zero the accelaration routine is
called and the function then continues with partitioner step.
commit_disks
There are a pretty lot of local variables in function commit_disks
.
This is due to the process of checking and modification of partitions
is very complex and a lot of structures are required to be stored and
maintain. Only the variables with special values are listed;
variables used only as an auxiliary ones in for-cycles or when
opening or closing device are not listed.
Number of partitions which are dirty; these are the partitions which were modified or newly created.
Array of `dirtness' flags for all partitions.
Number of partitions on which are stored files which will be used during conversion.
Array of `used files' flags for all partitions.
Number of completely deleted partitions.
Array of `deleted' flags for all partitions.
Number of disks on which some modifications are to be done.
Number of partitions which are to be renamed.
Array of original partitions' names.
Array of new partitions' names.
Array of struct partition
of modified partitions prepared
to be passed to the general converter.
Array of struct partition
of modified and newly created partitions
prepared to be passed to the general converter.
Number of free space blocks to be passed to the general converter.
Array of struct space
of free space blocks prepared to be passed
to the general converter.
Array containing partition information about imported modified partitions.
Array containing filesystem information about imported modified partitions.
Array containing filesystem information about exported modified partitions.
Array containing minimal sizes of new filesystems (whose on exported partitions).
Array containing minimal sizes of internal filesystem structures for new filesystems (whose on exported partitions).
Number of blocks available for conversion.
Number of blocks needed by internal filesystem structures during conversion.
Number of blocks needed to store all data contained in the files during conversion.
commit_disks
There are some special purpose functions called by function commit
during the checking and
conversion process. These functions implements simple technical manipulations with used data structures.
This function initialize struct fs_info
. The structured is filled with values corresponding
to empty filesystem.
This function increases the values stored in the structure passed as the first parameter by values stored in the second parameter structure.
This function returns number of blocks in the intersections of two partitions; if the partitions are disjoint zero is returned.
This function receives array space
containing
entries corresponding
to free space areas on the disk. The first from
entries are declared as free by user.
This function checks that the entries are disjoint with partition located at *base
and
in case that they are not, array space
is appropriately modified.