2 * Copyright (C) 2001 Sistina Software (UK) Limited.
4 * This file is released under the LGPL.
7 #ifndef LIB_DEVICE_MAPPER_H
8 #define LIB_DEVICE_MAPPER_H
11 #include <sys/types.h>
14 # include <linux/types.h>
18 * Since it is quite laborious to build the ioctl
19 * arguments for the device-mapper people are
20 * encouraged to use this library.
22 * You will need to build a struct dm_task for
23 * each ioctl command you want to execute.
26 typedef void (*dm_log_fn) (int level, const char *file, int line,
30 * The library user may wish to register their own
31 * logging function, by default errors go to
34 void dm_log_init(dm_log_fn fn);
35 void dm_log_init_verbose(int level);
65 struct dm_task *dm_task_create(int type);
66 void dm_task_destroy(struct dm_task *dmt);
68 int dm_task_set_name(struct dm_task *dmt, const char *name);
69 int dm_task_set_uuid(struct dm_task *dmt, const char *uuid);
72 * Retrieve attributes after an info.
82 uint32_t minor; /* minor device number */
83 int read_only; /* 0:read-write; 1:read-only */
96 uint32_t next; /* Offset to next struct from start of this struct */
100 int dm_get_library_version(char *version, size_t size);
101 int dm_task_get_driver_version(struct dm_task *dmt, char *version, size_t size);
102 int dm_task_get_info(struct dm_task *dmt, struct dm_info *dmi);
103 const char *dm_task_get_name(struct dm_task *dmt);
104 const char *dm_task_get_uuid(struct dm_task *dmt);
106 struct dm_deps *dm_task_get_deps(struct dm_task *dmt);
107 struct dm_names *dm_task_get_names(struct dm_task *dmt);
109 int dm_task_set_ro(struct dm_task *dmt);
110 int dm_task_set_newname(struct dm_task *dmt, const char *newname);
111 int dm_task_set_minor(struct dm_task *dmt, int minor);
112 int dm_task_set_major(struct dm_task *dmt, int major);
113 int dm_task_set_event_nr(struct dm_task *dmt, uint32_t event_nr);
116 * Use these to prepare for a create or reload.
118 int dm_task_add_target(struct dm_task *dmt,
120 uint64_t size, const char *ttype, const char *params);
123 * Format major/minor numbers correctly for input to driver
125 int dm_format_dev(char *buf, int bufsize, uint32_t dev_major, uint32_t dev_minor);
127 /* Use this to retrive target information returned from a STATUS call */
128 void *dm_get_next_target(struct dm_task *dmt,
129 void *next, uint64_t *start, uint64_t *length,
130 char **target_type, char **params);
133 * Call this to actually run the ioctl.
135 int dm_task_run(struct dm_task *dmt);
138 * Configure the device-mapper directory
140 int dm_set_dev_dir(const char *dir);
141 const char *dm_dir(void);
143 /* Release library resources */
144 void dm_lib_release(void);
145 void dm_lib_exit(void);
147 #endif /* LIB_DEVICE_MAPPER_H */