From patchwork Mon Mar 16 12:36:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 6017751 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2B9E7BFA21 for ; Mon, 16 Mar 2015 12:41:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4C3BA204D8 for ; Mon, 16 Mar 2015 12:41:06 +0000 (UTC) Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3AC1B204E0 for ; Mon, 16 Mar 2015 12:41:05 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2GCc8mN005245; Mon, 16 Mar 2015 08:38:08 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id t2GCbFOc028679 for ; Mon, 16 Mar 2015 08:37:15 -0400 Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.20]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2GCbEc0021869; Mon, 16 Mar 2015 08:37:14 -0400 Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2GCbCGf011613 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=FAIL); Mon, 16 Mar 2015 08:37:13 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 74692ADC4; Mon, 16 Mar 2015 12:37:08 +0000 (UTC) From: Hannes Reinecke To: Christophe Varoqui Date: Mon, 16 Mar 2015 13:36:06 +0100 Message-Id: <1426509425-15978-20-git-send-email-hare@suse.de> In-Reply-To: <1426509425-15978-1-git-send-email-hare@suse.de> References: <1426509425-15978-1-git-send-email-hare@suse.de> X-RedHat-Spam-Score: -7.309 (BAYES_00, DCC_REPUT_00_12, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, URIBL_BLOCKED) 195.135.220.15 cantor2.suse.de 195.135.220.15 cantor2.suse.de X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.20 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com Subject: [dm-devel] [PATCH 19/78] multipathd: implement 'list path ' cli command X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implement CLI command for printing the status of a single path. Signed-off-by: Hannes Reinecke --- multipathd/cli.c | 1 + multipathd/cli_handlers.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ multipathd/cli_handlers.h | 1 + multipathd/main.c | 1 + 4 files changed, 47 insertions(+) diff --git a/multipathd/cli.c b/multipathd/cli.c index 2a5edfa..acc4249 100644 --- a/multipathd/cli.c +++ b/multipathd/cli.c @@ -425,6 +425,7 @@ cli_init (void) { add_handler(LIST+PATHS, NULL); add_handler(LIST+PATHS+FMT, NULL); + add_handler(LIST+PATH, NULL); add_handler(LIST+STATUS, NULL); add_handler(LIST+DAEMON, NULL); add_handler(LIST+MAPS, NULL); diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 43372d3..6abe72a 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -71,6 +71,35 @@ show_paths (char ** r, int * len, struct vectors * vecs, char * style) } int +show_path (char ** r, int * len, struct vectors * vecs, struct path *pp, + char * style) +{ + char * c; + char * reply; + unsigned int maxlen = INITIAL_REPLY_LEN; + int again = 1; + + get_path_layout(vecs->pathvec, 1); + reply = MALLOC(maxlen); + + while (again) { + if (!reply) + return 1; + + c = reply; + + c += snprint_path(c, reply + maxlen - c, style, pp); + + again = ((c - reply) == (maxlen - 1)); + + REALLOC_REPLY(reply, again, maxlen); + } + *r = reply; + *len = (int)(c - reply + 1); + return 0; +} + +int show_map_topology (char ** r, int * len, struct multipath * mpp, struct vectors * vecs) { @@ -239,6 +268,21 @@ cli_list_paths_fmt (void * v, char ** reply, int * len, void * data) } int +cli_list_path (void * v, char ** reply, int * len, void * data) +{ + struct vectors * vecs = (struct vectors *)data; + char * param = get_keyparam(v, PATH); + struct path *pp; + + param = convert_dev(param, 1); + condlog(3, "%s: list path (operator)", param); + + pp = find_path_by_dev(vecs->pathvec, param); + + return show_path(reply, len, vecs, pp, "%o"); +} + +int cli_list_map_topology (void * v, char ** reply, int * len, void * data) { struct multipath * mpp; diff --git a/multipathd/cli_handlers.h b/multipathd/cli_handlers.h index de51961..c4636d2 100644 --- a/multipathd/cli_handlers.h +++ b/multipathd/cli_handlers.h @@ -1,5 +1,6 @@ int cli_list_paths (void * v, char ** reply, int * len, void * data); int cli_list_paths_fmt (void * v, char ** reply, int * len, void * data); +int cli_list_path (void * v, char ** reply, int * len, void * data); int cli_list_status (void * v, char ** reply, int * len, void * data); int cli_list_daemon (void * v, char ** reply, int * len, void * data); int cli_list_maps (void * v, char ** reply, int * len, void * data); diff --git a/multipathd/main.c b/multipathd/main.c index 3e22ad1..2107113 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -886,6 +886,7 @@ uxlsnrloop (void * ap) set_handler_callback(LIST+PATHS, cli_list_paths); set_handler_callback(LIST+PATHS+FMT, cli_list_paths_fmt); + set_handler_callback(LIST+PATH, cli_list_path); set_handler_callback(LIST+MAPS, cli_list_maps); set_handler_callback(LIST+STATUS, cli_list_status); set_handler_callback(LIST+DAEMON, cli_list_daemon);