libmount Reference Manual | ||||
---|---|---|---|---|
Top | Description |
struct libmnt_cache; struct libmnt_cache * mnt_new_cache (void
); void mnt_free_cache (struct libmnt_cache *cache
); void mnt_ref_cache (struct libmnt_cache *cache
); void mnt_unref_cache (struct libmnt_cache *cache
); int mnt_cache_device_has_tag (struct libmnt_cache *cache
,const char *devname
,const char *token
,const char *value
); char * mnt_cache_find_tag_value (struct libmnt_cache *cache
,const char *devname
,const char *token
); int mnt_cache_read_tags (struct libmnt_cache *cache
,const char *devname
); char * mnt_get_fstype (const char *devname
,int *ambi
,struct libmnt_cache *cache
); char * mnt_pretty_path (const char *path
,struct libmnt_cache *cache
); char * mnt_resolve_path (const char *path
,struct libmnt_cache *cache
); char * mnt_resolve_spec (const char *spec
,struct libmnt_cache *cache
); char * mnt_resolve_tag (const char *token
,const char *value
,struct libmnt_cache *cache
);
The cache is a very simple API for working with tags (LABEL, UUID, ...) and paths. The cache uses libblkid as a backend for TAGs resolution.
All returned paths are always canonicalized.
struct libmnt_cache * mnt_new_cache (void
);
Returns : |
new struct libmnt_cache instance or NULL in case of ENOMEM error. |
void mnt_free_cache (struct libmnt_cache *cache
);
Deallocates the cache. This function does not care about reference count. Don't
use this function directly -- it's better to use use mnt_unref_cache()
.
|
pointer to struct libmnt_cache instance |
void mnt_ref_cache (struct libmnt_cache *cache
);
Increments reference counter.
|
cache pointer |
void mnt_unref_cache (struct libmnt_cache *cache
);
De-increments reference counter, on zero the cache is automatically
deallocated by mnt_free_cache()
.
|
cache pointer |
int mnt_cache_device_has_tag (struct libmnt_cache *cache
,const char *devname
,const char *token
,const char *value
);
Look up cache
to check if tag
+value
are associated with devname
.
|
paths cache |
|
path to the device |
|
tag name (e.g "LABEL") |
|
tag value |
Returns : |
1 on success or 0. |
char * mnt_cache_find_tag_value (struct libmnt_cache *cache
,const char *devname
,const char *token
);
|
cache for results |
|
device name |
|
tag name ("LABEL" or "UUID") |
Returns : |
LABEL or UUID for the devname or NULL in case of error. |
int mnt_cache_read_tags (struct libmnt_cache *cache
,const char *devname
);
Reads devname
LABEL and UUID to the cache
.
|
pointer to struct libmnt_cache instance |
|
path device |
Returns : |
0 if at least one tag was added, 1 if no tag was added or negative number in case of error. |
char * mnt_get_fstype (const char *devname
,int *ambi
,struct libmnt_cache *cache
);
|
device name |
|
returns TRUE if probing result is ambivalent (optional argument) |
|
cache for results or NULL |
Returns : |
filesystem type or NULL in case of error. The result has to be
deallocated by free() if cache is NULL. |
char * mnt_pretty_path (const char *path
,struct libmnt_cache *cache
);
Converts path:
to the absolute path
/dev/dm-N to /dev/mapper/name
/dev/loopN to the loop backing filename
empty path (NULL) to 'none'
|
any path |
|
NULL or pointer to the cache |
Returns : |
newly allocated string with path, result always has to be deallocated
by free() . |
char * mnt_resolve_path (const char *path
,struct libmnt_cache *cache
);
Converts path:
to the absolute path
/dev/dm-N to /dev/mapper/name
|
"native" path |
|
cache for results or NULL |
Returns : |
absolute path or NULL in case of error. The result has to be
deallocated by free() if cache is NULL. |
char * mnt_resolve_spec (const char *spec
,struct libmnt_cache *cache
);
|
path or tag |
|
paths cache |
Returns : |
canonicalized path or NULL. The result has to be
deallocated by free() if cache is NULL. |