Next Previous Contents

4.3 Partition modifications

This sections describes the general steps needed to modify some partition (including its creation, deletion, move etc.). Please note that the number of physical disks is always fixed from the view of the program and it makes no sense to modify them. When application wants to perform some modifications, it has to finally pass the structure struct final to function commit_disks().

Although the application is allowed to do the conversion of struct resources to struct final itself, it may find more convenient to use int get_final(struct final *,struct resources *,ERR_PARAM). This function will convert the given resources parameter to the passed empty structure final. Please note that resources parameter can be passed as NULL, get_resources() is then done automatically (and discarded immediately after its conversion).

When you are preparing to do wished partition modifications, you are allowed to only modify struct disk_info * fi_exp_disks field of final, it initially contains the same contents as struct disk_info * fi_imp_disks but any modification of fi_imp_disks is strictly prohibited.

New partition

For this operation you must physically add one struct user_partition to the di_up field (something like newobjrearr(disk->di_up,disk->di_count+1) with proper di_count update afterwards). After this extension you will have to properly fill in the whole allocated struct user_partition:

Mkfs partition

This operations looks very similiar to the previous New partition, the only difference is that it will keep the physical partition location and numbering not modified. During its implementation you will need to initially free the contents of the original partition by void free_partition(struct user_partition *part,ERR_PARAM). You will still need to initialize the freed up_dircount and up_dirs as free_partition() will leave it uninitialized, this action is noted in the list below.

In this state you will do the appropriate parts of New partition process as described above:

Final invalidation of all up_entryvalid fields is NOT needed for this procedure.

Convert partition

Operation similiar (and simpler than) the previous Mkfs partition. We just call void free_pars(int count, struct user_parameter *pars, ERR_PARAM) instead of original free_partition as it would delete also all the data of our partition which is not wised. So initially call free_pars(upart->up_upcount,upart->up_up,ERR_PASS) followed by:

Final invalidation of all up_entryvalid fields is NOT needed for this procedure.

Delete partition

Free the contents of the original partition by void free_partition(struct user_partition *part,ERR_PARAM). Decision about renumbering (modification of up_number fields) of the partitions on the current disk should be left to user. As you are freeing some possibly inner item of the array struct disk_info * fi_exp_disks, you'll find easier to free the fields of this item and then copy/move the last item to the current one (no need to do slave data moving).

As the final step you are required to invalidate up_entryvalid fields of all the partitions on current physical disk as the exact partition entry values may need to be recalculated after this operation.

Move partition

Simple adjust of value found in up_base.pb_start field is sufficient, although you must be very careful to not to cross and conflict the physical space of any other partition found on the current physical disk.

As the final step you are required to invalidate up_entryvalid fields of all the partitions on current physical disk as the exact partition entry values may need to be recalculated after this operation.

Resize partition

Simple adjust of value found in up_base.pb_len field is sufficient, although you must be very careful to not to cross and conflict the physical space of any other partition found on the current physical disk.

As the final step you are required to invalidate up_entryvalid fields of all the partitions on current physical disk as the exact partition entry values may need to be recalculated after this operation.

Copy partition

You should use the (currently only one permitted) entry up_dirs from your source partition to the destination partition. Pointer to the struct must not be used directly, copy it instead. For now up_dircount is permitter to have maximal value of 1 so you'll have to free the previous value, if some exists. The easiest way to to the described copy is to use the function for it: int append_directories(struct user_partition *upartd,struct user_partition *uparts,ERR_PARAM). Adjust up_base.pb_type (and its bearing up_up) to the original filesystem or leave it alone, according to the wishes of the copy operation (simple copy with possible resize or copy combined with convert).

Modification of parameters

Parameters can be bind to:

All these described fields are pointers to arrays of struct user_parameter (count of them is stored in the field right before the pointer in each of the structures, name is varying). Application is not permitted to change the count of these structures in any way or to allocate/free some of them. You may only change the field val found in up_par union. Choose the appropriate union's structure by the actual parameter type stored in up_type - parameter can be number, string, choice from list of numbers etc)


Next Previous Contents