diff options
Diffstat (limited to 'libdm/libdevmapper.h')
-rw-r--r-- | libdm/libdevmapper.h | 463 |
1 files changed, 442 insertions, 21 deletions
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h index 4aa9991..c853ab4 100644 --- a/libdm/libdevmapper.h +++ b/libdm/libdevmapper.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. * * This file is part of the device-mapper userspace tools. * @@ -19,6 +19,7 @@ #include <inttypes.h> #include <stdarg.h> #include <sys/types.h> +#include <sys/stat.h> #ifdef linux # include <linux/types.h> @@ -74,6 +75,11 @@ void dm_log_init(dm_log_fn fn); */ int dm_log_is_non_default(void); +/* + * Number of devices currently in suspended state (via the library). + */ +int dm_get_suspended_counter(void); + enum { DM_DEVICE_CREATE, DM_DEVICE_RELOAD, @@ -158,13 +164,33 @@ struct dm_versions { int dm_get_library_version(char *version, size_t size); int dm_task_get_driver_version(struct dm_task *dmt, char *version, size_t size); int dm_task_get_info(struct dm_task *dmt, struct dm_info *dmi); -const char *dm_task_get_name(const struct dm_task *dmt); + +/* + * This function returns dm device's UUID based on the value + * of the mangling mode set during preceding dm_task_run call: + * - unmangled UUID for DM_STRING_MANGLING_{AUTO, HEX}, + * - UUID without any changes for DM_STRING_MANGLING_NONE. + * + * To get mangled or unmangled form of the UUID directly, use + * dm_task_get_uuid_mangled or dm_task_get_uuid_unmangled function. + */ const char *dm_task_get_uuid(const struct dm_task *dmt); struct dm_deps *dm_task_get_deps(struct dm_task *dmt); -struct dm_names *dm_task_get_names(struct dm_task *dmt); struct dm_versions *dm_task_get_versions(struct dm_task *dmt); +/* + * These functions return device-mapper names based on the value + * of the mangling mode set during preceding dm_task_run call: + * - unmangled name for DM_STRING_MANGLING_{AUTO, HEX}, + * - name without any changes for DM_STRING_MANGLING_NONE. + * + * To get mangled or unmangled form of the name directly, use + * dm_task_get_name_mangled or dm_task_get_name_unmangled function. + */ +const char *dm_task_get_name(const struct dm_task *dmt); +struct dm_names *dm_task_get_names(struct dm_task *dmt); + int dm_task_set_ro(struct dm_task *dmt); int dm_task_set_newname(struct dm_task *dmt, const char *newname); int dm_task_set_newuuid(struct dm_task *dmt, const char *newuuid); @@ -184,6 +210,19 @@ int dm_task_no_open_count(struct dm_task *dmt); int dm_task_skip_lockfs(struct dm_task *dmt); int dm_task_query_inactive_table(struct dm_task *dmt); int dm_task_suppress_identical_reload(struct dm_task *dmt); +int dm_task_secure_data(struct dm_task *dmt); +int dm_task_retry_remove(struct dm_task *dmt); + +/* + * Enable checks for common mistakes such as issuing ioctls in an unsafe order. + */ +int dm_task_enable_checks(struct dm_task *dmt); + +typedef enum { + DM_ADD_NODE_ON_RESUME, /* add /dev/mapper node with dmsetup resume */ + DM_ADD_NODE_ON_CREATE /* add /dev/mapper node with dmsetup create */ +} dm_add_node_t; +int dm_task_set_add_node(struct dm_task *dmt, dm_add_node_t add_node); /* * Control read_ahead. @@ -219,6 +258,30 @@ void *dm_get_next_target(struct dm_task *dmt, void *next, uint64_t *start, uint64_t *length, char **target_type, char **params); +/* Parse params from STATUS call for thin_pool target */ +struct dm_pool; + +struct dm_status_thin_pool { + uint64_t transaction_id; + uint64_t used_metadata_blocks; + uint64_t total_metadata_blocks; + uint64_t used_data_blocks; + uint64_t total_data_blocks; + uint64_t held_metadata_root; +}; + +int dm_get_status_thin_pool(struct dm_pool *mem, const char *params, + struct dm_status_thin_pool **status); + +/* Parse params from STATUS call for thin target */ +struct dm_status_thin { + uint64_t mapped_sectors; + uint64_t highest_mapped_sector; +}; + +int dm_get_status_thin(struct dm_pool *mem, const char *params, + struct dm_status_thin **status); + /* * Call this to actually run the ioctl. */ @@ -231,17 +294,96 @@ int dm_task_run(struct dm_task *dmt); void dm_task_update_nodes(void); /* + * Mangling support + * + * Character whitelist: 0-9, A-Z, a-z, #+-.:=@_ + * HEX mangling format: \xNN, NN being the hex value of the character. + * (whitelist and format supported by udev) +*/ +typedef enum { + DM_STRING_MANGLING_NONE, /* do not mangle at all */ + DM_STRING_MANGLING_AUTO, /* mangle only if not already mangled with hex, error when mixed */ + DM_STRING_MANGLING_HEX /* always mangle with hex encoding, no matter what the input is */ +} dm_string_mangling_t; + +/* + * Set/get mangling mode used for device-mapper names and uuids. + */ +int dm_set_name_mangling_mode(dm_string_mangling_t name_mangling); +dm_string_mangling_t dm_get_name_mangling_mode(void); + +/* + * Get mangled/unmangled form of the device-mapper name or uuid + * irrespective of the global setting (set by dm_set_name_mangling_mode). + * The name or uuid returned needs to be freed after use by calling dm_free! + */ +char *dm_task_get_name_mangled(const struct dm_task *dmt); +char *dm_task_get_name_unmangled(const struct dm_task *dmt); +char *dm_task_get_uuid_mangled(const struct dm_task *dmt); +char *dm_task_get_uuid_unmangled(const struct dm_task *dmt); + +/* * Configure the device-mapper directory */ int dm_set_dev_dir(const char *dir); const char *dm_dir(void); /* + * Configure sysfs directory, /sys by default + */ +int dm_set_sysfs_dir(const char *dir); +const char *dm_sysfs_dir(void); + +/* + * Configure default UUID prefix string. + * Conventionally this is a short capitalised prefix indicating the subsystem + * that is managing the devices, e.g. "LVM-" or "MPATH-". + * To support stacks of devices from different subsystems, recursive functions + * stop recursing if they reach a device with a different prefix. + */ +int dm_set_uuid_prefix(const char *uuid_prefix); +const char *dm_uuid_prefix(void); + +/* * Determine whether a major number belongs to device-mapper or not. */ int dm_is_dm_major(uint32_t major); /* + * Get associated device name for given major and minor number by reading + * the sysfs content. If this is a dm device, get associated dm name, the one + * that appears in /dev/mapper. DM names could be resolved this way only if + * kernel used >= 2.6.29, kernel name is found otherwise (e.g. dm-0). + * If prefer_kernel_name is set, the kernel name is always preferred over + * device-mapper name for dm devices no matter what the kernel version is. + * For non-dm devices, we always get associated kernel name, e.g sda, md0 etc. + * Returns 0 on error or if sysfs is not used (or configured incorrectly), + * otherwise returns 1 and the supplied buffer holds the device name. + */ +int dm_device_get_name(uint32_t major, uint32_t minor, + int prefer_kernel_name, + char *buf, size_t buf_size); + +/* + * Determine whether a device has any holders (devices + * using this device). If sysfs is not used (or configured + * incorrectly), returns 0. + */ +int dm_device_has_holders(uint32_t major, uint32_t minor); + +/* + * Determine whether a device contains mounted filesystem. + * If sysfs is not used (or configured incorrectly), returns 0. + */ +int dm_device_has_mounted_fs(uint32_t major, uint32_t minor); + + +/* + * Initialise library + */ +void dm_lib_init(void) __attribute__((constructor)); + +/* * Release library resources */ void dm_lib_release(void); @@ -384,6 +526,11 @@ void dm_tree_skip_lockfs(struct dm_tree_node *dnode); void dm_tree_use_no_flush_suspend(struct dm_tree_node *dnode); /* + * Retry removal of each device if not successful. + */ +void dm_tree_retry_remove(struct dm_tree_node *dnode); + +/* * Is the uuid prefix present in the tree? * Only returns 0 if every node was checked successfully. * Returns 1 if the tree walk has to be aborted. @@ -450,6 +597,14 @@ int dm_tree_node_add_mirror_target_log(struct dm_tree_node *node, unsigned area_count, uint32_t flags); +int dm_tree_node_add_raid_target(struct dm_tree_node *node, + uint64_t size, + const char *raid_type, + uint32_t region_size, + uint32_t stripe_size, + uint64_t rebuilds, + uint64_t flags); + /* * Replicator operation mode * Note: API for Replicator is not yet stable @@ -484,6 +639,63 @@ int dm_tree_node_add_replicator_dev_target(struct dm_tree_node *node, uint32_t slog_region_size); /* End of Replicator API */ +/* + * FIXME: Defines bellow are based on kernel's dm-thin.c defines + * DATA_DEV_BLOCK_SIZE_MIN_SECTORS (64 * 1024 >> SECTOR_SHIFT) + * DATA_DEV_BLOCK_SIZE_MAX_SECTORS (1024 * 1024 * 1024 >> SECTOR_SHIFT) + */ +#define DM_THIN_MIN_DATA_BLOCK_SIZE (UINT32_C(128)) +#define DM_THIN_MAX_DATA_BLOCK_SIZE (UINT32_C(2097152)) + +int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node, + uint64_t size, + uint64_t transaction_id, + const char *metadata_uuid, + const char *pool_uuid, + uint32_t data_block_size, + uint64_t low_water_mark, + unsigned skip_block_zeroing); + +/* Supported messages for thin provision target */ +typedef enum { + DM_THIN_MESSAGE_CREATE_SNAP, /* device_id, origin_id */ + DM_THIN_MESSAGE_CREATE_THIN, /* device_id */ + DM_THIN_MESSAGE_DELETE, /* device_id */ + DM_THIN_MESSAGE_SET_TRANSACTION_ID, /* current_id, new_id */ + DM_THIN_MESSAGE_RESERVE_METADATA_SNAP, /* target version >= 1.1 */ + DM_THIN_MESSAGE_RELEASE_METADATA_SNAP, /* target version >= 1.1 */ +} dm_thin_message_t; + +int dm_tree_node_add_thin_pool_message(struct dm_tree_node *node, + dm_thin_message_t type, + uint64_t id1, uint64_t id2); + +/* + * Set thin pool discard features + * ignore - Disable support for discards + * no_passdown - Don't pass discards down to underlying data device, + * just remove the mapping + * Feature is available since version 1.1 of the thin target. + */ +int dm_tree_node_set_thin_pool_discard(struct dm_tree_node *node, + unsigned ignore, + unsigned no_passdown); + +/* + * FIXME: Defines bellow are based on kernel's dm-thin.c defines + * MAX_DEV_ID ((1 << 24) - 1) + */ +#define DM_THIN_MAX_DEVICE_ID (UINT32_C((1 << 24) - 1)) +int dm_tree_node_add_thin_target(struct dm_tree_node *node, + uint64_t size, + const char *pool_uuid, + uint32_t device_id); + +int dm_tree_node_set_thin_external_origin(struct dm_tree_node *node, + const char *external_uuid); + +void dm_tree_node_set_udev_flags(struct dm_tree_node *node, uint16_t udev_flags); + void dm_tree_node_set_presuspend_node(struct dm_tree_node *node, struct dm_tree_node *presuspend_node); @@ -493,12 +705,31 @@ int dm_tree_node_add_target_area(struct dm_tree_node *node, uint64_t offset); /* + * Only for temporarily-missing raid devices where changes are tracked. + */ +int dm_tree_node_add_null_area(struct dm_tree_node *node, uint64_t offset); + +/* * Set readahead (in sectors) after loading the node. */ void dm_tree_node_set_read_ahead(struct dm_tree_node *dnode, uint32_t read_ahead, uint32_t read_ahead_flags); +/* + * Set node callback hook before de/activation. + * Callback is called before 'activation' of node for activation tree, + * or 'deactivation' of node for deactivation tree. + */ +typedef enum { + DM_NODE_CALLBACK_PRELOADED, /* Node has preload deps */ + DM_NODE_CALLBACK_DEACTIVATED, /* Node is deactivated */ +} dm_node_callback_t; +typedef int (*dm_node_callback_fn) (struct dm_tree_node *node, + dm_node_callback_t type, void *cb_data); +void dm_tree_node_set_callback(struct dm_tree_node *node, + dm_node_callback_fn cb, void *cb_data); + void dm_tree_set_cookie(struct dm_tree_node *node, uint32_t cookie); uint32_t dm_tree_get_cookie(struct dm_tree_node *node); @@ -510,13 +741,19 @@ uint32_t dm_tree_get_cookie(struct dm_tree_node *node); * Memory management *******************/ -void *dm_malloc_aux(size_t s, const char *file, int line); -void *dm_malloc_aux_debug(size_t s, const char *file, int line); -void *dm_zalloc_aux(size_t s, const char *file, int line); -void *dm_zalloc_aux_debug(size_t s, const char *file, int line); -char *dm_strdup_aux(const char *str, const char *file, int line); +void *dm_malloc_aux(size_t s, const char *file, int line) + __attribute__((malloc)) __attribute__((__warn_unused_result__)); +void *dm_malloc_aux_debug(size_t s, const char *file, int line) + __attribute__((__warn_unused_result__)); +void *dm_zalloc_aux(size_t s, const char *file, int line) + __attribute__((malloc)) __attribute__((__warn_unused_result__)); +void *dm_zalloc_aux_debug(size_t s, const char *file, int line) + __attribute__((__warn_unused_result__)); +char *dm_strdup_aux(const char *str, const char *file, int line) + __attribute__((malloc)) __attribute__((__warn_unused_result__)); void dm_free_aux(void *p); -void *dm_realloc_aux(void *p, unsigned int s, const char *file, int line); +void *dm_realloc_aux(void *p, unsigned int s, const char *file, int line) + __attribute__((__warn_unused_result__)); int dm_dump_memory_debug(void); void dm_bounds_check_debug(void); @@ -579,16 +816,35 @@ void dm_bounds_check_debug(void); struct dm_pool; /* constructor and destructor */ -struct dm_pool *dm_pool_create(const char *name, size_t chunk_hint); +struct dm_pool *dm_pool_create(const char *name, size_t chunk_hint) + __attribute__((__warn_unused_result__)); void dm_pool_destroy(struct dm_pool *p); /* simple allocation/free routines */ -void *dm_pool_alloc(struct dm_pool *p, size_t s); -void *dm_pool_alloc_aligned(struct dm_pool *p, size_t s, unsigned alignment); +void *dm_pool_alloc(struct dm_pool *p, size_t s) + __attribute__((__warn_unused_result__)); +void *dm_pool_alloc_aligned(struct dm_pool *p, size_t s, unsigned alignment) + __attribute__((__warn_unused_result__)); void dm_pool_empty(struct dm_pool *p); void dm_pool_free(struct dm_pool *p, void *ptr); /* + * To aid debugging, a pool can be locked. Any modifications made + * to the content of the pool while it is locked can be detected. + * Default compilation is using a crc checksum to notice modifications. + * The pool locking is using the mprotect with the compilation flag + * DEBUG_ENFORCE_POOL_LOCKING to enforce the memory protection. + */ +/* query pool lock status */ +int dm_pool_locked(struct dm_pool *p); +/* mark pool as locked */ +int dm_pool_lock(struct dm_pool *p, int crc) + __attribute__((__warn_unused_result__)); +/* mark pool as unlocked */ +int dm_pool_unlock(struct dm_pool *p, int crc) + __attribute__((__warn_unused_result__)); + +/* * Object building routines: * * These allow you to 'grow' an object, useful for @@ -639,9 +895,12 @@ void *dm_pool_end_object(struct dm_pool *p); void dm_pool_abandon_object(struct dm_pool *p); /* utilities */ -char *dm_pool_strdup(struct dm_pool *p, const char *str); -char *dm_pool_strndup(struct dm_pool *p, const char *str, size_t n); -void *dm_pool_zalloc(struct dm_pool *p, size_t s); +char *dm_pool_strdup(struct dm_pool *p, const char *str) + __attribute__((__warn_unused_result__)); +char *dm_pool_strndup(struct dm_pool *p, const char *str, size_t n) + __attribute__((__warn_unused_result__)); +void *dm_pool_zalloc(struct dm_pool *p, size_t s) + __attribute__((__warn_unused_result__)); /****************** * bitset functions @@ -699,7 +958,8 @@ struct dm_hash_node; typedef void (*dm_hash_iterate_fn) (void *data); -struct dm_hash_table *dm_hash_create(unsigned size_hint); +struct dm_hash_table *dm_hash_create(unsigned size_hint) + __attribute__((__warn_unused_result__)); void dm_hash_destroy(struct dm_hash_table *t); void dm_hash_wipe(struct dm_hash_table *t); @@ -707,10 +967,10 @@ void *dm_hash_lookup(struct dm_hash_table *t, const char *key); int dm_hash_insert(struct dm_hash_table *t, const char *key, void *data); void dm_hash_remove(struct dm_hash_table *t, const char *key); -void *dm_hash_lookup_binary(struct dm_hash_table *t, const char *key, uint32_t len); -int dm_hash_insert_binary(struct dm_hash_table *t, const char *key, uint32_t len, +void *dm_hash_lookup_binary(struct dm_hash_table *t, const void *key, uint32_t len); +int dm_hash_insert_binary(struct dm_hash_table *t, const void *key, uint32_t len, void *data); -void dm_hash_remove_binary(struct dm_hash_table *t, const char *key, uint32_t len); +void dm_hash_remove_binary(struct dm_hash_table *t, const void *key, uint32_t len); unsigned dm_hash_get_num_entries(struct dm_hash_table *t); void dm_hash_iter(struct dm_hash_table *t, dm_hash_iterate_fn f); @@ -770,7 +1030,7 @@ void dm_list_del(struct dm_list *elem); void dm_list_move(struct dm_list *head, struct dm_list *elem); /* - * Join 'head1' to the of 'head'. + * Join 'head1' to the end of 'head'. */ void dm_list_splice(struct dm_list *head, struct dm_list *head1); @@ -968,6 +1228,52 @@ int dm_snprintf(char *buf, size_t bufsize, const char *format, ...) */ const char *dm_basename(const char *path); +/* + * Returns number of occurrences of 'c' in 'str' of length 'size'. + */ +unsigned dm_count_chars(const char *str, size_t len, const int c); + +/* + * Length of string after escaping double quotes and backslashes. + */ +size_t dm_escaped_len(const char *str); + +/* + * <vg>-<lv>-<layer> or if !layer just <vg>-<lv>. + */ +char *dm_build_dm_name(struct dm_pool *mem, const char *vgname, + const char *lvname, const char *layer); +char *dm_build_dm_uuid(struct dm_pool *mem, const char *prefix, const char *lvid, const char *layer); + +/* + * Copies a string, quoting double quotes with backslashes. + */ +char *dm_escape_double_quotes(char *out, const char *src); + +/* + * Undo quoting in situ. + */ +void dm_unescape_double_quotes(char *src); + +/* + * Unescape colons and "at" signs in situ and save the substrings + * starting at the position of the first unescaped colon and the + * first unescaped "at" sign. This is normally used to unescape + * device names used as PVs. + */ +void dm_unescape_colons_and_at_signs(char *src, + char **substr_first_unquoted_colon, + char **substr_first_unquoted_at_sign); + +/* + * Replacement for strncpy() function. + * + * Copies no more than n bytes from string pointed by src to the buffer + * pointed by dest and ensure string is finished with '\0'. + * Returns 0 if the whole string does not fit. + */ +int dm_strncpy(char *dest, const char *src, size_t n); + /************************** * file/stream manipulation **************************/ @@ -978,6 +1284,8 @@ const char *dm_basename(const char *path); */ int dm_create_dir(const char *dir); +int dm_is_empty_dir(const char *dir); + /* * Close a stream, with nicer error checking than fclose's. * Derived from gnulib's close-stream.c. @@ -995,6 +1303,7 @@ int dm_fclose(FILE *stream); */ int dm_asprintf(char **buf, const char *format, ...) __attribute__ ((format(printf, 2, 3))); +int dm_vasprintf(char **buf, const char *format, va_list ap); /* * create lockfile (pidfile) - create and lock a lock file @@ -1117,7 +1426,7 @@ int dm_report_set_output_field_name_prefix(struct dm_report *rh, * They take care of allocating copies of the data. */ int dm_report_field_string(struct dm_report *rh, struct dm_report_field *field, - const char **data); + const char *const *data); int dm_report_field_int32(struct dm_report *rh, struct dm_report_field *field, const int32_t *data); int dm_report_field_uint32(struct dm_report *rh, struct dm_report_field *field, @@ -1135,7 +1444,112 @@ int dm_report_field_uint64(struct dm_report *rh, struct dm_report_field *field, void dm_report_field_set_value(struct dm_report_field *field, const void *value, const void *sortvalue); +/************************* + * config file parse/print + *************************/ +typedef enum { + DM_CFG_INT, + DM_CFG_FLOAT, + DM_CFG_STRING, + DM_CFG_EMPTY_ARRAY +} dm_config_value_type_t; + +struct dm_config_value { + dm_config_value_type_t type; + + union { + int64_t i; + float f; + double d; /* Unused. */ + const char *str; + } v; + + struct dm_config_value *next; /* For arrays */ +}; + +struct dm_config_node { + const char *key; + struct dm_config_node *parent, *sib, *child; + struct dm_config_value *v; +}; + +struct dm_config_tree { + struct dm_config_node *root; + struct dm_config_tree *cascade; + struct dm_pool *mem; + void *custom; +}; + +struct dm_config_tree *dm_config_create(void); +struct dm_config_tree *dm_config_from_string(const char *config_settings); +int dm_config_parse(struct dm_config_tree *cft, const char *start, const char *end); + +void *dm_config_get_custom(struct dm_config_tree *cft); +void dm_config_set_custom(struct dm_config_tree *cft, void *custom); + +/* + * When searching, first_cft is checked before second_cft. + */ +struct dm_config_tree *dm_config_insert_cascaded_tree(struct dm_config_tree *first_cft, struct dm_config_tree *second_cft); + +/* + * If there's a cascaded dm_config_tree, remove the top layer + * and return the layer below. Otherwise return NULL. + */ +struct dm_config_tree *dm_config_remove_cascaded_tree(struct dm_config_tree *cft); + +void dm_config_destroy(struct dm_config_tree *cft); + +typedef int (*dm_putline_fn)(const char *line, void *baton); +/* Write the node and any subsequent siblings it has. */ +int dm_config_write_node(const struct dm_config_node *cn, dm_putline_fn putline, void *baton); +/* Write given node only without subsequent siblings. */ +int dm_config_write_one_node(const struct dm_config_node *cn, dm_putline_fn putline, void *baton); + +struct dm_config_node *dm_config_find_node(const struct dm_config_node *cn, const char *path); +int dm_config_has_node(const struct dm_config_node *cn, const char *path); +const char *dm_config_find_str(const struct dm_config_node *cn, const char *path, const char *fail); +const char *dm_config_find_str_allow_empty(const struct dm_config_node *cn, const char *path, const char *fail); +int dm_config_find_int(const struct dm_config_node *cn, const char *path, int fail); +int64_t dm_config_find_int64(const struct dm_config_node *cn, const char *path, int64_t fail); +float dm_config_find_float(const struct dm_config_node *cn, const char *path, float fail); + +const struct dm_config_node *dm_config_tree_find_node(const struct dm_config_tree *cft, const char *path); +const char *dm_config_tree_find_str(const struct dm_config_tree *cft, const char *path, const char *fail); +const char *dm_config_tree_find_str_allow_empty(const struct dm_config_tree *cft, const char *path, const char *fail); +int dm_config_tree_find_int(const struct dm_config_tree *cft, const char *path, int fail); +int64_t dm_config_tree_find_int64(const struct dm_config_tree *cft, const char *path, int64_t fail); +float dm_config_tree_find_float(const struct dm_config_tree *cft, const char *path, float fail); +int dm_config_tree_find_bool(const struct dm_config_tree *cft, const char *path, int fail); + +/* + * Understands (0, ~0), (y, n), (yes, no), (on, + * off), (true, false). + */ +int dm_config_find_bool(const struct dm_config_node *cn, const char *path, int fail); + +int dm_config_get_uint32(const struct dm_config_node *cn, const char *path, uint32_t *result); +int dm_config_get_uint64(const struct dm_config_node *cn, const char *path, uint64_t *result); +int dm_config_get_str(const struct dm_config_node *cn, const char *path, const char **result); +int dm_config_get_list(const struct dm_config_node *cn, const char *path, const struct dm_config_value **result); +int dm_config_get_section(const struct dm_config_node *cn, const char *path, const struct dm_config_node **result); + +unsigned dm_config_maybe_section(const char *str, unsigned len); + +const char *dm_config_parent_name(const struct dm_config_node *n); + +struct dm_config_node *dm_config_clone_node_with_mem(struct dm_pool *mem, const struct dm_config_node *node, int siblings); +struct dm_config_node *dm_config_create_node(struct dm_config_tree *cft, const char *key); +struct dm_config_value *dm_config_create_value(struct dm_config_tree *cft); +struct dm_config_node *dm_config_clone_node(struct dm_config_tree *cft, const struct dm_config_node *cn, int siblings); + +struct dm_pool *dm_config_memory(struct dm_config_tree *cft); + +/* Udev device directory. */ +#define DM_UDEV_DEV_DIR "/dev/" + /* Cookie prefixes. + * * The cookie value consists of a prefix (16 bits) and a base (16 bits). * We can use the prefix to store the flags. These flags are sent to * kernel within given dm task. When returned back to userspace in @@ -1143,6 +1557,7 @@ void dm_report_field_set_value(struct dm_report_field *field, const void *value, * of udev rules we use by decoding the cookie prefix. When doing the * notification, we replace the cookie prefix with DM_COOKIE_MAGIC, * so we notify the right semaphore. + * * It is still possible to use cookies for passing the flags to udev * rules even when udev_sync is disabled. The base part of the cookie * will be zero (there's no notification semaphore) and prefix will be @@ -1214,11 +1629,17 @@ void dm_udev_set_sync_support(int sync_with_udev); int dm_udev_get_sync_support(void); void dm_udev_set_checking(int checking); int dm_udev_get_checking(void); + +/* + * Default value to get new auto generated cookie created + */ +#define DM_COOKIE_AUTO_CREATE 0 int dm_udev_create_cookie(uint32_t *cookie); int dm_udev_complete(uint32_t cookie); int dm_udev_wait(uint32_t cookie); #define DM_DEV_DIR_UMASK 0022 +#define DM_CONTROL_NODE_UMASK 0177 #ifdef __cplusplus } |