Next Previous Contents

4.2 Commit request processing

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:

Local variables of function 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.

int dirty_parts

Number of partitions which are dirty; these are the partitions which were modified or newly created.

int dirty_part[][]

Array of `dirtness' flags for all partitions.

int used_parts

Number of partitions on which are stored files which will be used during conversion.

int used_part[][]

Array of `used files' flags for all partitions.

int del_parts

Number of completely deleted partitions.

int del_part[][]

Array of `deleted' flags for all partitions.

int dirty_disk[]

Number of disks on which some modifications are to be done.

int renames

Number of partitions which are to be renamed.

char *renamed_orig[]

Array of original partitions' names.

char *renamed_finl[]

Array of new partitions' names.

struct partition imp[]

Array of struct partition of modified partitions prepared to be passed to the general converter.

struct partition exp[]

Array of struct partition of modified and newly created partitions prepared to be passed to the general converter.

int fspaces

Number of free space blocks to be passed to the general converter.

struct space fspace[]

Array of struct space of free space blocks prepared to be passed to the general converter.

struct part_info imp_part_info[][]

Array containing partition information about imported modified partitions.

struct fs_info imp_fs_info[][]

Array containing filesystem information about imported modified partitions.

struct fs_info exp_fs_info[][]

Array containing filesystem information about exported modified partitions.

block_t exp_size[]

Array containing minimal sizes of new filesystems (whose on exported partitions).

block_t exp_struct[]

Array containing minimal sizes of internal filesystem structures for new filesystems (whose on exported partitions).

block_t available_blocks

Number of blocks available for conversion.

block_t needed1_blocks

Number of blocks needed by internal filesystem structures during conversion.

block_t needed2_blocks

Number of blocks needed to store all data contained in the files during conversion.

Special functions called by 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.

void clear_fs_info(struct fs_info *)

This function initialize struct fs_info. The structured is filled with values corresponding to empty filesystem.

void add_fs_info(struct fs_info *, struct fs_info *)

This function increases the values stored in the structure passed as the first parameter by values stored in the second parameter structure.

block_t count_intersect(struct partition_base *,struct partition_base *)

This function returns number of blocks in the intersections of two partitions; if the partitions are disjoint zero is returned.

int disjoint_space(int from,int *num,struct space **space,struct partition_base *base,ERR_PARAM)

This function receives array space containing

*num

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.


Next Previous Contents