From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martin Wilck Subject: [RFC PATCH 16/20] libmultipath/print: add "%G - foreign" wildcard Date: Tue, 20 Feb 2018 14:26:54 +0100 Message-ID: <20180220132658.22295-17-mwilck@suse.com> References: <20180220132658.22295-1-mwilck@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20180220132658.22295-1-mwilck@suse.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: Christophe Varoqui , Hannes Reinecke Cc: dm-devel@redhat.com, Martin Wilck List-Id: dm-devel.ids This adds a format field to identify foreign maps as such, and uses it in default-formatted topology output (generic_style()). Signed-off-by: Martin Wilck --- libmultipath/generic.c | 4 +++- libmultipath/print.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libmultipath/generic.c b/libmultipath/generic.c index 61cbffb708b6..5f74427cb5b1 100644 --- a/libmultipath/generic.c +++ b/libmultipath/generic.c @@ -33,7 +33,9 @@ int generic_style(const struct gen_multipath* gm, gm->ops->snprint(gm, wwid_buf, sizeof(wwid_buf), 'w'); if (strcmp(alias_buf, wwid_buf)) - n = snprintf(buf, len, " (%%w)"); + n += snprintf(buf, len, "%%n (%%w) [%%G]"); + else + n += snprintf(buf, len, "%%n [%%G]"); return (n < len ? n : len - 1); } diff --git a/libmultipath/print.c b/libmultipath/print.c index 9a5a6a2f4ad6..a6ff6b297b3f 100644 --- a/libmultipath/print.c +++ b/libmultipath/print.c @@ -342,6 +342,12 @@ snprint_multipath_rev (char * buff, size_t len, const struct multipath * mpp) return snprintf(buff, len, "##"); } +static int +snprint_multipath_foreign (char * buff, size_t len, const struct multipath * pp) +{ + return snprintf(buff, len, "%s", "--"); +} + static int snprint_action (char * buff, size_t len, const struct multipath * mpp) { @@ -621,6 +627,12 @@ snprint_path_checker (char * buff, size_t len, const struct path * pp) return snprint_str(buff, len, c->name); } +static int +snprint_path_foreign (char * buff, size_t len, const struct path * pp) +{ + return snprintf(buff, len, "%s", "--"); +} + struct multipath_data mpd[] = { {'n', "name", 0, snprint_name}, {'w', "uuid", 0, snprint_multipath_uuid}, @@ -644,6 +656,7 @@ struct multipath_data mpd[] = { {'v', "vend", 0, snprint_multipath_vend}, {'p', "prod", 0, snprint_multipath_prod}, {'e', "rev", 0, snprint_multipath_rev}, + {'G', "foreign", 0, snprint_multipath_foreign}, {0, NULL, 0 , NULL} }; @@ -667,6 +680,7 @@ struct path_data pd[] = { {'R', "host WWPN", 0, snprint_host_wwpn}, {'r', "target WWPN", 0, snprint_tgt_wwpn}, {'a', "host adapter", 0, snprint_host_adapter}, + {'G', "foreign", 0, snprint_path_foreign}, {0, NULL, 0 , NULL} }; -- 2.16.1