Next Previous Contents

3.1 General description of API usage

The common usage of the library will look as follows: The program calls the function get_resources first; this function fills the given structure with information about present hard disks and their partition structure. For some of the partitions will be called function get_rootdirs to obtain the list of their root-subdirectories. Then the program calls function commit_disks with parameters describing new partition structures on the disks and data location for new partitions. If there are demands conflicting with possibilities of the library (e.g. there is too much data to move to a small partition) then the function will return the list of such encountered conflicts and refuses to continue the operation.

get_resources()

This function is used to get information about all disks and filesystems in the system. It is also possible to provide as a parameter us_sp_devices a list of file names to check for partition tables and filesystems. The list is terminated by an empty string. It is also possible to provide as us_sp_devices NULL pointer in case that there are no additional files to check. Its prototype is following:

int get_resources(struct resources *,char **us_sp_devices, ERR_PARAM);

After successful call (see Error handling) the struct resources is filled in. This structure contains array of all drives detected on the system, array of all supported global parameters, and arrays of all filesystem specific parameters (one array for each supported filesystem). See Filesystem specific and global parameters for parameter description.

For each detected drive there is (in struct disk_info) some `technical' information like drive type or geometry (see lib.h for details) and an array of struct user_partition with information for each partition on the drive. struct user_partition contains:

  1. partition start, length and type of filesystem on partition (up_base),
  2. ondisk format of corresponding partition entry (up_entry) and its validity flag (up_entryvalid)
  3. current filesystem specific parameters of filesystem on partition (see Filesystem specific and global parameters)
  4. potential array of root subdirectories (see get_rootdirs() and Structures used for data location) - only one entry representing all data on partition is allocated by get_resources() itself.

get_rootdirs()

int get_rootdirs(struct user_partition *part, ERR_PARAM);

Function get_rootdirs expands information about directories contained in struct user_partition; it deallocates the one-member array up_dirs allocated by get_resources() and allocates a new one of length equal to up_dircount; up_dircount is set to the number of root subdirectories increased by one. Function get_rootdirs will not be supported in the first versions of the library.

See Data structures used for data location for description of array of directories.

commit_disks()

int commit_disks(struct final *, int check_only, ERR_PARAM);

commit_disks() is The Function. It gets struct final with description of current partitions and filesystems and also with description of desired situation after conversion. Some global parameters can be also specified in struct final. If check_only is set, only checks are performed and result is returned.

As current as desired configuration of partitions is specified by an array of struct disk_info. Each struct describes layout of one disk.

For description of how disk layout is specified see get_resources() (the current layout given to commit_disks() should be the same as returned by get_resources() and the future layout should have the `same form'). See Filesystem specific and global parameters for instructions how to alter filesystem parameters.

Note that record struct part_entry up_entry (ondisk format of partition entry) in struct user_partition can be left unfilled if corresponding flag (up_entryvalid) set to appropriate value (zero). In that case needed values are computed by library itself from struct partition_base.


Next Previous Contents