Low-level tags

Low-level tags — generic NAME=value interface.

Synopsis

int                 blkid_do_fullprobe                  (blkid_probe pr);
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);

Description

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).

Details

blkid_do_fullprobe ()

int                 blkid_do_fullprobe                  (blkid_probe pr);

This function gathers probing results from all enabled chains. Same as blkid_so_safeprobe() but does not check for collision between probing result.

This is string-based NAME=value interface only.

pr :

prober

Returns :

0 on success, 1 if nothing is detected or -1 on case of error.

blkid_do_probe ()

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 reseted by blkid_reset_probe() or by filter functions.

This is string-based NAME=value interface only.

Example 1. 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 2. 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().

pr :

prober

Returns :

0 on success, 1 when probing is done and -1 in case of error.

blkid_do_safeprobe ()

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.

pr :

prober

Returns :

0 on success, 1 if nothing is detected, -2 if ambivalen result is detected and -1 on case of error.

blkid_probe_get_value ()

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.

pr :

probe

num :

wanted value in range 0..N, where N is blkid_probe_numof_values() - 1

name :

pointer to return value name or NULL

data :

pointer to return value data or NULL

len :

pointer to return value length or NULL

Returns :

0 on success, or -1 in case of error.

blkid_probe_has_value ()

int                 blkid_probe_has_value               (blkid_probe pr,
                                                         const char *name);

pr :

probe

name :

name of value

Returns :

1 if value exist in probing result, otherwise 0.

blkid_probe_lookup_value ()

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.

pr :

probe

name :

name of value

data :

pointer to return value data or NULL

len :

pointer to return value length or NULL

Returns :

0 on success, or -1 in case of error.

blkid_probe_numof_values ()

int                 blkid_probe_numof_values            (blkid_probe pr);

pr :

probe

Returns :

number of values in probing result or -1 in case of error.