164
164
int dm_get_library_version(char *version, size_t size);
165
165
int dm_task_get_driver_version(struct dm_task *dmt, char *version, size_t size);
166
166
int dm_task_get_info(struct dm_task *dmt, struct dm_info *dmi);
169
* This function returns dm device's UUID based on the value
170
* of the mangling mode set during preceding dm_task_run call:
171
* - unmangled UUID for DM_STRING_MANGLING_{AUTO, HEX},
172
* - UUID without any changes for DM_STRING_MANGLING_NONE.
174
* To get mangled or unmangled form of the UUID directly, use
175
* dm_task_get_uuid_mangled or dm_task_get_uuid_unmangled function.
167
177
const char *dm_task_get_uuid(const struct dm_task *dmt);
169
179
struct dm_deps *dm_task_get_deps(struct dm_task *dmt);
297
307
} dm_string_mangling_t;
300
* Set/get mangling mode used for device-mapper names.
310
* Set/get mangling mode used for device-mapper names and uuids.
302
312
int dm_set_name_mangling_mode(dm_string_mangling_t name_mangling);
303
313
dm_string_mangling_t dm_get_name_mangling_mode(void);
306
* Get mangled/unmangled form of the device-mapper name
316
* Get mangled/unmangled form of the device-mapper name or uuid
307
317
* irrespective of the global setting (set by dm_set_name_mangling_mode).
308
* The name returned needs to be freed after use by calling dm_free!
318
* The name or uuid returned needs to be freed after use by calling dm_free!
310
320
char *dm_task_get_name_mangled(const struct dm_task *dmt);
311
321
char *dm_task_get_name_unmangled(const struct dm_task *dmt);
322
char *dm_task_get_uuid_mangled(const struct dm_task *dmt);
323
char *dm_task_get_uuid_unmangled(const struct dm_task *dmt);
314
326
* Configure the device-mapper directory
650
662
DM_THIN_MESSAGE_CREATE_THIN, /* device_id */
651
663
DM_THIN_MESSAGE_DELETE, /* device_id */
652
664
DM_THIN_MESSAGE_SET_TRANSACTION_ID, /* current_id, new_id */
665
DM_THIN_MESSAGE_RESERVE_METADATA_SNAP, /* target version >= 1.1 */
666
DM_THIN_MESSAGE_RELEASE_METADATA_SNAP, /* target version >= 1.1 */
653
667
} dm_thin_message_t;
655
669
int dm_tree_node_add_thin_pool_message(struct dm_tree_node *node,
657
671
uint64_t id1, uint64_t id2);
674
* Set thin pool discard features
675
* ignore - Disable support for discards
676
* no_passdown - Don't pass discards down to underlying data device,
677
* just remove the mapping
678
* Feature is available since version 1.1 of the thin target.
680
int dm_tree_node_set_thin_pool_discard(struct dm_tree_node *node,
682
unsigned no_passdown);
660
685
* FIXME: Defines bellow are based on kernel's dm-thin.c defines
661
686
* MAX_DEV_ID ((1 << 24) - 1)
666
691
const char *pool_uuid,
667
692
uint32_t device_id);
694
int dm_tree_node_set_thin_external_origin(struct dm_tree_node *node,
695
const char *external_uuid);
669
697
void dm_tree_node_set_udev_flags(struct dm_tree_node *node, uint16_t udev_flags);
671
699
void dm_tree_node_set_presuspend_node(struct dm_tree_node *node,
713
741
* Memory management
714
742
*******************/
716
void *dm_malloc_aux(size_t s, const char *file, int line);
717
void *dm_malloc_aux_debug(size_t s, const char *file, int line);
718
void *dm_zalloc_aux(size_t s, const char *file, int line);
719
void *dm_zalloc_aux_debug(size_t s, const char *file, int line);
720
char *dm_strdup_aux(const char *str, const char *file, int line);
744
void *dm_malloc_aux(size_t s, const char *file, int line)
745
__attribute__((malloc)) __attribute__((__warn_unused_result__));
746
void *dm_malloc_aux_debug(size_t s, const char *file, int line)
747
__attribute__((__warn_unused_result__));
748
void *dm_zalloc_aux(size_t s, const char *file, int line)
749
__attribute__((malloc)) __attribute__((__warn_unused_result__));
750
void *dm_zalloc_aux_debug(size_t s, const char *file, int line)
751
__attribute__((__warn_unused_result__));
752
char *dm_strdup_aux(const char *str, const char *file, int line)
753
__attribute__((malloc)) __attribute__((__warn_unused_result__));
721
754
void dm_free_aux(void *p);
722
void *dm_realloc_aux(void *p, unsigned int s, const char *file, int line);
755
void *dm_realloc_aux(void *p, unsigned int s, const char *file, int line)
756
__attribute__((__warn_unused_result__));
723
757
int dm_dump_memory_debug(void);
724
758
void dm_bounds_check_debug(void);
784
818
/* constructor and destructor */
785
struct dm_pool *dm_pool_create(const char *name, size_t chunk_hint);
819
struct dm_pool *dm_pool_create(const char *name, size_t chunk_hint)
820
__attribute__((__warn_unused_result__));
786
821
void dm_pool_destroy(struct dm_pool *p);
788
823
/* simple allocation/free routines */
789
void *dm_pool_alloc(struct dm_pool *p, size_t s);
790
void *dm_pool_alloc_aligned(struct dm_pool *p, size_t s, unsigned alignment);
824
void *dm_pool_alloc(struct dm_pool *p, size_t s)
825
__attribute__((__warn_unused_result__));
826
void *dm_pool_alloc_aligned(struct dm_pool *p, size_t s, unsigned alignment)
827
__attribute__((__warn_unused_result__));
791
828
void dm_pool_empty(struct dm_pool *p);
792
829
void dm_pool_free(struct dm_pool *p, void *ptr);
858
895
void dm_pool_abandon_object(struct dm_pool *p);
861
char *dm_pool_strdup(struct dm_pool *p, const char *str);
862
char *dm_pool_strndup(struct dm_pool *p, const char *str, size_t n);
863
void *dm_pool_zalloc(struct dm_pool *p, size_t s);
898
char *dm_pool_strdup(struct dm_pool *p, const char *str)
899
__attribute__((__warn_unused_result__));
900
char *dm_pool_strndup(struct dm_pool *p, const char *str, size_t n)
901
__attribute__((__warn_unused_result__));
902
void *dm_pool_zalloc(struct dm_pool *p, size_t s)
903
__attribute__((__warn_unused_result__));
865
905
/******************
866
906
* bitset functions
919
959
typedef void (*dm_hash_iterate_fn) (void *data);
921
struct dm_hash_table *dm_hash_create(unsigned size_hint);
961
struct dm_hash_table *dm_hash_create(unsigned size_hint)
962
__attribute__((__warn_unused_result__));
922
963
void dm_hash_destroy(struct dm_hash_table *t);
923
964
void dm_hash_wipe(struct dm_hash_table *t);
1263
1304
int dm_asprintf(char **buf, const char *format, ...)
1264
1305
__attribute__ ((format(printf, 2, 3)));
1306
int dm_vasprintf(char **buf, const char *format, va_list ap);
1267
1309
* create lockfile (pidfile) - create and lock a lock file
1459
1501
void dm_config_destroy(struct dm_config_tree *cft);
1461
1503
typedef int (*dm_putline_fn)(const char *line, void *baton);
1504
/* Write the node and any subsequent siblings it has. */
1462
1505
int dm_config_write_node(const struct dm_config_node *cn, dm_putline_fn putline, void *baton);
1506
/* Write given node only without subsequent siblings. */
1507
int dm_config_write_one_node(const struct dm_config_node *cn, dm_putline_fn putline, void *baton);
1464
1509
struct dm_config_node *dm_config_find_node(const struct dm_config_node *cn, const char *path);
1465
1510
int dm_config_has_node(const struct dm_config_node *cn, const char *path);