本文整理汇总了C++中dm_task_create函数的典型用法代码示例。如果您正苦于以下问题:C++ dm_task_create函数的具体用法?C++ dm_task_create怎么用?C++ dm_task_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dm_task_create函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dm_dev_t
static int
dm_dev_t (const char * mapname, char * dev_t, int len)
{
int r = 1;
struct dm_task *dmt;
struct dm_info info;
if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
return 0;
if (!dm_task_set_name(dmt, mapname))
goto out;
if (!dm_task_run(dmt))
goto out;
if (!dm_task_get_info(dmt, &info) || !info.exists)
goto out;
if (snprintf(dev_t, len, "%i:%i", info.major, info.minor) > len)
goto out;
r = 0;
out:
dm_task_destroy(dmt);
return r;
}
示例2: dm_get_minor
int
dm_get_minor (char * mapname)
{
int r = -1;
struct dm_task *dmt;
struct dm_info info;
if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
return 0;
if (!dm_task_set_name(dmt, mapname))
goto out;
if (!dm_task_run(dmt))
goto out;
if (!dm_task_get_info(dmt, &info))
goto out;
if (!info.exists)
goto out;
r = info.minor;
out:
dm_task_destroy(dmt);
return r;
}
示例3: dm_get_status
extern int
dm_get_status(char * name, char * outstatus)
{
int r = 1;
struct dm_task *dmt;
uint64_t start, length;
char *target_type;
char *status;
if (!(dmt = dm_task_create(DM_DEVICE_STATUS)))
return 1;
if (!dm_task_set_name(dmt, name))
goto out;
dm_task_no_open_count(dmt);
if (!dm_task_run(dmt))
goto out;
/* Fetch 1st target */
dm_get_next_target(dmt, NULL, &start, &length,
&target_type, &status);
if (snprintf(outstatus, PARAMS_SIZE, "%s", status) <= PARAMS_SIZE)
r = 0;
out:
if (r)
condlog(0, "%s: error getting map status string", name);
dm_task_destroy(dmt);
return r;
}
示例4: dm_type
/*
* returns:
* 1 : match
* 0 : no match
* -1 : empty map
*/
extern int
dm_type(const char * name, char * type)
{
int r = 0;
struct dm_task *dmt;
uint64_t start, length;
char *target_type = NULL;
char *params;
if (!(dmt = dm_task_create(DM_DEVICE_TABLE)))
return 0;
if (!dm_task_set_name(dmt, name))
goto out;
dm_task_no_open_count(dmt);
if (!dm_task_run(dmt))
goto out;
/* Fetch 1st target */
dm_get_next_target(dmt, NULL, &start, &length,
&target_type, ¶ms);
if (!target_type)
r = -1;
else if (!strcmp(target_type, type))
r = 1;
out:
dm_task_destroy(dmt);
return r;
}
示例5: era_dm_list
int era_dm_list(int (*cb)(void *arg, const char *name), void *cbarg)
{
struct dm_task *dmt;
struct dm_names *names;
unsigned next = 0;
if (!(dmt = dm_task_create(DM_DEVICE_LIST)))
return -1;
if (!dm_task_run(dmt))
goto out;
if (!(names = dm_task_get_names(dmt)))
goto out;
if (names->dev)
{
do {
names = (struct dm_names *)((char *)names + next);
if (cb(cbarg, names->name))
goto out;
next = names->next;
} while(next);
}
dm_task_destroy(dmt);
return 0;
out:
dm_task_destroy(dmt);
return -1;
}
示例6: virStorageBackendGetMinorNumber
static int
virStorageBackendGetMinorNumber(const char *dev_name, uint32_t *minor)
{
int ret = -1;
struct dm_task *dmt;
struct dm_info info;
if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
goto out;
if (!dm_task_set_name(dmt, dev_name))
goto out;
if (!dm_task_run(dmt))
goto out;
if (!dm_task_get_info(dmt, &info))
goto out;
*minor = info.minor;
ret = 0;
out:
if (dmt != NULL)
dm_task_destroy(dmt);
return ret;
}
示例7: dm_geteventnr
int
dm_geteventnr (char *name)
{
struct dm_task *dmt;
struct dm_info info;
int event = -1;
if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
return -1;
if (!dm_task_set_name(dmt, name))
goto out;
dm_task_no_open_count(dmt);
if (!dm_task_run(dmt))
goto out;
if (!dm_task_get_info(dmt, &info))
goto out;
if (info.exists)
event = info.event_nr;
out:
dm_task_destroy(dmt);
return event;
}
示例8: dm_get_info
static
int
dm_get_info(const char *name, struct dm_info *dmi)
{
struct dm_task *dmt = NULL;
int error = -1;
if ((dmt = dm_task_create(DM_DEVICE_INFO)) == NULL)
goto out;
if ((dm_task_set_name(dmt, name)) == 0)
goto out;
if ((dm_task_run(dmt)) == 0)
goto out;
if ((dm_task_get_info(dmt, dmi)) == 0)
goto out;
error = 0;
out:
if (dmt)
dm_task_destroy(dmt);
return error;
}
示例9: _dm_check_versions
static int _dm_check_versions(void)
{
struct dm_task *dmt;
struct dm_versions *target, *last_target;
if (_dm_crypt_checked)
return 1;
if (!(dmt = dm_task_create(DM_DEVICE_LIST_VERSIONS)))
return 0;
if (!dm_task_run(dmt)) {
dm_task_destroy(dmt);
return 0;
}
target = dm_task_get_versions(dmt);
do {
last_target = target;
if (!strcmp(DM_CRYPT_TARGET, target->name)) {
_dm_set_crypt_compat((int)target->version[0],
(int)target->version[1],
(int)target->version[2]);
}
target = (void *) target + target->next;
} while (last_target != target);
dm_task_destroy(dmt);
return 1;
}
示例10: run_task
/* Create a task, set its name and run it. */
static int
run_task(struct lib_context *lc, struct raid_set *rs, char *table, int type, char *name)
{
/*
* DM_UUID_LEN is defined in dm-ioctl.h as 129 characters;
* though not all 129 must be used (md uses just 16 from
* a quick review of md.c.
* We will be using: (len vol grp name)
*/
char uuid[DM_UUID_LEN];
int ret;
struct dm_task *dmt;
_init_dm();
ret = (dmt = dm_task_create(type)) && dm_task_set_name(dmt, name);
if (ret && table)
ret = parse_table(lc, dmt, table);
if (ret) {
if (DM_DEVICE_CREATE == type) {
ret = dmraid_uuid(lc, rs, uuid, DM_UUID_LEN, name) &&
dm_task_set_uuid(dmt, uuid) && dm_task_run(dmt);
} else
ret = dm_task_run(dmt);
}
_exit_dm(dmt);
return ret;
}
示例11: _error_device
static int _error_device(const char *name, size_t size)
{
struct dm_task *dmt;
int r = 0;
if (!(dmt = dm_task_create(DM_DEVICE_RELOAD)))
return 0;
if (!dm_task_set_name(dmt, name))
goto error;
if (!dm_task_add_target(dmt, UINT64_C(0), size, "error", ""))
goto error;
if (!dm_task_set_ro(dmt))
goto error;
if (!dm_task_no_open_count(dmt))
goto error;
if (!dm_task_run(dmt))
goto error;
if (!_dm_simple(DM_DEVICE_RESUME, name, 1)) {
_dm_simple(DM_DEVICE_CLEAR, name, 0);
goto error;
}
r = 1;
error:
dm_task_destroy(dmt);
return r;
}
示例12: _dm_simple
/* DM helpers */
static int _dm_simple(int task, const char *name, int udev_wait)
{
int r = 0;
struct dm_task *dmt;
uint32_t cookie = 0;
if (!_dm_use_udev())
udev_wait = 0;
if (!(dmt = dm_task_create(task)))
return 0;
if (name && !dm_task_set_name(dmt, name))
goto out;
if (udev_wait && !dm_task_set_cookie(dmt, &cookie, 0))
goto out;
r = dm_task_run(dmt);
if (udev_wait)
(void)dm_udev_wait(cookie);
out:
dm_task_destroy(dmt);
return r;
}
示例13: dm_mount_aspect
int dm_mount_aspect(substrate_t *substrate, u64 header_offset, u8 *header_key, char *name)
{
char *params;
struct dm_task *task;
task = dm_task_create(DM_DEVICE_CREATE);
if(!task) {
die("dm_task_create");
}
if(!dm_task_set_name(task, name)) {
die("dm_task_set_name");
}
if(!dm_task_set_uuid(task, name)) {
die("dm_task_set_uuid");
}
params = steg_malloc(strlen(substrate->filename) + 4096);
sprintf(params, "%s %zu ", substrate->filename, header_offset);
sprint_hex(params + strlen(params), header_key, KEY_BYTES);
if(!dm_task_add_target(task, 0, substrate->bytes, "steg", params)) {
die("dm_task_add_target");
}
if(!dm_task_run(task)) {
die("dm_task_run");
}
dm_task_destroy(task);
steg_free(params);
return 0;
}
示例14: dm_message
int dm_message(char *path, char *message)
{
struct dm_task *task;
int e = -EIO;
if(!path) {
goto fail;
}
if(!(task = dm_task_create(DM_DEVICE_TARGET_MSG))) {
goto fail;
}
if(!dm_task_set_name(task, path)) {
goto fail;
}
if(!dm_task_set_sector(task, 0)) {
goto fail;
}
if(!dm_task_set_message(task, message)) {
goto fail;
}
if(!dm_task_run(task)) {
e = -errno;
goto fail;
}
e = 0;
fail:
dm_task_destroy(task);
return e;
}
示例15: _lookup_dev_name
static int _lookup_dev_name(uint64_t dev, char *buf, size_t len)
{
struct dm_names *names;
unsigned next = 0;
struct dm_task *dmt;
int r = 0;
if (!(dmt = dm_task_create(DM_DEVICE_LIST)))
return 0;
if (!dm_task_run(dmt))
goto out;
if (!(names = dm_task_get_names(dmt)))
goto out;
if (!names->dev)
goto out;
do {
names = (void *) names + next;
if (names->dev == dev) {
strncpy(buf, names->name, len);
r = 1;
break;
}
next = names->next;
} while (next);
out:
dm_task_destroy(dmt);
return r;
}