Top |
int | fdisk_set_script () |
struct fdisk_script * | fdisk_get_script () |
int | fdisk_apply_script () |
int | fdisk_apply_script_headers () |
struct fdisk_script * | fdisk_new_script () |
struct fdisk_script * | fdisk_new_script_from_file () |
void | fdisk_ref_script () |
const char * | fdisk_script_get_header () |
int | fdisk_script_get_nlines () |
struct fdisk_table * | fdisk_script_get_table () |
int | fdisk_script_read_context () |
int | fdisk_script_read_file () |
int | fdisk_script_read_line () |
int | fdisk_script_set_header () |
int | fdisk_script_write_file () |
void | fdisk_unref_script () |
The libfdisk scripts are based on original sfdisk script (dumps). Each script has two parts: script headers and partition table entries (partitions).
For more details about script format see sfdisk man page.
int fdisk_set_script (struct fdisk_context *cxt
,struct fdisk_script *dp
);
Sets reference to the dp
script. The script headers might be used by label
drivers to overwrite built-in defaults (for example disk label Id) and label
driver might optimize the default semantic to be more usable for scripts
(for example to not ask for primary/logical/extended partition type).
Note that script also contains reference to the fdisk context (see
fdisk_new_script()
). This context may be completely independent on
context used for fdisk_set_script()
.
int fdisk_apply_script (struct fdisk_context *cxt
,struct fdisk_script *dp
);
This function creates a new disklabel and partition within context cxt
. You
have to call fdisk_write_disklabel()
to apply changes to the device.
int fdisk_apply_script_headers (struct fdisk_context *cxt
,struct fdisk_script *dp
);
Associte context cxt
with script dp
and creates a new empty disklabel.
struct fdisk_script *
fdisk_new_script (struct fdisk_context *cxt
);
The script hold fdisk_table and additional information to read/write script to the file.
struct fdisk_script * fdisk_new_script_from_file (struct fdisk_context *cxt
,const char *filename
);
Allocates a new script and reads script from filename
.
const char * fdisk_script_get_header (struct fdisk_script *dp
,const char *name
);
struct fdisk_table *
fdisk_script_get_table (struct fdisk_script *dp
);
The table (container with partitions) is possible to create by
fdisk_script_read_context()
or fdisk_script_read_file()
, otherwise
this function returns NULL.
int fdisk_script_read_context (struct fdisk_script *dp
,struct fdisk_context *cxt
);
Reads data from the cxt
context (on disk partition table) into the script.
If the context is no specified than defaults to context used for fdisk_new_script()
.
Return: 0 on success, <0 on error.
int fdisk_script_read_file (struct fdisk_script *dp
,FILE *f
);
Reads file f
into script dp
.
int fdisk_script_read_line (struct fdisk_script *dp
,FILE *f
,char *buf
,size_t bufsz
);
Reads next line into dump.
int fdisk_script_set_header (struct fdisk_script *dp
,const char *name
,const char *data
);
The headers are used as global options for whole partition table, always one header per line.
If no data
is specified then the header is removed. If header does not exist
and data
is specified then a new header is added.
Note that libfdisk allows to specify arbitrary custom header, the default build-in headers are "unit" and "label", and some label specific headers (for example "uuid" and "name" for GPT).
int fdisk_script_write_file (struct fdisk_script *dp
,FILE *f
);
Writes script dp
to the ile f
.