On Fri, Jul 12, 2024 at 07:14:41PM +0200, Martin Wilck wrote: > Export it, as it will be used by multipathd and libmpathpersist. > Reviewed-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx> > Signed-off-by: Martin Wilck <mwilck@xxxxxxxx> > --- > libmultipath/devmapper.c | 13 +++++++++---- > libmultipath/devmapper.h | 2 ++ > libmultipath/libmultipath.version | 1 + > 3 files changed, 12 insertions(+), 4 deletions(-) > > diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c > index 9483f02..6f17d32 100644 > --- a/libmultipath/devmapper.c > +++ b/libmultipath/devmapper.c > @@ -840,6 +840,11 @@ int dm_get_map(const char *name, unsigned long long *size, char **outparams) > } > } > > +bool is_mpath_uuid(const char uuid[DM_UUID_LEN]) > +{ > + return !strncmp(uuid, UUID_PREFIX, UUID_PREFIX_LEN); > +} > + > /** > * dm_get_wwid(): return WWID for a multipath map > * @returns: > @@ -857,7 +862,7 @@ int dm_get_wwid(const char *name, char *uuid, int uuid_len) > if (rc != DMP_OK) > return rc; > > - if (!strncmp(tmp, UUID_PREFIX, UUID_PREFIX_LEN)) > + if (is_mpath_uuid(tmp)) > strlcpy(uuid, tmp + UUID_PREFIX_LEN, uuid_len); > else > return DMP_NO_MATCH; > @@ -982,7 +987,7 @@ int dm_is_mpath(const char *name) > > switch (rc) { > case DMP_OK: > - if (!strncmp(uuid, UUID_PREFIX, UUID_PREFIX_LEN)) > + if (is_mpath_uuid(uuid)) > return DM_IS_MPATH_YES; > /* fallthrough */ > case DMP_NOT_FOUND: > @@ -1082,7 +1087,7 @@ int _dm_flush_map (const char *mapname, int flags, int retries) > (mapinfo_t) { > .uuid = uuid, > .target = ¶ms }) != DMP_OK > - || strncmp(uuid, UUID_PREFIX, UUID_PREFIX_LEN)) > + || !is_mpath_uuid(uuid)) > return DM_FLUSH_OK; /* nothing to do */ > > /* if the device currently has no partitions, do not > @@ -1325,7 +1330,7 @@ struct multipath *dm_get_multipath(const char *name) > }) != DMP_OK) > return NULL; > > - if (strncmp(uuid, UUID_PREFIX, UUID_PREFIX_LEN)) > + if (!is_mpath_uuid(uuid)) > return NULL; > > strlcpy(mpp->wwid, uuid + UUID_PREFIX_LEN, sizeof(mpp->wwid)); > diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h > index 4c8f345..a10821f 100644 > --- a/libmultipath/devmapper.h > +++ b/libmultipath/devmapper.h > @@ -136,6 +136,8 @@ enum { > DM_IS_MPATH_YES, > DM_IS_MPATH_ERR, > }; > + > +bool is_mpath_uuid(const char uuid[DM_UUID_LEN]); > int dm_is_mpath(const char *name); > > enum { > diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version > index 7d3ff63..5b8f9e0 100644 > --- a/libmultipath/libmultipath.version > +++ b/libmultipath/libmultipath.version > @@ -127,6 +127,7 @@ global: > init_foreign; > init_prio; > io_err_stat_handle_pathfail; > + is_mpath_uuid; > is_path_valid; > libmp_dm_task_create; > libmp_get_version; > -- > 2.45.2