libblkid Reference Manual | ||||
---|---|---|---|---|
Top | Description |
int blkid_do_fullprobe (blkid_probe pr
); int blkid_do_wipe (blkid_probe pr
,int dryrun
); int blkid_do_probe (blkid_probe pr
); int blkid_do_safeprobe (blkid_probe pr
); int blkid_probe_get_value (blkid_probe pr
,int num
,const char **name
,const char **data
,size_t *len
); int blkid_probe_has_value (blkid_probe pr
,const char *name
); int blkid_probe_lookup_value (blkid_probe pr
,const char *name
,const char **data
,size_t *len
); int blkid_probe_numof_values (blkid_probe pr
);
The probing routines inside the chain are mutually exclusive by default --
only few probing routines are marked as "tolerant". The "tolerant" probing
routines are used for filesystem which can share the same device with any
other filesystem. The blkid_do_safeprobe()
checks for the "tolerant" flag.
The SUPERBLOCKS chain is enabled by default. The all others chains is necessary to enable by blkid_probe_enable_'CHAINNAME'(). See chains specific documentation.
The blkid_do_probe()
function returns a result from only one probing
routine, and the next call from the next probing routine. It means you need
to call the function in loop, for example:
1 2 |
while((blkid_do_probe(pr) == 0) ... use result ... |
The blkid_do_safeprobe()
is the same as blkid_do_probe()
, but returns only
first probing result for every enabled chain. This function checks for
ambivalent results (e.g. more "intolerant" filesystems superblocks on the
device).
The probing result is set of NAME=value pairs (the NAME is always unique).
int blkid_do_fullprobe (blkid_probe pr
);
This function gathers probing results from all enabled chains. Same as
blkid_do_safeprobe()
but does not check for collision between probing
result.
This is string-based NAME=value interface only.
|
prober |
Returns : |
0 on success, 1 if nothing is detected or -1 on case of error. |
int blkid_do_wipe (blkid_probe pr
,int dryrun
);
This function erases the current signature detected by pr
. The pr
has to
be open in O_RDWR mode, BLKID_SUBLKS_MAGIC or/and BLKID_PARTS_MAGIC flags
has to be enabled.
After successful signature removing the pr
prober will be moved one step
back and the next blkid_do_probe()
call will again call previously called
probing function.
Example 1. wipe all filesystems or raids from the device
1 2 3 4 5 6 7 8 |
fd = open(devname, O_RDWR); blkid_probe_set_device(pr, fd, 0, 0); blkid_probe_enable_superblocks(pr, 1); blkid_probe_set_superblocks_flags(pr, BLKID_SUBLKS_MAGIC); while (blkid_do_probe(pr) == 0) blkid_do_wipe(pr, FALSE); |
|
prober |
|
if TRUE then don't touch the device. |
Returns : |
0 on success, 1 when probing is done and -1 in case of error. |
int blkid_do_probe (blkid_probe pr
);
Calls probing functions in all enabled chains. The superblocks chain is
enabled by default. The blkid_do_probe()
stores result from only one
probing function. It's necessary to call this routine in a loop to get
results from all probing functions in all chains. The probing is reset
by blkid_reset_probe()
or by filter functions.
This is string-based NAME=value interface only.
Example 2. basic case - use the first result only
1 2 3 4 5 6 7 |
if (blkid_do_probe(pr) == 0) { int nvals = blkid_probe_numof_values(pr); for (n = 0; n < nvals; n++) { if (blkid_probe_get_value(pr, n, &name, &data, &len) == 0) printf("%s = %s\n", name, data); } } |
Example 3. advanced case - probe for all signatures
1 2 3 4 |
while (blkid_do_probe(pr) == 0) { int nvals = blkid_probe_numof_values(pr); ... } |
See also blkid_reset_probe()
.
|
prober |
Returns : |
0 on success, 1 when probing is done and -1 in case of error. |
int blkid_do_safeprobe (blkid_probe pr
);
This function gathers probing results from all enabled chains and checks for ambivalent results (e.g. more filesystems on the device).
This is string-based NAME=value interface only.
Note about suberblocks chain -- the function does not check for filesystems when a RAID signature is detected. The function also does not check for collision between RAIDs. The first detected RAID is returned. The function checks for collision between partition table and RAID signature -- it's recommended to enable partitions chain together with superblocks chain.
|
prober |
Returns : |
0 on success, 1 if nothing is detected, -2 if ambivalen result is detected and -1 on case of error. |
int blkid_probe_get_value (blkid_probe pr
,int num
,const char **name
,const char **data
,size_t *len
);
Note, the len
returns length of the data
, including the terminating
'\0' character.
|
probe |
|
wanted value in range 0..N, where N is blkid_probe_numof_values() - 1 |
|
pointer to return value name or NULL |
|
pointer to return value data or NULL |
|
pointer to return value length or NULL |
Returns : |
0 on success, or -1 in case of error. |
int blkid_probe_has_value (blkid_probe pr
,const char *name
);
|
probe |
|
name of value |
Returns : |
1 if value exist in probing result, otherwise 0. |
int blkid_probe_lookup_value (blkid_probe pr
,const char *name
,const char **data
,size_t *len
);
Note, the len
returns length of the data
, including the terminating
'\0' character.
|
probe |
|
name of value |
|
pointer to return value data or NULL |
|
pointer to return value length or NULL |
Returns : |
0 on success, or -1 in case of error. |
int blkid_probe_numof_values (blkid_probe pr
);
|
probe |
Returns : |
number of values in probing result or -1 in case of error. |