From: Martin Wilck <mwi...@suse.com> exactly like snprint_config(), but takes a struct strbuf * as argument.
Signed-off-by: Martin Wilck <mwi...@suse.com> --- libmultipath/libmultipath.version | 5 +++++ libmultipath/print.c | 34 +++++++++++++++++++++---------- libmultipath/print.h | 2 ++ 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version index 2107c51..b2feee2 100644 --- a/libmultipath/libmultipath.version +++ b/libmultipath/libmultipath.version @@ -297,3 +297,8 @@ LIBMULTIPATH_9.2.0 { global: set_wakeup_fn; } LIBMULTIPATH_9.1.0; + +LIBMULTIPATH_9.3.0 { +global: + __snprint_config; +} LIBMULTIPATH_9.2.0; diff --git a/libmultipath/print.c b/libmultipath/print.c index 2fb9f4e..d2ef010 100644 --- a/libmultipath/print.c +++ b/libmultipath/print.c @@ -1756,24 +1756,36 @@ static int snprint_blacklist_except(const struct config *conf, return get_strbuf_len(buff) - initial_len; } +int __snprint_config(const struct config *conf, struct strbuf *buff, + const struct _vector *hwtable, const struct _vector *mpvec) +{ + int rc; + + if ((rc = snprint_defaults(conf, buff)) < 0 || + (rc = snprint_blacklist(conf, buff)) < 0 || + (rc = snprint_blacklist_except(conf, buff)) < 0 || + (rc = snprint_hwtable(conf, buff, + hwtable ? hwtable : conf->hwtable)) < 0 || + (rc = snprint_overrides(conf, buff, conf->overrides)) < 0) + return rc; + + if (VECTOR_SIZE(conf->mptable) > 0 || + (mpvec != NULL && VECTOR_SIZE(mpvec) > 0)) + if ((rc = snprint_mptable(conf, buff, mpvec)) < 0) + return rc; + + return 0; +} + char *snprint_config(const struct config *conf, int *len, const struct _vector *hwtable, const struct _vector *mpvec) { STRBUF_ON_STACK(buff); char *reply; - int rc; + int rc = __snprint_config(conf, &buff, hwtable, mpvec); - if ((rc = snprint_defaults(conf, &buff)) < 0 || - (rc = snprint_blacklist(conf, &buff)) < 0 || - (rc = snprint_blacklist_except(conf, &buff)) < 0 || - (rc = snprint_hwtable(conf, &buff, - hwtable ? hwtable : conf->hwtable)) < 0 || - (rc = snprint_overrides(conf, &buff, conf->overrides)) < 0) + if (rc < 0) return NULL; - if (VECTOR_SIZE(conf->mptable) > 0 || - (mpvec != NULL && VECTOR_SIZE(mpvec) > 0)) - if ((rc = snprint_mptable(conf, &buff, mpvec)) < 0) - return NULL; if (len) *len = get_strbuf_len(&buff); diff --git a/libmultipath/print.h b/libmultipath/print.h index c6674a5..b149275 100644 --- a/libmultipath/print.h +++ b/libmultipath/print.h @@ -54,6 +54,8 @@ int _snprint_multipath_topology (const struct gen_multipath *, struct strbuf *, #define snprint_multipath_topology(buf, mpp, v) \ _snprint_multipath_topology (dm_multipath_to_gen(mpp), buf, v) int snprint_multipath_topology_json(struct strbuf *, const struct vectors *vecs); +int __snprint_config(const struct config *conf, struct strbuf *buff, + const struct _vector *hwtable, const struct _vector *mpvec); char *snprint_config(const struct config *conf, int *len, const struct _vector *hwtable, const struct _vector *mpvec); -- 2.33.0 -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel