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.
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
:
/dev/hda3
will have this number set as 3
. Finding right
number should depend primarily on user's wishes, you just need to be sure
to not to have the same number as any other struct user_partition
in this physical disk (struct disk_info
).
0
as we don’t generally wish to
specify our custom values on up_entry. Set it to value 1
if you wish
custom partition table entry but you will also need to properly initialize
appropriate field of up_entry, depending on the partition layout of
current physical disk.
0
, NULL
, respectively, as we
are not wishing to move or copy here any data of the surrounding partitions.
int pars_fill_newexp(struct user_partition *upart,enum fs_types fstype,struct resources *res,ERR_PARAM)
.
pb_type
is just dumb filled-in by copying the parameter,
fields for user parameters are copied from the array that can be found
in struct resources
for the new partitions (struct fs_pars * rs_fspars
).
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:
0
, NULL
, respectively, as we
are not wishing to move or copy here any data of the surrounding partitions.
0
as we don’t generally wish to
specify our custom values on up_entry. Set it to value 1
if you wish
custom partition table entry but you will also need to properly initialize
appropriate field of up_entry, depending on the partition layout of
current physical disk.
int pars_fill_newexp(struct user_partition *upart,enum fs_types fstype,struct resources *res,ERR_PARAM)
.
pb_type
is just dumb filled-in by copying the parameter,
fields for user parameters are copied from the array that can be found
in struct resources
for the new partitions (struct fs_pars * rs_fspars
).
Final invalidation of all up_entryvalid fields is NOT needed for this procedure.
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:
0
, NULL
, respectively, as we
are not wishing to move or copy here any data of the surrounding partitions.
0
as we don’t generally wish to
specify our custom values on up_entry. Set it to value 1
if you wish
custom partition table entry but you will also need to properly initialize
appropriate field of up_entry, depending on the partition layout of
current physical disk.
int pars_fill_newexp(struct user_partition *upart,enum fs_types fstype,struct resources *res,ERR_PARAM)
.
pb_type
is just dumb filled-in by copying the parameter,
fields for user parameters are copied from the array that can be found
in struct resources
for the new partitions (struct fs_pars * rs_fspars
).
Final invalidation of all up_entryvalid fields is NOT needed for this procedure.
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.
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.
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.
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).
Parameters can be bind to:
up_up
in struct user_partition
di_pars
in struct disk_info
fi_pars
in struct final
rs_fspars[x].fp_pars
in struct resources
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)