2 * Copyright (c) 2004, 2005 Christophe Varoqui
7 #include <libdevmapper.h>
9 #include <linux/kdev_t.h>
12 dm_prereq (char * str, int x, int y, int z)
16 struct dm_versions *target;
17 struct dm_versions *last_target;
19 if (!(dmt = dm_task_create(DM_DEVICE_LIST_VERSIONS)))
22 dm_task_no_open_count(dmt);
24 if (!dm_task_run(dmt))
27 target = dm_task_get_versions(dmt);
29 /* Fetch targets and print 'em */
33 if (!strncmp(str, target->name, strlen(str)) &&
34 /* dummy prereq on multipath version */
35 target->version[0] >= x &&
36 target->version[1] >= y &&
37 target->version[2] >= z
41 target = (void *) target + target->next;
42 } while (last_target != target);
50 dm_simplecmd (int task, const char *name) {
54 if (!(dmt = dm_task_create(task)))
57 if (!dm_task_set_name(dmt, name))
60 dm_task_no_open_count(dmt);
70 dm_addmap (int task, const char *name, const char *target,
71 const char *params, unsigned long size) {
75 if (!(dmt = dm_task_create (task)))
78 if (!dm_task_set_name (dmt, name))
81 if (!dm_task_add_target (dmt, 0, size, target, params))
84 dm_task_no_open_count(dmt);
86 r = dm_task_run (dmt);
89 dm_task_destroy (dmt);
94 dm_map_present (char * str)
100 if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
103 if (!dm_task_set_name(dmt, str))
106 dm_task_no_open_count(dmt);
108 if (!dm_task_run(dmt))
111 if (!dm_task_get_info(dmt, &info))
117 dm_task_destroy(dmt);
123 dm_mapname(int major, int minor)
128 if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
131 dm_task_no_open_count(dmt);
132 dm_task_set_major(dmt, major);
133 dm_task_set_minor(dmt, minor);
135 if (!dm_task_run(dmt))
138 mapname = strdup(dm_task_get_name(dmt));
140 dm_task_destroy(dmt);