@@ -1023,49 +1023,16 @@ out:
return r;
}
-/*
- * Return
- * 1 : map with uuid exists
- * 0 : map with uuid doesn't exist
- * -1 : error
- */
-int
-dm_map_present_by_uuid(const char *uuid)
+int dm_map_present_by_wwid(const char *wwid)
{
- struct dm_task *dmt;
- struct dm_info info;
- char prefixed_uuid[WWID_SIZE + UUID_PREFIX_LEN];
- int r = -1;
+ char tmp[DM_UUID_LEN];
- if (!uuid || uuid[0] == '\0')
- return 0;
+ if (safe_sprintf(tmp, UUID_PREFIX "%s", wwid))
+ return DMP_ERR;
- if (safe_sprintf(prefixed_uuid, UUID_PREFIX "%s", uuid))
- goto out;
-
- if (!(dmt = libmp_dm_task_create(DM_DEVICE_INFO)))
- goto out;
-
- if (!dm_task_set_uuid(dmt, prefixed_uuid))
- goto out_task;
-
- if (!libmp_dm_task_run(dmt)) {
- dm_log_error(3, DM_DEVICE_INFO, dmt);
- goto out_task;
- }
-
- if (!dm_task_get_info(dmt, &info))
- goto out_task;
-
- r = !!info.exists;
-
-out_task:
- dm_task_destroy(dmt);
-out:
- if (r < 0)
- condlog(3, "%s: dm command failed in %s: %s", uuid,
- __FUNCTION__, strerror(errno));
- return r;
+ return libmp_mapinfo(DM_MAP_BY_UUID,
+ (mapid_t) { .str = tmp },
+ (mapinfo_t) { .name = NULL });
}
static int dm_dev_t (const char *mapname, char *dev_t, int len)
@@ -127,7 +127,7 @@ int dm_simplecmd_flush (int task, const char *name, uint16_t udev_flags);
int dm_simplecmd_noflush (int task, const char *name, uint16_t udev_flags);
int dm_addmap_create (struct multipath *mpp, char *params);
int dm_addmap_reload (struct multipath *mpp, char *params, int flush);
-int dm_map_present_by_uuid(const char *uuid);
+int dm_map_present_by_wwid(const char *uuid);
int dm_get_map(const char *name, unsigned long long *size, char **outparams);
int dm_get_status(const char *name, char **outstatus);
@@ -360,7 +360,7 @@ is_path_valid(const char *name, struct config *conf, struct path *pp,
if (check_wwids_file(pp->wwid, 0) == 0)
return PATH_IS_VALID_NO_CHECK;
- if (dm_map_present_by_uuid(pp->wwid) == 1)
+ if (dm_map_present_by_wwid(pp->wwid) == DMP_OK)
return PATH_IS_VALID;
/* all these act like FIND_MULTIPATHS_STRICT for finding if a
@@ -189,7 +189,7 @@ int __wrap_check_wwids_file(char *wwid, int write_wwid)
return -1;
}
-int __wrap_dm_map_present_by_uuid(const char *uuid)
+int __wrap_dm_map_present_by_wwid(const char *uuid)
{
int ret = mock_type(int);
assert_string_equal(uuid, mock_ptr_type(char *));
@@ -271,8 +271,8 @@ static void setup_passing(char *name, char *wwid, unsigned int check_multipathd,
will_return(__wrap_check_wwids_file, wwid);
if (stage == STAGE_CHECK_WWIDS)
return;
- will_return(__wrap_dm_map_present_by_uuid, 0);
- will_return(__wrap_dm_map_present_by_uuid, wwid);
+ will_return(__wrap_dm_map_present_by_wwid, 0);
+ will_return(__wrap_dm_map_present_by_wwid, wwid);
}
static void test_bad_arguments(void **state)
@@ -516,8 +516,8 @@ static void test_check_uuid_present(void **state)
memset(&pp, 0, sizeof(pp));
conf.find_multipaths = FIND_MULTIPATHS_STRICT;
setup_passing(name, wwid, CHECK_MPATHD_RUNNING, STAGE_CHECK_WWIDS);
- will_return(__wrap_dm_map_present_by_uuid, 1);
- will_return(__wrap_dm_map_present_by_uuid, wwid);
+ will_return(__wrap_dm_map_present_by_wwid, 1);
+ will_return(__wrap_dm_map_present_by_wwid, wwid);
assert_int_equal(is_path_valid(name, &conf, &pp, true),
PATH_IS_VALID);
assert_string_equal(pp.dev, name);