From patchwork Tue Aug 30 19:27:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12959772 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9FD83ECAAD5 for ; Tue, 30 Aug 2022 19:28:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661887706; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=rXzb16f8p9PnMv2y1RJnaBNapSA4seB2bst5idjjBqQ=; b=RqHex5kuBwQH2NHvoKeBG7C9ozAuQ9QBIX7GQDobSSx3u2dprqeosnl91p9TaZWuTXn3VM EZjiMLb74KU3qGpwdaewTq55mPY3f/WFwHEXmxJYFop+7cm5d6fx2sRI2rYSlR1Q3c0sJf Csgep0EO4xLmiLBFOcxZLnlHfzA4Bu4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-383-Dy1A3SkFMiCxpFvB4ttfMg-1; Tue, 30 Aug 2022 15:28:25 -0400 X-MC-Unique: Dy1A3SkFMiCxpFvB4ttfMg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4E201800DA7; Tue, 30 Aug 2022 19:28:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id F21D11415133; Tue, 30 Aug 2022 19:28:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 661031946A72; Tue, 30 Aug 2022 19:28:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 49ECF1946A40 for ; Tue, 30 Aug 2022 19:28:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3B04A492CA2; Tue, 30 Aug 2022 19:28:16 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 37812492C3B for ; Tue, 30 Aug 2022 19:28:16 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1E6CC101A56D for ; Tue, 30 Aug 2022 19:28:16 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-625-_8AjvEVBNw-iMpAWar5uhg-1; Tue, 30 Aug 2022 15:28:14 -0400 X-MC-Unique: _8AjvEVBNw-iMpAWar5uhg-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 35CBE21E7C; Tue, 30 Aug 2022 19:28:10 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 04F9513B0C; Tue, 30 Aug 2022 19:28:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id aNL9OslkDmO5GgAAMHmgww (envelope-from ); Tue, 30 Aug 2022 19:28:09 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Tue, 30 Aug 2022 21:27:02 +0200 Message-Id: <20220830192713.19778-2-mwilck@suse.com> In-Reply-To: <20220830192713.19778-1-mwilck@suse.com> References: <20220830192713.19778-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Subject: [dm-devel] [PATCH v4 01/12] multipathd: replace libreadline with getline() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Hannes Reinecke libreadline changed the license to be incompatible with multipath-tools usage, so replace it with a simple getline(). mwilck: Make this the default option via Makefile.inc; it is used if READLINE is unset. Compiling with READLINE=libreadline or READLINE=libedit remains possible. Signed-off-by: Hannes Reinecke Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- Makefile.inc | 4 ++-- multipathd/cli.c | 2 ++ multipathd/cli.h | 4 +++- multipathd/uxclnt.c | 49 +++++++++++++++++++++++++++++++++------------ 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/Makefile.inc b/Makefile.inc index ad7afd0..4b32fa7 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -9,10 +9,10 @@ # Uncomment to disable dmevents polling support # ENABLE_DMEVENTS_POLL = 0 # -# Readline library to use, libedit or libreadline +# Readline library to use, libedit, libreadline, or empty # Caution: Using libreadline may make the multipathd binary undistributable, # see https://github.com/opensvc/multipath-tools/issues/36 -READLINE = libedit +READLINE := # List of scsi device handler modules to load on boot, e.g. # SCSI_DH_MODULES_PRELOAD := scsi_dh_alua scsi_dh_rdac diff --git a/multipathd/cli.c b/multipathd/cli.c index fa482a6..cc56950 100644 --- a/multipathd/cli.c +++ b/multipathd/cli.c @@ -459,6 +459,7 @@ void cli_exit(void) keys = NULL; } +#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) static int key_match_fingerprint (struct key * kw, uint64_t fp) { @@ -564,3 +565,4 @@ key_generator (const char * str, int state) */ return ((char *)NULL); } +#endif diff --git a/multipathd/cli.h b/multipathd/cli.h index a6082ac..2a0c102 100644 --- a/multipathd/cli.h +++ b/multipathd/cli.h @@ -151,6 +151,8 @@ void free_keys (vector vec); void free_handlers (void); int cli_init (void); void cli_exit(void); -char * key_generator (const char * str, int state); +#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) +char *key_generator (const char * str, int state); +#endif #endif /* _CLI_H_ */ diff --git a/multipathd/uxclnt.c b/multipathd/uxclnt.c index 251e7d7..deff565 100644 --- a/multipathd/uxclnt.c +++ b/multipathd/uxclnt.c @@ -30,6 +30,7 @@ #include "defaults.h" #include "vector.h" +#include "util.h" #include "cli.h" #include "uxclnt.h" @@ -77,35 +78,57 @@ static int need_quit(char *str, size_t len) */ static void process(int fd, unsigned int timeout) { - char *line; - char *reply; - int ret; - cli_init(); +#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) rl_readline_name = "multipathd"; rl_completion_entry_function = key_generator; - while ((line = readline("multipathd> "))) { - size_t llen = strlen(line); +#endif - if (!llen) { - free(line); + cli_init(); + for(;;) + { + char *line __attribute__((cleanup(cleanup_charp))) = NULL; + char *reply __attribute__((cleanup(cleanup_charp))) = NULL; + ssize_t llen; + int ret; + +#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) + line = readline("multipathd> "); + if (!line) + break; + llen = strlen(line); + if (!llen) continue; +#else + size_t lsize = 0; + + fputs("multipathd> ", stdout); + errno = 0; + llen = getline(&line, &lsize, stdin); + if (llen == -1) { + if (errno != 0) + fprintf(stderr, "Error in getline: %m"); + break; } + if (!llen || !strcmp(line, "\n")) + continue; +#endif if (need_quit(line, llen)) break; - if (send_packet(fd, line) != 0) break; + if (send_packet(fd, line) != 0) + break; ret = recv_packet(fd, &reply, timeout); - if (ret != 0) break; + if (ret != 0) + break; print_reply(reply); +#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) if (line && *line) add_history(line); - - free(line); - free(reply); +#endif } } From patchwork Tue Aug 30 19:27:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12959774 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 35452C64991 for ; Tue, 30 Aug 2022 19:28:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661887708; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wqeTQh0yjZlyN0lk2GTEpjOKMY9S9T6m1n+iVAqmhW8=; b=TPfwMHrl6qj7f2cdmOaJfv7R9QY61VQIqFeJJUwNLMu4Ex+v/n38Ri7cIo1LhwUTm7090l wm8YOqQhuKhrDcJYs5+Vy1ww2/A69KsG8XoAMGS6Nry0BnWUASqf8J5Ogc9CLevNc4iVRL 4GlD0pqa0hE401vDEzvV623wlMuFRvU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-665-ntdxuRl9NmSijq1v7AvFkA-1; Tue, 30 Aug 2022 15:28:24 -0400 X-MC-Unique: ntdxuRl9NmSijq1v7AvFkA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 42C9A8039D3; Tue, 30 Aug 2022 19:28:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EE4A403D0CC; Tue, 30 Aug 2022 19:28:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E82DF1946A55; Tue, 30 Aug 2022 19:28:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 075701946A42 for ; Tue, 30 Aug 2022 19:28:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F03654010E6E; Tue, 30 Aug 2022 19:28:16 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC22F400E88E for ; Tue, 30 Aug 2022 19:28:16 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D30A3101A58F for ; Tue, 30 Aug 2022 19:28:16 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-267-G1nZO1RANHa-daO_cwYC7w-1; Tue, 30 Aug 2022 15:28:12 -0400 X-MC-Unique: G1nZO1RANHa-daO_cwYC7w-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8359121E7F; Tue, 30 Aug 2022 19:28:10 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3E2BC13B0C; Tue, 30 Aug 2022 19:28:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id aAl3DcpkDmO5GgAAMHmgww (envelope-from ); Tue, 30 Aug 2022 19:28:10 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Tue, 30 Aug 2022 21:27:03 +0200 Message-Id: <20220830192713.19778-3-mwilck@suse.com> In-Reply-To: <20220830192713.19778-1-mwilck@suse.com> References: <20220830192713.19778-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Subject: [dm-devel] [PATCH v4 02/12] .gitignore: ignore generated ABI files X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 8e09f95..b88608c 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,5 @@ tests/*.out tests/*.vgr libmultipath/nvme-ioctl.c libmultipath/nvme-ioctl.h +*/*-nv.version +reference-abi From patchwork Tue Aug 30 19:27:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12959768 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A399CECAAA1 for ; Tue, 30 Aug 2022 19:28:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661887705; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ZhPQ0q6S20M2Ope6PUuidQYhIphsqohXXmzuHLxovYU=; b=C0EnREaM0cY8eJuUWqLrFcf/sbKm23VM8SysURmHzYeWb70qNOAcq6jSbNtN1skj2wY4AO yZhKuPorYZXBpGZFTDJVfrh0ZFCDGeHqBhMjg1RMHTxWAhHpplVUnRCpW9u3vHLJgMbB8o 7qAd1qKGIDfpESgmxtJROkveQ4dNX1c= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-287-apmihs5PNdi_8yHg3jh0_w-1; Tue, 30 Aug 2022 15:28:24 -0400 X-MC-Unique: apmihs5PNdi_8yHg3jh0_w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0C260824065; Tue, 30 Aug 2022 19:28:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C3FA141512E; Tue, 30 Aug 2022 19:28:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2B8BC1946A6C; Tue, 30 Aug 2022 19:28:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F200F1946A40 for ; Tue, 30 Aug 2022 19:28:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E2BC8492CA2; Tue, 30 Aug 2022 19:28:16 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DED9A492C3B for ; Tue, 30 Aug 2022 19:28:16 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C5F4229AB3F7 for ; Tue, 30 Aug 2022 19:28:16 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-269-ODJScXHEMS29An-cnGKPuA-1; Tue, 30 Aug 2022 15:28:13 -0400 X-MC-Unique: ODJScXHEMS29An-cnGKPuA-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C0AA61FAF0; Tue, 30 Aug 2022 19:28:10 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8677D13B22; Tue, 30 Aug 2022 19:28:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kK8KH8pkDmO5GgAAMHmgww (envelope-from ); Tue, 30 Aug 2022 19:28:10 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Tue, 30 Aug 2022 21:27:04 +0200 Message-Id: <20220830192713.19778-4-mwilck@suse.com> In-Reply-To: <20220830192713.19778-1-mwilck@suse.com> References: <20220830192713.19778-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Subject: [dm-devel] [PATCH v4 03/12] libmultipath: move all reservation key functions to prkey.c X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck Also make parse_prkey() static, and avoid including libmpathpersist headers in libmultipath. The only exception is now prkey.c, where we pull in some public declarations from mpath_persist.h. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmultipath/Makefile | 2 +- libmultipath/dict.c | 16 +------------- libmultipath/dict.h | 2 -- libmultipath/prkey.c | 49 ++++++++++++++++++++++++++++++++++++++++++- libmultipath/prkey.h | 3 +++ libmultipath/util.c | 32 ---------------------------- libmultipath/util.h | 2 -- 7 files changed, 53 insertions(+), 53 deletions(-) diff --git a/libmultipath/Makefile b/libmultipath/Makefile index a70acab..01c7d26 100644 --- a/libmultipath/Makefile +++ b/libmultipath/Makefile @@ -8,7 +8,7 @@ DEVLIB = libmultipath.so LIBS = $(DEVLIB).$(SONAME) VERSION_SCRIPT := libmultipath.version -CPPFLAGS += -I$(mpathcmddir) -I$(mpathpersistdir) -I$(nvmedir) +CPPFLAGS += -I$(mpathcmddir) -I$(nvmedir) CFLAGS += $(LIB_CFLAGS) LIBDEPS += -lpthread -ldl -ldevmapper -ludev -L$(mpathcmddir) -lmpathcmd -lurcu -laio diff --git a/libmultipath/dict.c b/libmultipath/dict.c index ad049cc..aa93fe4 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -24,10 +24,10 @@ #include #include #include -#include #include "mpath_cmd.h" #include "dict.h" #include "strbuf.h" +#include "prkey.h" static void do_set_int(vector strvec, void *ptr, int min, int max, const char *file, @@ -1404,20 +1404,6 @@ set_reservation_key(vector strvec, struct be64 *be64_ptr, uint8_t *flags_ptr, return 0; } -int -print_reservation_key(struct strbuf *buff, - struct be64 key, uint8_t flags, int source) -{ - char *flagstr = ""; - if (source == PRKEY_SOURCE_NONE) - return 0; - if (source == PRKEY_SOURCE_FILE) - return append_strbuf_quoted(buff, "file"); - if (flags & MPATH_F_APTPL_MASK) - flagstr = ":aptpl"; - return print_strbuf(buff, "0x%" PRIx64 "%s", get_be64(key), flagstr); -} - static int def_reservation_key_handler(struct config *conf, vector strvec, const char *file, int line_nr) diff --git a/libmultipath/dict.h b/libmultipath/dict.h index d80f990..15d9cba 100644 --- a/libmultipath/dict.h +++ b/libmultipath/dict.h @@ -16,7 +16,5 @@ int print_pgpolicy(struct strbuf *buff, long v); int print_no_path_retry(struct strbuf *buff, long v); int print_undef_off_zero(struct strbuf *buff, long v); int print_dev_loss(struct strbuf *buff, unsigned long v); -int print_reservation_key(struct strbuf *buff, - struct be64 key, uint8_t flags, int source); int print_off_int_undef(struct strbuf *buff, long v); #endif /* _DICT_H */ diff --git a/libmultipath/prkey.c b/libmultipath/prkey.c index d645f81..a215499 100644 --- a/libmultipath/prkey.c +++ b/libmultipath/prkey.c @@ -4,6 +4,7 @@ #include "config.h" #include "util.h" #include "propsel.h" +#include "strbuf.h" #include "prkey.h" #include #include @@ -12,11 +13,57 @@ #include #include #include -#include +/* MPATH_F_APTPL_MASK is publicly defined in mpath_persist.h */ +#include <../libmpathpersist/mpath_persist.h> #define PRKEY_READ 0 #define PRKEY_WRITE 1 +int +print_reservation_key(struct strbuf *buff, + struct be64 key, uint8_t flags, int source) +{ + char *flagstr = ""; + if (source == PRKEY_SOURCE_NONE) + return 0; + if (source == PRKEY_SOURCE_FILE) + return append_strbuf_quoted(buff, "file"); + if (flags & MPATH_F_APTPL_MASK) + flagstr = ":aptpl"; + return print_strbuf(buff, "0x%" PRIx64 "%s", get_be64(key), flagstr); +} + +static int parse_prkey(const char *ptr, uint64_t *prkey) +{ + if (!ptr) + return 1; + if (*ptr == '0') + ptr++; + if (*ptr == 'x' || *ptr == 'X') + ptr++; + if (*ptr == '\0' || strlen(ptr) > 16) + return 1; + if (strlen(ptr) != strspn(ptr, "0123456789aAbBcCdDeEfF")) + return 1; + if (sscanf(ptr, "%" SCNx64 "", prkey) != 1) + return 1; + return 0; +} + +int parse_prkey_flags(const char *ptr, uint64_t *prkey, uint8_t *flags) +{ + char *flagstr; + + flagstr = strchr(ptr, ':'); + *flags = 0; + if (flagstr) { + *flagstr++ = '\0'; + if (strlen(flagstr) == 5 && strcmp(flagstr, "aptpl") == 0) + *flags = MPATH_F_APTPL_MASK; + } + return parse_prkey(ptr, prkey); +} + static int do_prkey(int fd, char *wwid, char *keystr, int cmd) { char buf[4097]; diff --git a/libmultipath/prkey.h b/libmultipath/prkey.h index 6739191..a16de10 100644 --- a/libmultipath/prkey.h +++ b/libmultipath/prkey.h @@ -13,6 +13,9 @@ "# prkey wwid\n" \ "#\n" +int print_reservation_key(struct strbuf *buff, + struct be64 key, uint8_t flags, int source); +int parse_prkey_flags(const char *ptr, uint64_t *prkey, uint8_t *flags); int set_prkey(struct config *conf, struct multipath *mpp, uint64_t prkey, uint8_t sa_flags); int get_prkey(struct config *conf, struct multipath *mpp, uint64_t *prkey, diff --git a/libmultipath/util.c b/libmultipath/util.c index e7e7d4c..6979e74 100644 --- a/libmultipath/util.c +++ b/libmultipath/util.c @@ -13,7 +13,6 @@ #include #include #include -#include #include "util.h" #include "debug.h" @@ -333,37 +332,6 @@ int get_linux_version_code(void) return _linux_version_code; } -int parse_prkey(const char *ptr, uint64_t *prkey) -{ - if (!ptr) - return 1; - if (*ptr == '0') - ptr++; - if (*ptr == 'x' || *ptr == 'X') - ptr++; - if (*ptr == '\0' || strlen(ptr) > 16) - return 1; - if (strlen(ptr) != strspn(ptr, "0123456789aAbBcCdDeEfF")) - return 1; - if (sscanf(ptr, "%" SCNx64 "", prkey) != 1) - return 1; - return 0; -} - -int parse_prkey_flags(const char *ptr, uint64_t *prkey, uint8_t *flags) -{ - char *flagstr; - - flagstr = strchr(ptr, ':'); - *flags = 0; - if (flagstr) { - *flagstr++ = '\0'; - if (strlen(flagstr) == 5 && strcmp(flagstr, "aptpl") == 0) - *flags = MPATH_F_APTPL_MASK; - } - return parse_prkey(ptr, prkey); -} - int safe_write(int fd, const void *buf, size_t count) { while (count > 0) { diff --git a/libmultipath/util.h b/libmultipath/util.h index 5a44018..bede49d 100644 --- a/libmultipath/util.h +++ b/libmultipath/util.h @@ -24,8 +24,6 @@ char *convert_dev(char *dev, int is_path_device); void setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached); int systemd_service_enabled(const char *dev); int get_linux_version_code(void); -int parse_prkey(const char *ptr, uint64_t *prkey); -int parse_prkey_flags(const char *ptr, uint64_t *prkey, uint8_t *flags); int safe_write(int fd, const void *buf, size_t count); void set_max_fds(rlim_t max_fds); int should_exit(void); From patchwork Tue Aug 30 19:27:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12959773 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1267EC54EE9 for ; Tue, 30 Aug 2022 19:28:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661887708; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=kIdmsnOSi7U/+UtqQ5mb4L86RnVQx5VZgz2lYrhRtz8=; b=P2DjbimzSim4pdrUmEI/kTsxWO9QFpkgoybLva1l/U31PhWZHql1njUtPyZqLHbeYE8TyZ R0wZxdMfEhS7D0HlnDRkXtDsIKF3TzJGpBMMUHkdGgB5tFWWR1RTGKlmYxE5XQp9+Vwf/9 Gxg88DPoeIbSG9THQ1eJf9WPq5QFBK4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-656-Ou20jZ9-M0GpSCtaUWy88w-1; Tue, 30 Aug 2022 15:28:24 -0400 X-MC-Unique: Ou20jZ9-M0GpSCtaUWy88w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 09E2C803918; Tue, 30 Aug 2022 19:28:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6836CC15BC8; Tue, 30 Aug 2022 19:28:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 33BBA1946A48; Tue, 30 Aug 2022 19:28:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9609C1946A40 for ; Tue, 30 Aug 2022 19:28:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 541CF2166B2B; Tue, 30 Aug 2022 19:28:15 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5051D2166B2A for ; Tue, 30 Aug 2022 19:28:15 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2F0543802B83 for ; Tue, 30 Aug 2022 19:28:15 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-449-w-KAoUYdN4yfA8SWyx3cnQ-1; Tue, 30 Aug 2022 15:28:13 -0400 X-MC-Unique: w-KAoUYdN4yfA8SWyx3cnQ-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 094911FB1F; Tue, 30 Aug 2022 19:28:11 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CC16113B22; Tue, 30 Aug 2022 19:28:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gAo2MMpkDmO5GgAAMHmgww (envelope-from ); Tue, 30 Aug 2022 19:28:10 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Tue, 30 Aug 2022 21:27:05 +0200 Message-Id: <20220830192713.19778-5-mwilck@suse.com> In-Reply-To: <20220830192713.19778-1-mwilck@suse.com> References: <20220830192713.19778-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Subject: [dm-devel] [PATCH v4 04/12] libmultipath: always set _GNU_SOURCE X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck ... not only if dm_task_no_flush is available. Also, look for includes under libmultipath but not under libmpathpersist. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmultipath/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libmultipath/Makefile b/libmultipath/Makefile index 01c7d26..6e87a16 100644 --- a/libmultipath/Makefile +++ b/libmultipath/Makefile @@ -8,7 +8,7 @@ DEVLIB = libmultipath.so LIBS = $(DEVLIB).$(SONAME) VERSION_SCRIPT := libmultipath.version -CPPFLAGS += -I$(mpathcmddir) -I$(nvmedir) +CPPFLAGS += -I$(mpathcmddir) -I$(nvmedir) -D_GNU_SOURCE CFLAGS += $(LIB_CFLAGS) LIBDEPS += -lpthread -ldl -ldevmapper -ludev -L$(mpathcmddir) -lmpathcmd -lurcu -laio @@ -23,7 +23,7 @@ ifdef SYSTEMD endif ifneq ($(call check_func,dm_task_no_flush,$(DEVMAPPER_INCDIR)/libdevmapper.h),0) - CPPFLAGS += -DLIBDM_API_FLUSH -D_GNU_SOURCE + CPPFLAGS += -DLIBDM_API_FLUSH endif ifneq ($(call check_func,dm_task_get_errno,$(DEVMAPPER_INCDIR)/libdevmapper.h),0) From patchwork Tue Aug 30 19:27:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12959770 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D5DFC3DA6B for ; Tue, 30 Aug 2022 19:28:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661887707; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2PBXA/oPUtxSQ97rU3HP1ps/Go6H5LfaUM49vWQ244A=; b=QHjs48MxIUf2aP/jB2S7SBDslu0Pbds+hFNbQEJuasVMBMR6Y9GlWi9DT7UJ9TE6g+Zrp0 ZVyDq3ES7aO8BAyScBE9f2syO9czEFyvikfCSlaW+XPIxcSDGY7tP8bHmfKinS3k5pDXPI oxSFXZpjQb9sh8RGHjt3r7l8Xu8vzcc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-656-ZcDpTr-vOL2h50Iv3yXQ0w-1; Tue, 30 Aug 2022 15:28:24 -0400 X-MC-Unique: ZcDpTr-vOL2h50Iv3yXQ0w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0C1D618F026F; Tue, 30 Aug 2022 19:28:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 429761410DD5; Tue, 30 Aug 2022 19:28:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 72ED51946A53; Tue, 30 Aug 2022 19:28:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F18151946A40 for ; Tue, 30 Aug 2022 19:28:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D5A8AC15BBA; Tue, 30 Aug 2022 19:28:15 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D2762C15BB3 for ; Tue, 30 Aug 2022 19:28:15 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B669229AB3F9 for ; Tue, 30 Aug 2022 19:28:15 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-477-5YrKkUREOcWtIgkr0BuWtA-1; Tue, 30 Aug 2022 15:28:13 -0400 X-MC-Unique: 5YrKkUREOcWtIgkr0BuWtA-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5325C1FB20; Tue, 30 Aug 2022 19:28:11 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 155D613B0C; Tue, 30 Aug 2022 19:28:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gB+FA8tkDmO5GgAAMHmgww (envelope-from ); Tue, 30 Aug 2022 19:28:11 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Tue, 30 Aug 2022 21:27:06 +0200 Message-Id: <20220830192713.19778-6-mwilck@suse.com> In-Reply-To: <20220830192713.19778-1-mwilck@suse.com> References: <20220830192713.19778-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Subject: [dm-devel] [PATCH v4 05/12] multipath-tools: Makefile: fix dependencies for "install" target X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck subdir.install targets should depend on subdir targets. This is cleaner than just having "install" depend on "all". Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 82e0ea3..ffca586 100644 --- a/Makefile +++ b/Makefile @@ -84,7 +84,7 @@ libmultipath/checkers.install \ $(BUILDDIRS.clean): $(MAKE) -C ${@:.clean=} clean -$(BUILDDIRS:=.install): +$(BUILDDIRS:=.install): $(BUILDDIRS) $(MAKE) -C ${@:.install=} install $(BUILDDIRS:=.uninstall): @@ -93,7 +93,7 @@ $(BUILDDIRS:=.uninstall): clean: $(BUILDDIRS.clean) rm -rf abi abi.tar.gz abi-test compile_commands.json -install: all $(BUILDDIRS:=.install) +install: $(BUILDDIRS:=.install) uninstall: $(BUILDDIRS:=.uninstall) test-progs: all From patchwork Tue Aug 30 19:27:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12959777 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0192C0502A for ; Tue, 30 Aug 2022 19:28:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661887710; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bEbaDg7Ty9aK2zQR6sK31snsI0kkUMiJkzE/0mrYkJA=; b=e8Vig+LT/2QGqXyQBfKOJz6C76/b2UL0v/OyVEXFJJA9nIbenbiab5Z56nwht7S49D4e3y S8/03uTPPfRj94Hm+GBWIz1b0o7JJXHi0R5lHViBr4qn26y1bHlzUxcjojwjPrIZio0FS6 5H8GC05n4f3z1aFjpxMWgib1Qc+ys38= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-151-oDVd8MChObOsVgt2j9nDGg-1; Tue, 30 Aug 2022 15:28:27 -0400 X-MC-Unique: oDVd8MChObOsVgt2j9nDGg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 099BD3802BAA; Tue, 30 Aug 2022 19:28:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A050401473; Tue, 30 Aug 2022 19:28:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B1A7E1946A5B; Tue, 30 Aug 2022 19:28:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2AD9C1946A40 for ; Tue, 30 Aug 2022 19:28:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1DB061410F37; Tue, 30 Aug 2022 19:28:17 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 19E8F1410DD5 for ; Tue, 30 Aug 2022 19:28:17 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 03BC9823F11 for ; Tue, 30 Aug 2022 19:28:17 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-284-nR0N_Hl0OQy7g5WDoyI-Kg-1; Tue, 30 Aug 2022 15:28:14 -0400 X-MC-Unique: nR0N_Hl0OQy7g5WDoyI-Kg-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 916961FB23; Tue, 30 Aug 2022 19:28:11 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5426913B22; Tue, 30 Aug 2022 19:28:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GLfXEstkDmO5GgAAMHmgww (envelope-from ); Tue, 30 Aug 2022 19:28:11 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Tue, 30 Aug 2022 21:27:07 +0200 Message-Id: <20220830192713.19778-7-mwilck@suse.com> In-Reply-To: <20220830192713.19778-1-mwilck@suse.com> References: <20220830192713.19778-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Subject: [dm-devel] [PATCH v4 06/12] libmultipath checkers/prioritizers: search for includes in libmultipath X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck Set TOPDIR correctly rather than using hard-coded "../". Also remove duplicate -lmultipath in checkers makefile. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmultipath/checkers/Makefile | 5 +++-- libmultipath/checkers/directio.c | 4 ++-- libmultipath/checkers/emc_clariion.c | 2 +- libmultipath/checkers/hp_sw.c | 4 ++-- libmultipath/checkers/rdac.c | 2 +- libmultipath/checkers/tur.c | 8 ++++---- libmultipath/foreign/Makefile | 4 ++-- libmultipath/prioritizers/Makefile | 6 ++++-- libmultipath/prioritizers/alua_rtpg.c | 2 +- 9 files changed, 20 insertions(+), 17 deletions(-) diff --git a/libmultipath/checkers/Makefile b/libmultipath/checkers/Makefile index 8d8e45e..69de1ed 100644 --- a/libmultipath/checkers/Makefile +++ b/libmultipath/checkers/Makefile @@ -1,11 +1,12 @@ # # Copyright (C) 2003 Christophe Varoqui, # +TOPDIR = ../.. include ../../Makefile.inc -CPPFLAGS += -I.. +CPPFLAGS += -I$(multipathdir) CFLAGS += $(LIB_CFLAGS) -LDFLAGS += -L.. -lmultipath +LDFLAGS += -L$(multipathdir) LIBDEPS = -lmultipath -laio -lpthread -lrt # If you add or remove a checker also update multipath/multipath.conf.5 diff --git a/libmultipath/checkers/directio.c b/libmultipath/checkers/directio.c index a326e37..2f3ece0 100644 --- a/libmultipath/checkers/directio.c +++ b/libmultipath/checkers/directio.c @@ -15,8 +15,8 @@ #include #include "checkers.h" -#include "../libmultipath/debug.h" -#include "../libmultipath/time-util.h" +#include "debug.h" +#include "time-util.h" #define AIO_GROUP_SIZE 1024 diff --git a/libmultipath/checkers/emc_clariion.c b/libmultipath/checkers/emc_clariion.c index aa636e7..04635b5 100644 --- a/libmultipath/checkers/emc_clariion.c +++ b/libmultipath/checkers/emc_clariion.c @@ -11,7 +11,7 @@ #include #include -#include "../libmultipath/sg_include.h" +#include "sg_include.h" #include "libsg.h" #include "checkers.h" #include "debug.h" diff --git a/libmultipath/checkers/hp_sw.c b/libmultipath/checkers/hp_sw.c index 915918c..1ab7909 100644 --- a/libmultipath/checkers/hp_sw.c +++ b/libmultipath/checkers/hp_sw.c @@ -13,8 +13,8 @@ #include "checkers.h" -#include "../libmultipath/sg_include.h" -#include "../libmultipath/unaligned.h" +#include "sg_include.h" +#include "unaligned.h" #define TUR_CMD_LEN 6 #define INQUIRY_CMDLEN 6 diff --git a/libmultipath/checkers/rdac.c b/libmultipath/checkers/rdac.c index f7aaa30..9a3860f 100644 --- a/libmultipath/checkers/rdac.c +++ b/libmultipath/checkers/rdac.c @@ -14,7 +14,7 @@ #include "checkers.h" #include "debug.h" -#include "../libmultipath/sg_include.h" +#include "sg_include.h" #define INQUIRY_CMDLEN 6 #define INQUIRY_CMD 0x12 diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c index 1bcb757..551dc4f 100644 --- a/libmultipath/checkers/tur.c +++ b/libmultipath/checkers/tur.c @@ -19,10 +19,10 @@ #include "checkers.h" -#include "../libmultipath/debug.h" -#include "../libmultipath/sg_include.h" -#include "../libmultipath/util.h" -#include "../libmultipath/time-util.h" +#include "debug.h" +#include "sg_include.h" +#include "util.h" +#include "time-util.h" #define TUR_CMD_LEN 6 #define HEAVY_CHECK_COUNT 10 diff --git a/libmultipath/foreign/Makefile b/libmultipath/foreign/Makefile index 42cea4d..3d4491a 100644 --- a/libmultipath/foreign/Makefile +++ b/libmultipath/foreign/Makefile @@ -4,9 +4,9 @@ TOPDIR=../.. include ../../Makefile.inc -CPPFLAGS += -I.. -I$(nvmedir) +CPPFLAGS += -I$(multipathdir) -I$(nvmedir) CFLAGS += $(LIB_CFLAGS) -LDFLAGS += -L.. +LDFLAGS += -L$(multipathdir) LIBDEPS = -lmultipath -ludev -lpthread -lrt LIBS = libforeign-nvme.so diff --git a/libmultipath/prioritizers/Makefile b/libmultipath/prioritizers/Makefile index a5ab5e1..eb6f03b 100644 --- a/libmultipath/prioritizers/Makefile +++ b/libmultipath/prioritizers/Makefile @@ -1,11 +1,13 @@ # # Copyright (C) 2007 Christophe Varoqui, # +TOPDIR=../.. + include ../../Makefile.inc -CPPFLAGS += -I.. +CPPFLAGS += -I$(multipathdir) CFLAGS += $(LIB_CFLAGS) -LDFLAGS += -L.. +LDFLAGS += -L$(multipathdir) LIBDEPS = -lmultipath -lm -lpthread -lrt # If you add or remove a prioritizer also update multipath/multipath.conf.5 diff --git a/libmultipath/prioritizers/alua_rtpg.c b/libmultipath/prioritizers/alua_rtpg.c index 4db13c2..2db9153 100644 --- a/libmultipath/prioritizers/alua_rtpg.c +++ b/libmultipath/prioritizers/alua_rtpg.c @@ -27,7 +27,7 @@ #include "../structs.h" #include "../prio.h" #include "../discovery.h" -#include "../debug.h" +#include "debug.h" #include "alua_rtpg.h" #define SENSE_BUFF_LEN 32 From patchwork Tue Aug 30 19:27:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12959776 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A80BC0502C for ; Tue, 30 Aug 2022 19:28:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661887709; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=WUDd3VuInDqCP0FmibsZxjYSsZ7LSTf4A/GzxSQ3SBc=; b=OxFOfRDMipx7J/mebFvjntUc/N8sjxAA0tfv2pRupUIQwrgNemz26wxkSDed31gafid+rz Vxj66uBVjrUDLKfjaM5Ucj7QtKXBxXk9sfglOcwi6BfTj/U3zEpxWL5d16hJwV0BnDBU1Q 0yS3pTbI3jR3GwNp2SziwyKa1moQpn4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-646-vSZ5cH0pMzSAST5mCtDehw-1; Tue, 30 Aug 2022 15:28:26 -0400 X-MC-Unique: vSZ5cH0pMzSAST5mCtDehw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0A1D43802BAB; Tue, 30 Aug 2022 19:28:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BEF040E7F28; Tue, 30 Aug 2022 19:28:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E8C961946A62; Tue, 30 Aug 2022 19:28:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B6AE81946A40 for ; Tue, 30 Aug 2022 19:28:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AAA3D4010E6E; Tue, 30 Aug 2022 19:28:16 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A6C52400E88E for ; Tue, 30 Aug 2022 19:28:16 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8FDAE29AB3F7 for ; Tue, 30 Aug 2022 19:28:16 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-44-25CfphdTMP6lFw5aqpczag-1; Tue, 30 Aug 2022 15:28:14 -0400 X-MC-Unique: 25CfphdTMP6lFw5aqpczag-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CDA5B1FB24; Tue, 30 Aug 2022 19:28:11 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9C4FC13B0C; Tue, 30 Aug 2022 19:28:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KMBwJMtkDmO5GgAAMHmgww (envelope-from ); Tue, 30 Aug 2022 19:28:11 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Tue, 30 Aug 2022 21:27:08 +0200 Message-Id: <20220830192713.19778-8-mwilck@suse.com> In-Reply-To: <20220830192713.19778-1-mwilck@suse.com> References: <20220830192713.19778-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Subject: [dm-devel] [PATCH v4 07/12] libmultipath: remove weak attribute for {get, put}_multipath_config X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck The "weak" attribute was set to make sure that these symbols are overridden by symbols of the same name in the main executable. This is unnecessary, as the standard ELF symbol resolution algorithm ensures this even without the "weak" attribute. See ELF Specification, III.2 Dynamic Linking / Shared Object Dependencies: "The dynamic linker examines the symbol tables with a breadth-first search. That is, it first looks at the symbol table of the executable program itself, then at the symbol tables of the DT_NEEDED entries (in order), then at the second level DT_NEEDED entries, and so on". Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmultipath/config.c | 4 ++-- libmultipath/config.h | 11 ----------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index a2c79a4..5c5c072 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -82,7 +82,7 @@ struct config *libmp_get_multipath_config(void) } struct config *get_multipath_config(void) - __attribute__((weak, alias("libmp_get_multipath_config"))); + __attribute__((alias("libmp_get_multipath_config"))); void libmp_put_multipath_config(void *conf __attribute__((unused))) { @@ -90,7 +90,7 @@ void libmp_put_multipath_config(void *conf __attribute__((unused))) } void put_multipath_config(void *conf) - __attribute__((weak, alias("libmp_put_multipath_config"))); + __attribute__((alias("libmp_put_multipath_config"))); static int hwe_strmatch (const struct hwentry *hwe1, const struct hwentry *hwe2) diff --git a/libmultipath/config.h b/libmultipath/config.h index fdcdff0..2d00ad2 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -303,17 +303,6 @@ void free_config (struct config * conf); int init_config(const char *file); void uninit_config(void); -/* - * libmultipath provides default implementations of - * get_multipath_config() and put_multipath_config(). - * Applications using these should use init_config(file, NULL) - * to load the configuration, rather than load_config(file). - * Likewise, uninit_config() should be used for teardown, but - * using free_config() for that is supported, too. - * Applications can define their own {get,put}_multipath_config() - * functions, which override the library-internal ones, but - * could still call libmp_{get,put}_multipath_config(). - */ struct config *libmp_get_multipath_config(void); struct config *get_multipath_config(void); void libmp_put_multipath_config(void *); From patchwork Tue Aug 30 19:27:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12959780 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44D6EC54EE9 for ; Tue, 30 Aug 2022 19:28:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661887711; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=BqBiEv3SlNdEi1O8GgpzMfBpqiMrevEScfbME+lvw2Q=; b=PGrYUkay3aHYa/+nM3UaRz2Ei+vQfeE8IKl6t4+XHIQ5J4yaClgnThBa8ugF2OA7MLqirJ /7YyD+azv1kTxu6prCKhrZeeWn8rKhEb8Sd1YioNez9bKYREyE9blU9V2I6XDN3qS3h8/o h4YGbPWetk6OKt3aDWVMagMfIRMu1H8= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-422-MsJavHhUMRyS6e_GNML4bA-1; Tue, 30 Aug 2022 15:28:28 -0400 X-MC-Unique: MsJavHhUMRyS6e_GNML4bA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 60EC53802AC5; Tue, 30 Aug 2022 19:28:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C8C2492C3B; Tue, 30 Aug 2022 19:28:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 326651946A42; Tue, 30 Aug 2022 19:28:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DF4E51946A40 for ; Tue, 30 Aug 2022 19:28:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C3CAC1415133; Tue, 30 Aug 2022 19:28:18 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast10.extmail.prod.ext.rdu2.redhat.com [10.11.55.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF852141512E for ; Tue, 30 Aug 2022 19:28:18 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A01921C06EE5 for ; Tue, 30 Aug 2022 19:28:18 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-380-CQq2zAIFN4OG6-nVqHzkcQ-1; Tue, 30 Aug 2022 15:28:15 -0400 X-MC-Unique: CQq2zAIFN4OG6-nVqHzkcQ-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 29F251FB25; Tue, 30 Aug 2022 19:28:12 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E04CE13B0C; Tue, 30 Aug 2022 19:28:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KFobNctkDmO5GgAAMHmgww (envelope-from ); Tue, 30 Aug 2022 19:28:11 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Tue, 30 Aug 2022 21:27:09 +0200 Message-Id: <20220830192713.19778-9-mwilck@suse.com> In-Reply-To: <20220830192713.19778-1-mwilck@suse.com> References: <20220830192713.19778-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Subject: [dm-devel] [PATCH v4 08/12] libmultipath: split off libmpathutil X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck Split libmultipath into two libraries: libmpathutil contains generic utilities that don't relate to device-mapper or multipath specifically. libmultipath retains multipath-specific code. The reason for this change is that we'll create a small client program that takes over the role of "multipath -k", the interactive client. This way multipathd doesn't need to link against libreadline any more. The client only needs functionality from libmpathutil, which doesn't contain code that isn't compliant with GPL-3.0, and can thus be linked to libreadline without conflicts. The new library contains weak implementations of {get,put}_multipath_config, which are meant to be superseded by libmultipath's implementation. In the interactive client, these functions aren't needed. As we now have an ABI between libmpathutil and libmultipath, the ABI must be extended by adding functions from libmpathutil that are used internally by libmultipath. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- Makefile | 4 +- Makefile.inc | 1 + libmpathpersist/Makefile | 6 +- libmpathutil/Makefile | 70 +++++++++++ {libmultipath => libmpathutil}/debug.c | 0 {libmultipath => libmpathutil}/debug.h | 0 libmpathutil/globals.c | 12 ++ libmpathutil/globals.h | 39 ++++++ libmpathutil/libmpathutil.version | 123 +++++++++++++++++++ {libmultipath => libmpathutil}/log.c | 0 {libmultipath => libmpathutil}/log.h | 0 {libmultipath => libmpathutil}/log_pthread.c | 0 {libmultipath => libmpathutil}/log_pthread.h | 0 {libmultipath => libmpathutil}/msort.c | 0 {libmultipath => libmpathutil}/msort.h | 0 {libmultipath => libmpathutil}/parser.c | 0 {libmultipath => libmpathutil}/parser.h | 2 +- {libmultipath => libmpathutil}/strbuf.c | 0 {libmultipath => libmpathutil}/strbuf.h | 0 {libmultipath => libmpathutil}/time-util.c | 0 {libmultipath => libmpathutil}/time-util.h | 0 {libmultipath => libmpathutil}/util.c | 0 {libmultipath => libmpathutil}/util.h | 0 {libmultipath => libmpathutil}/uxsock.c | 0 {libmultipath => libmpathutil}/uxsock.h | 0 {libmultipath => libmpathutil}/vector.c | 0 {libmultipath => libmpathutil}/vector.h | 0 libmpathvalid/Makefile | 6 +- libmultipath/Makefile | 15 ++- libmultipath/checkers/Makefile | 6 +- libmultipath/config.h | 3 +- libmultipath/foreign/Makefile | 6 +- libmultipath/libmultipath.version | 41 ------- libmultipath/prioritizers/Makefile | 6 +- mpathpersist/Makefile | 4 +- multipath/Makefile | 6 +- multipathd/Makefile | 12 +- tests/Makefile | 12 +- 38 files changed, 290 insertions(+), 84 deletions(-) create mode 100644 libmpathutil/Makefile rename {libmultipath => libmpathutil}/debug.c (100%) rename {libmultipath => libmpathutil}/debug.h (100%) create mode 100644 libmpathutil/globals.c create mode 100644 libmpathutil/globals.h create mode 100644 libmpathutil/libmpathutil.version rename {libmultipath => libmpathutil}/log.c (100%) rename {libmultipath => libmpathutil}/log.h (100%) rename {libmultipath => libmpathutil}/log_pthread.c (100%) rename {libmultipath => libmpathutil}/log_pthread.h (100%) rename {libmultipath => libmpathutil}/msort.c (100%) rename {libmultipath => libmpathutil}/msort.h (100%) rename {libmultipath => libmpathutil}/parser.c (100%) rename {libmultipath => libmpathutil}/parser.h (99%) rename {libmultipath => libmpathutil}/strbuf.c (100%) rename {libmultipath => libmpathutil}/strbuf.h (100%) rename {libmultipath => libmpathutil}/time-util.c (100%) rename {libmultipath => libmpathutil}/time-util.h (100%) rename {libmultipath => libmpathutil}/util.c (100%) rename {libmultipath => libmpathutil}/util.h (100%) rename {libmultipath => libmpathutil}/uxsock.c (100%) rename {libmultipath => libmpathutil}/uxsock.h (100%) rename {libmultipath => libmpathutil}/vector.c (100%) rename {libmultipath => libmpathutil}/vector.h (100%) diff --git a/Makefile b/Makefile index ffca586..5851149 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ LIB_BUILDDIRS := \ libmpathcmd \ + libmpathutil \ libmultipath \ libmpathpersist \ libmpathvalid @@ -72,7 +73,8 @@ compile_commands.json: Makefile Makefile.inc $(BUILDDIRS:=/Makefile) $(MAKE) clean bear -- $(MAKE) -libmultipath libdmmp: libmpathcmd +libmpathutil libdmmp: libmpathcmd +libmultipath: libmpathutil libmpathpersist libmpathvalid multipath multipathd: libmultipath libmultipath/prioritizers libmultipath/checkers libmultipath/foreign: libmultipath mpathpersist multipathd: libmpathpersist diff --git a/Makefile.inc b/Makefile.inc index 4b32fa7..6399beb 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -86,6 +86,7 @@ libudevdir = $(prefix)/$(SYSTEMDPATH)/udev udevrulesdir = $(libudevdir)/rules.d modulesloaddir = $(prefix)/$(SYSTEMDPATH)/modules-load.d multipathdir = $(TOPDIR)/libmultipath +mpathutildir = $(TOPDIR)/libmpathutil man8dir = $(prefix)/usr/share/man/man8 man5dir = $(prefix)/usr/share/man/man5 man3dir = $(prefix)/usr/share/man/man3 diff --git a/libmpathpersist/Makefile b/libmpathpersist/Makefile index 9843d96..4e1717e 100644 --- a/libmpathpersist/Makefile +++ b/libmpathpersist/Makefile @@ -5,10 +5,10 @@ DEVLIB = libmpathpersist.so LIBS = $(DEVLIB).$(SONAME) VERSION_SCRIPT:= libmpathpersist.version -CFLAGS += $(LIB_CFLAGS) -I$(multipathdir) -I$(mpathpersistdir) -I$(mpathcmddir) -LDFLAGS += -L$(multipathdir) -L$(mpathcmddir) +CFLAGS += $(LIB_CFLAGS) -I$(multipathdir) -I$(mpathutildir) -I$(mpathpersistdir) -I$(mpathcmddir) +LDFLAGS += -L$(multipathdir) -L$(mpathutildir) -L$(mpathcmddir) -LIBDEPS += -lmultipath -lmpathcmd -ldevmapper -lpthread -ldl +LIBDEPS += -lmultipath -lmpathutil -lmpathcmd -ldevmapper -lpthread -ldl OBJS = mpath_persist.o mpath_updatepr.o mpath_pr_ioctl.o mpath_persist_int.o diff --git a/libmpathutil/Makefile b/libmpathutil/Makefile new file mode 100644 index 0000000..68b1c7d --- /dev/null +++ b/libmpathutil/Makefile @@ -0,0 +1,70 @@ +# +# Copyright (C) 2003 Christophe Varoqui, +# +include ../Makefile.inc + +SONAME = 0 +DEVLIB = libmpathutil.so +LIBS = $(DEVLIB).$(SONAME) +VERSION_SCRIPT := libmpathutil.version + +CPPFLAGS += -I. -I$(multipathdir) -I$(mpathcmddir) +CFLAGS += $(LIB_CFLAGS) -D_GNU_SOURCE + +LIBDEPS += -lpthread -ldl -ludev -L$(mpathcmddir) -lmpathcmd + +ifdef SYSTEMD + CPPFLAGS += -DUSE_SYSTEMD=$(SYSTEMD) + ifeq ($(shell test $(SYSTEMD) -gt 209 && echo 1), 1) + LIBDEPS += -lsystemd + else + LIBDEPS += -lsystemd-daemon + endif +endif + +# object files referencing MULTIPATH_DIR or CONFIG_DIR +# they need to be recompiled for unit tests + +# other object files +OBJS := parser.o vector.o util.o debug.o time-util.o \ + uxsock.o log_pthread.o log.o strbuf.o globals.o msort.o + +all: $(DEVLIB) + +make_static = $(shell sed '/^static/!s/^\([a-z]\{1,\} \)/static \1/' <$1 >$2) + +$(LIBS): $(OBJS) $(VERSION_SCRIPT) + $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ \ + -Wl,--version-script=$(VERSION_SCRIPT) -o $@ $(OBJS) $(LIBDEPS) + +$(DEVLIB): $(LIBS) + $(LN) $(LIBS) $@ + +$(NV_VERSION_SCRIPT): $(VERSION_SCRIPT) + @printf 'NOVERSION {\nglobal:\n' >$@ + @grep -P '^[ \t]+[a-zA-Z_][a-zA-Z0-9_]*;' $< >>$@ + @printf 'local:\n\t*;\n};\n' >>$@ + +$(LIBS:%.so.$(SONAME)=%-nv.so): $(OBJS) $(NV_VERSION_SCRIPT) + $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ \ + -Wl,--version-script=$(NV_VERSION_SCRIPT) -o $@ $(OBJS) $(LIBDEPS) + +abi: $(LIBS:%.so.$(SONAME)=%-nv.abi) + +install: all + $(INSTALL_PROGRAM) -d $(DESTDIR)$(syslibdir) + $(INSTALL_PROGRAM) -m 755 $(LIBS) $(DESTDIR)$(syslibdir)/$(LIBS) + $(INSTALL_PROGRAM) -m 755 -d $(DESTDIR)$(libdir) + $(LN) $(LIBS) $(DESTDIR)$(syslibdir)/$(DEVLIB) + +uninstall: + $(RM) $(DESTDIR)$(syslibdir)/$(LIBS) + $(RM) $(DESTDIR)$(syslibdir)/$(DEVLIB) + +clean: dep_clean + $(RM) core *.a *.o *.so *.so.* *.abi nvme-ioctl.c nvme-ioctl.h $(NV_VERSION_SCRIPT) + +include $(wildcard $(OBJS:.o=.d)) + +dep_clean: + $(RM) $(OBJS:.o=.d) diff --git a/libmultipath/debug.c b/libmpathutil/debug.c similarity index 100% rename from libmultipath/debug.c rename to libmpathutil/debug.c diff --git a/libmultipath/debug.h b/libmpathutil/debug.h similarity index 100% rename from libmultipath/debug.h rename to libmpathutil/debug.h diff --git a/libmpathutil/globals.c b/libmpathutil/globals.c new file mode 100644 index 0000000..0c9a5ba --- /dev/null +++ b/libmpathutil/globals.c @@ -0,0 +1,12 @@ +#include +#include +#include "globals.h" + +struct udev __attribute__((weak)) *udev; +struct config __attribute__((weak)) *get_multipath_config(void) +{ + return NULL; +} + +void __attribute__((weak)) put_multipath_config(void *p __attribute__((unused))) +{} diff --git a/libmpathutil/globals.h b/libmpathutil/globals.h new file mode 100644 index 0000000..fab507e --- /dev/null +++ b/libmpathutil/globals.h @@ -0,0 +1,39 @@ +#ifndef _GLOBALS_H +#define _GLOBALS_H + +struct config; + +/** + * extern variable: udev + * + * A &struct udev instance used by libmultipath. libmultipath expects + * a valid, initialized &struct udev in this variable. + * An application can define this variable itself, in which case + * the applications's instance will take precedence. + * The application can initialize and destroy this variable by + * calling libmultipath_init() and libmultipath_exit(), respectively, + * whether or not it defines the variable itself. + * An application can initialize udev with udev_new() before calling + * libmultipath_init(), e.g. if it has to make libudev calls before + * libmultipath calls. If an application wants to keep using the + * udev variable after calling libmultipath_exit(), it should have taken + * an additional reference on it beforehand. This is the case e.g. + * after initializing udev with udev_new(). + */ +extern struct udev *udev; + +/* + * libmultipath provides default implementations of + * get_multipath_config() and put_multipath_config(). + * Applications using these should use init_config(file, NULL) + * to load the configuration, rather than load_config(file). + * Likewise, uninit_config() should be used for teardown, but + * using free_config() for that is supported, too. + * Applications can define their own {get,put}_multipath_config() + * functions, which override the library-internal ones, but + * could still call libmp_{get,put}_multipath_config(). + */ +void put_multipath_config(void *); +struct config *get_multipath_config(void); + +#endif diff --git a/libmpathutil/libmpathutil.version b/libmpathutil/libmpathutil.version new file mode 100644 index 0000000..3be5558 --- /dev/null +++ b/libmpathutil/libmpathutil.version @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2020 SUSE LLC + * SPDX-License-Identifier: GPL-2.0-or-later + * + * libmultipath ABI (libmpathutil part) + * + * libmultipath doesn't have a stable ABI in the usual sense. In particular, + * the library does not attempt to ship different versions of the same symbol + * for backward compatibility. + * + * The ABI versioning only serves to avoid linking with a non-matching ABI, to + * cut down the set of exported symbols, and to describe it. + * The version string is LIBMULTIPATH_$MAJOR.$MINOR.$REL. + * + * Policy: + * + * * Bump $MAJOR for incompatible changes, like: + * - symbols removed + * - parameter list or return values changed for existing functions + * - externally visible data structures changed in incompatible ways + * (like offsets of previously existing struct members) + * In this case, the new version doesn't inherit the previous versions, + * because the new library doesn't provide the full previous ABI any more. + * All predecessors are merged into the new version. + * + * * Bump $MINOR for compatible changes, like adding symbols. + * The new version inherits the previous ones. + * + * * Bump $REL to describe deviations from upstream, e.g. in + * multipath-tools packages shipped by distributions. + * The new version inherits the previous ones. + */ + +/* symbols referenced by multipath and multipathd */ +LIBMULTIPATH_15.0.0 { +global: + alloc_strvec; + append_strbuf_str; + cleanup_charp; + cleanup_mutex; + cleanup_ucharp; + close_fd; + convert_dev; + dlog; + fill_strbuf; + find_slot; + free_scandir_result; + free_strvec; + get_monotonic_time; + get_multipath_config; + get_next_string; + get_strbuf_len; + get_strbuf_str; + is_quote; + log_thread_reset; + log_thread_start; + log_thread_stop; + logsink; + normalize_timespec; + print_strbuf; + pthread_cond_init_mono; + put_multipath_config; + recv_packet; + reset_strbuf; + send_packet; + set_max_fds; + setup_thread_attr; + strchop; + strlcpy; + timespeccmp; + timespecsub; + truncate_strbuf; + udev; + ux_socket_listen; + vector_alloc; + vector_alloc_slot; + vector_del_slot; + vector_free; + vector_reset; + vector_set_slot; + +local: + *; +}; + +/* symbols referenced internally by libmultipath */ +LIBMPATHUTIL_1.0 { + alloc_bitfield; + __append_strbuf_str; + append_strbuf_quoted; + basenamecpy; + cleanup_free_ptr; + devt2devname; + filepresent; + find_keyword; + free_keywords; + get_linux_version_code; + __get_strbuf_buf; + get_word; + _install_keyword; + install_sublevel; + install_sublevel_end; + keyword_alloc; + libmp_verbosity; + _log_bitfield_overflow; + log_safe; + msort; + parse_devt; + parse_prkey; + process_file; + safe_write; + set_value; + should_exit; + snprint_keyword; + steal_strbuf_str; + strlcat; + systemd_service_enabled; + validate_config_strvec; + vector_find_or_add_slot; + vector_insert_slot; + vector_move_up; + vector_sort; +}; diff --git a/libmultipath/log.c b/libmpathutil/log.c similarity index 100% rename from libmultipath/log.c rename to libmpathutil/log.c diff --git a/libmultipath/log.h b/libmpathutil/log.h similarity index 100% rename from libmultipath/log.h rename to libmpathutil/log.h diff --git a/libmultipath/log_pthread.c b/libmpathutil/log_pthread.c similarity index 100% rename from libmultipath/log_pthread.c rename to libmpathutil/log_pthread.c diff --git a/libmultipath/log_pthread.h b/libmpathutil/log_pthread.h similarity index 100% rename from libmultipath/log_pthread.h rename to libmpathutil/log_pthread.h diff --git a/libmultipath/msort.c b/libmpathutil/msort.c similarity index 100% rename from libmultipath/msort.c rename to libmpathutil/msort.c diff --git a/libmultipath/msort.h b/libmpathutil/msort.h similarity index 100% rename from libmultipath/msort.h rename to libmpathutil/msort.h diff --git a/libmultipath/parser.c b/libmpathutil/parser.c similarity index 100% rename from libmultipath/parser.c rename to libmpathutil/parser.c diff --git a/libmultipath/parser.h b/libmpathutil/parser.h similarity index 99% rename from libmultipath/parser.h rename to libmpathutil/parser.h index 11ea227..9d9d948 100644 --- a/libmultipath/parser.h +++ b/libmpathutil/parser.h @@ -33,8 +33,8 @@ /* local includes */ #include "vector.h" -#include "config.h" struct strbuf; +struct config; /* Global definitions */ #define EOB "}" diff --git a/libmultipath/strbuf.c b/libmpathutil/strbuf.c similarity index 100% rename from libmultipath/strbuf.c rename to libmpathutil/strbuf.c diff --git a/libmultipath/strbuf.h b/libmpathutil/strbuf.h similarity index 100% rename from libmultipath/strbuf.h rename to libmpathutil/strbuf.h diff --git a/libmultipath/time-util.c b/libmpathutil/time-util.c similarity index 100% rename from libmultipath/time-util.c rename to libmpathutil/time-util.c diff --git a/libmultipath/time-util.h b/libmpathutil/time-util.h similarity index 100% rename from libmultipath/time-util.h rename to libmpathutil/time-util.h diff --git a/libmultipath/util.c b/libmpathutil/util.c similarity index 100% rename from libmultipath/util.c rename to libmpathutil/util.c diff --git a/libmultipath/util.h b/libmpathutil/util.h similarity index 100% rename from libmultipath/util.h rename to libmpathutil/util.h diff --git a/libmultipath/uxsock.c b/libmpathutil/uxsock.c similarity index 100% rename from libmultipath/uxsock.c rename to libmpathutil/uxsock.c diff --git a/libmultipath/uxsock.h b/libmpathutil/uxsock.h similarity index 100% rename from libmultipath/uxsock.h rename to libmpathutil/uxsock.h diff --git a/libmultipath/vector.c b/libmpathutil/vector.c similarity index 100% rename from libmultipath/vector.c rename to libmpathutil/vector.c diff --git a/libmultipath/vector.h b/libmpathutil/vector.h similarity index 100% rename from libmultipath/vector.h rename to libmpathutil/vector.h diff --git a/libmpathvalid/Makefile b/libmpathvalid/Makefile index 0a51925..5dbfb92 100644 --- a/libmpathvalid/Makefile +++ b/libmpathvalid/Makefile @@ -5,11 +5,11 @@ DEVLIB = libmpathvalid.so LIBS = $(DEVLIB).$(SONAME) VERSION_SCRIPT := libmpathvalid.version -CPPFLAGS += -I$(multipathdir) -I$(mpathcmddir) +CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) -I$(mpathcmddir) CFLAGS += $(LIB_CFLAGS) -LIBDEPS += -lpthread -ldevmapper -ldl -L$(multipathdir) \ - -lmultipath -L$(mpathcmddir) -lmpathcmd -ludev +LIBDEPS += -lpthread -ldevmapper -ldl -L$(multipathdir) -lmultipath \ + -L$(mpathutildir) -lmpathutil -L$(mpathcmddir) -lmpathcmd -ludev OBJS = mpath_valid.o diff --git a/libmultipath/Makefile b/libmultipath/Makefile index 6e87a16..3b60a52 100644 --- a/libmultipath/Makefile +++ b/libmultipath/Makefile @@ -8,10 +8,10 @@ DEVLIB = libmultipath.so LIBS = $(DEVLIB).$(SONAME) VERSION_SCRIPT := libmultipath.version -CPPFLAGS += -I$(mpathcmddir) -I$(nvmedir) -D_GNU_SOURCE +CPPFLAGS += -I$(mpathutildir) -I$(mpathcmddir) -I$(nvmedir) -D_GNU_SOURCE CFLAGS += $(LIB_CFLAGS) -LIBDEPS += -lpthread -ldl -ldevmapper -ludev -L$(mpathcmddir) -lmpathcmd -lurcu -laio +LIBDEPS += -lpthread -ldl -ldevmapper -ludev -L$(mpathutildir) -lmpathutil -L$(mpathcmddir) -lmpathcmd -lurcu -laio ifdef SYSTEMD CPPFLAGS += -DUSE_SYSTEMD=$(SYSTEMD) @@ -56,15 +56,14 @@ OBJS-U := prio.o checkers.o foreign.o config.o OBJS-T := $(patsubst %.o,%-test.o,$(OBJS-U)) # other object files -OBJS-O := parser.o vector.o devmapper.o \ - hwtable.o blacklist.o util.o dmparser.o \ +OBJS-O := devmapper.o hwtable.o blacklist.o dmparser.o \ structs.o discovery.o propsel.o dict.o \ - pgpolicies.o debug.o defaults.o uevent.o time-util.o \ - switchgroup.o uxsock.o print.o alias.o log_pthread.o \ - log.o configure.o structs_vec.o sysfs.o \ + pgpolicies.o defaults.o uevent.o \ + switchgroup.o print.o alias.o \ + configure.o structs_vec.o sysfs.o \ lock.o file.o wwids.o prioritizers/alua_rtpg.o prkey.o \ io_err_stat.o dm-generic.o generic.o nvme-lib.o \ - libsg.o valid.o strbuf.o msort.o + libsg.o valid.o OBJS := $(OBJS-O) $(OBJS-U) diff --git a/libmultipath/checkers/Makefile b/libmultipath/checkers/Makefile index 69de1ed..c9a2c4c 100644 --- a/libmultipath/checkers/Makefile +++ b/libmultipath/checkers/Makefile @@ -4,10 +4,10 @@ TOPDIR = ../.. include ../../Makefile.inc -CPPFLAGS += -I$(multipathdir) +CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) CFLAGS += $(LIB_CFLAGS) -LDFLAGS += -L$(multipathdir) -LIBDEPS = -lmultipath -laio -lpthread -lrt +LDFLAGS += -L$(multipathdir) -L$(mpathutildir) +LIBDEPS = -lmultipath -lmpathutil -laio -lpthread -lrt # If you add or remove a checker also update multipath/multipath.conf.5 LIBS= \ diff --git a/libmultipath/config.h b/libmultipath/config.h index 2d00ad2..8794746 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -6,6 +6,7 @@ #include #include #include "byteorder.h" +#include "globals.h" #define ORIGIN_DEFAULT 0 #define ORIGIN_CONFIG 1 @@ -304,9 +305,7 @@ int init_config(const char *file); void uninit_config(void); struct config *libmp_get_multipath_config(void); -struct config *get_multipath_config(void); void libmp_put_multipath_config(void *); -void put_multipath_config(void *); int parse_uid_attrs(char *uid_attrs, struct config *conf); const char *get_uid_attribute_by_attrs(const struct config *conf, diff --git a/libmultipath/foreign/Makefile b/libmultipath/foreign/Makefile index 3d4491a..d0232f2 100644 --- a/libmultipath/foreign/Makefile +++ b/libmultipath/foreign/Makefile @@ -4,10 +4,10 @@ TOPDIR=../.. include ../../Makefile.inc -CPPFLAGS += -I$(multipathdir) -I$(nvmedir) +CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) -I$(nvmedir) CFLAGS += $(LIB_CFLAGS) -LDFLAGS += -L$(multipathdir) -LIBDEPS = -lmultipath -ludev -lpthread -lrt +LDFLAGS += -L$(multipathdir) -L$(mpathutildir) +LIBDEPS = -lmultipath -lmpathutil -ludev -lpthread -lrt LIBS = libforeign-nvme.so diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version index c1d9b15..1cda40b 100644 --- a/libmultipath/libmultipath.version +++ b/libmultipath/libmultipath.version @@ -42,8 +42,6 @@ global: alloc_path; alloc_path_layout; alloc_path_with_pathinfo; - alloc_strvec; - append_strbuf_str; change_foreign; check_alias_settings; check_daemon; @@ -54,17 +52,11 @@ global: checker_name; checker_state_name; check_foreign; - cleanup_charp; cleanup_lock; - cleanup_mutex; - cleanup_ucharp; - close_fd; coalesce_paths; - convert_dev; count_active_paths; delete_all_foreign; delete_foreign; - dlog; dm_cancel_deferred_remove; dm_enablegroup; dm_fail_path; @@ -99,7 +91,6 @@ global: find_mpe; find_path_by_dev; find_path_by_devt; - find_slot; foreign_multipath_layout; foreign_path_layout; free_config; @@ -107,16 +98,12 @@ global: free_multipathvec; free_path; free_pathvec; - free_strvec; - get_monotonic_time; get_multipath_config; get_multipath_layout; get_path_layout; get_pgpolicy_id; get_refwwid; get_state; - get_strbuf_len; - get_strbuf_str; get_udev_device; get_uid; get_used_hwes; @@ -129,7 +116,6 @@ global: init_prio; io_err_stat_handle_pathfail; is_path_valid; - is_quote; libmp_dm_task_create; libmp_get_version; libmp_get_multipath_config; @@ -140,12 +126,7 @@ global: libmultipath_exit; libmultipath_init; load_config; - log_thread_reset; - log_thread_start; - log_thread_stop; - logsink; need_io_err_check; - normalize_timespec; orphan_path; parse_prkey_flags; pathcount; @@ -156,10 +137,7 @@ global: print_all_paths; print_foreign_topology; _print_multipath_topology; - print_strbuf; - pthread_cond_init_mono; put_multipath_config; - recv_packet; reinstate_paths; remember_wwid; remove_map; @@ -169,20 +147,16 @@ global: remove_wwid; replace_wwids; reset_checker_classes; - reset_strbuf; select_all_tg_pt; select_action; select_find_multipaths_timeout; select_no_path_retry; select_path_group; select_reservation_key; - send_packet; - set_max_fds; set_no_path_retry; set_path_removed; set_prkey; setup_map; - setup_thread_attr; should_multipath; skip_libmp_dm_init; snprint_blacklist_report; @@ -204,16 +178,11 @@ global: stop_io_err_stat_thread; store_path; store_pathinfo; - strchop; - strlcpy; sync_map_state; sysfs_get_size; sysfs_is_multipathed; - timespeccmp; - timespecsub; trigger_path_udev_change; trigger_paths_udev_change; - truncate_strbuf; udev; uevent_dispatch; uevent_get_dm_str; @@ -226,14 +195,7 @@ global: update_multipath_table; update_queue_mode_add_path; update_queue_mode_del_path; - ux_socket_listen; valid_alias; - vector_alloc; - vector_alloc_slot; - vector_del_slot; - vector_free; - vector_reset; - vector_set_slot; verify_paths; /* checkers */ @@ -242,9 +204,7 @@ global: start_checker_thread; /* prioritizers */ - fill_strbuf; get_asymmetric_access_state; - get_next_string; get_prio_timeout; get_target_port_group; get_target_port_group_support; @@ -262,7 +222,6 @@ global: sysfs_get_asymmetric_access_state; /* foreign */ - free_scandir_result; local: *; diff --git a/libmultipath/prioritizers/Makefile b/libmultipath/prioritizers/Makefile index eb6f03b..400f773 100644 --- a/libmultipath/prioritizers/Makefile +++ b/libmultipath/prioritizers/Makefile @@ -5,10 +5,10 @@ TOPDIR=../.. include ../../Makefile.inc -CPPFLAGS += -I$(multipathdir) +CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) CFLAGS += $(LIB_CFLAGS) -LDFLAGS += -L$(multipathdir) -LIBDEPS = -lmultipath -lm -lpthread -lrt +LDFLAGS += -L$(multipathdir) -L$(mpathutildir) +LIBDEPS = -lmultipath -lmpathutil -lm -lpthread -lrt # If you add or remove a prioritizer also update multipath/multipath.conf.5 LIBS = \ diff --git a/mpathpersist/Makefile b/mpathpersist/Makefile index 2e4d483..2219c86 100644 --- a/mpathpersist/Makefile +++ b/mpathpersist/Makefile @@ -1,11 +1,11 @@ include ../Makefile.inc -CPPFLAGS += -I$(multipathdir) -I$(mpathpersistdir) +CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) -I$(mpathpersistdir) CFLAGS += $(BIN_CFLAGS) LDFLAGS += $(BIN_LDFLAGS) LIBDEPS += -L$(mpathpersistdir) -lmpathpersist -L$(multipathdir) -lmultipath \ - -L$(mpathcmddir) -lmpathcmd -lpthread -ldevmapper -ludev + -L$(mpathutildir) -lmpathutil -L$(mpathcmddir) -lmpathcmd -lpthread -ldevmapper -ludev EXEC = mpathpersist diff --git a/multipath/Makefile b/multipath/Makefile index bcb0453..46b7553 100644 --- a/multipath/Makefile +++ b/multipath/Makefile @@ -3,11 +3,11 @@ # include ../Makefile.inc -CPPFLAGS += -I$(multipathdir) -I$(mpathcmddir) +CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) -I$(mpathcmddir) CFLAGS += $(BIN_CFLAGS) LDFLAGS += $(BIN_LDFLAGS) -LIBDEPS += -L$(multipathdir) -lmultipath -L$(mpathcmddir) -lmpathcmd \ - -lpthread -ldevmapper -ldl -ludev +LIBDEPS += -L$(multipathdir) -lmultipath -L$(mpathutildir) -lmpathutil \ + -L$(mpathcmddir) -lmpathcmd -lpthread -ldevmapper -ldl -ludev EXEC = multipath diff --git a/multipathd/Makefile b/multipathd/Makefile index 95acd88..7128510 100644 --- a/multipathd/Makefile +++ b/multipathd/Makefile @@ -15,14 +15,16 @@ endif #CPPFLAGS += -D_DEBUG_ #CPPFLAGS += -DLOGDBG -CPPFLAGS += -I$(multipathdir) -I$(mpathpersistdir) -I$(mpathcmddir) -I$(thirdpartydir) \ +CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) -I$(mpathpersistdir) -I$(mpathcmddir) -I$(thirdpartydir) \ $(shell $(PKGCONFIG) --modversion liburcu 2>/dev/null | \ awk -F. '{ printf("-DURCU_VERSION=0x%06x", 256 * ( 256 * $$1 + $$2) + $$3); }') CFLAGS += $(BIN_CFLAGS) LDFLAGS += $(BIN_LDFLAGS) + +CLI_LIBDEPS := -L$(mpathutildir) -lmpathutil -L$(mpathcmddir) -lmpathcmd -ludev -ldl -lurcu -lpthread LIBDEPS += -L$(multipathdir) -lmultipath -L$(mpathpersistdir) -lmpathpersist \ - -L$(mpathcmddir) -lmpathcmd -ludev -ldl -lurcu -lpthread \ - -ldevmapper + -ldevmapper $(CLI_LIBDEPS) + ifeq ($(READLINE),libedit) CPPFLAGS += -DUSE_LIBEDIT @@ -36,9 +38,9 @@ endif ifdef SYSTEMD CPPFLAGS += -DUSE_SYSTEMD=$(SYSTEMD) ifeq ($(shell test $(SYSTEMD) -gt 209 && echo 1), 1) - LIBDEPS += -lsystemd + CLI_LIBDEPS += -lsystemd else - LIBDEPS += -lsystemd-daemon + CLI_LIBDEPS += -lsystemd-daemon endif endif ifeq ($(ENABLE_DMEVENTS_POLL),0) diff --git a/tests/Makefile b/tests/Makefile index 95a9990..9866962 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -11,9 +11,9 @@ TEST_MISSING_INITIALIZERS = $(shell \ || echo -Wno-missing-field-initializers) W_MISSING_INITIALIZERS := $(call TEST_MISSING_INITIALIZERS) -CPPFLAGS += -I$(multipathdir) -I$(mpathcmddir) -DTESTCONFDIR=\"$(TESTDIR)/conf.d\" +CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) -I$(mpathcmddir) -DTESTCONFDIR=\"$(TESTDIR)/conf.d\" CFLAGS += $(BIN_CFLAGS) -Wno-unused-parameter $(W_MISSING_INITIALIZERS) -LIBDEPS += -L. -L$(mpathcmddir) -lmultipath -lmpathcmd -lcmocka +LIBDEPS += -L. -L $(mpathutildir) -L$(mpathcmddir) -lmultipath -lmpathutil -lmpathcmd -lcmocka TESTS := uevent parser util dmevents hwtable blacklist unaligned vpd pgpolicy \ alias directio valid devt mpathvalid strbuf sysfs @@ -69,9 +69,9 @@ mpathvalid-test_OBJDEPS := ../libmpathvalid/mpath_valid.o ifneq ($(DIO_TEST_DEV),) directio-test_LIBDEPS := -laio endif -strbuf-test_OBJDEPS := ../libmultipath/strbuf.o +strbuf-test_OBJDEPS := ../libmpathutil/strbuf.o sysfs-test_TESTDEPS := test-log.o -sysfs-test_OBJDEPS := ../libmultipath/sysfs.o ../libmultipath/util.o +sysfs-test_OBJDEPS := ../libmultipath/sysfs.o ../libmpathutil/util.o sysfs-test_LIBDEPS := -ludev -lpthread -ldl %.o: %.c @@ -83,11 +83,11 @@ lib/libchecktur.so: %.out: %-test lib/libchecktur.so @echo == running $< == - @LD_LIBRARY_PATH=.:$(mpathcmddir) ./$< >$@ + @LD_LIBRARY_PATH=.:$(mpathutildir):$(mpathcmddir) ./$< >$@ %.vgr: %-test lib/libchecktur.so @echo == running valgrind for $< == - @LD_LIBRARY_PATH=.:$(mpathcmddir) \ + @LD_LIBRARY_PATH=.:$(mpathutildir):$(mpathcmddir) \ valgrind --leak-check=full --error-exitcode=128 ./$< >$@ 2>&1 OBJS = $(TESTS:%=%.o) $(HELPERS) From patchwork Tue Aug 30 19:27:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12959779 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4EAC4C64991 for ; Tue, 30 Aug 2022 19:28:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661887711; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=mwex413t6kkuig3ZKJBK8Hp2coVu1+LWMoPe3aSJ/HM=; b=J082ut6fx/KvJyI8si+w4DlwdF0utUP5PVM1zcCBZpRw9X6i0Vzspqy2avFlNYkKHDxAMk AveB4bliS/nxyB0WFW5ROMkKyu7XWcKmClTW6de/x5XAKGHYzxH0jhqarCJOTg50sAq7d4 YQtPB+2cUcduO8EXPRB8Tb89hKAkVvw= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-122-dIqdNDNbNi-cpwzQ3dCVfA-1; Tue, 30 Aug 2022 15:28:27 -0400 X-MC-Unique: dIqdNDNbNi-cpwzQ3dCVfA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 183313802AC7; Tue, 30 Aug 2022 19:28:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 026DC2166B26; Tue, 30 Aug 2022 19:28:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id ECBC61946A42; Tue, 30 Aug 2022 19:28:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0EAAF1946A67 for ; Tue, 30 Aug 2022 19:28:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F375FC15BBD; Tue, 30 Aug 2022 19:28:17 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EEBB1C15BBA for ; Tue, 30 Aug 2022 19:28:17 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D2101185A7BA for ; Tue, 30 Aug 2022 19:28:17 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-346-6v2z0qMtMtWqeqk6jZsIzQ-1; Tue, 30 Aug 2022 15:28:16 -0400 X-MC-Unique: 6v2z0qMtMtWqeqk6jZsIzQ-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6DB871FB26; Tue, 30 Aug 2022 19:28:12 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3556313B0C; Tue, 30 Aug 2022 19:28:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YE9AC8xkDmO5GgAAMHmgww (envelope-from ); Tue, 30 Aug 2022 19:28:12 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Tue, 30 Aug 2022 21:27:10 +0200 Message-Id: <20220830192713.19778-10-mwilck@suse.com> In-Reply-To: <20220830192713.19778-1-mwilck@suse.com> References: <20220830192713.19778-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Subject: [dm-devel] [PATCH v4 09/12] multipathc: add new interactive client program X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck Add a new small program, multipathc, that acts as interactive uxsock client for multipathd. multipathc is the only program that has an interactive mode and can thus link to either libreadline or libedit for command line history. All code depending on libreadline is moved from uxclnt.c and cli.c to multipathc.c. This patch breaks multipathd's interactive mode. It will be restored in the next patch. As multipathc doesn't link to libmultipath, it can link to libreadline without license conflict. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski Reviewed-by: Benjamin Marzinski --- .gitignore | 1 + multipathd/Makefile | 24 ++-- multipathd/cli.c | 130 ++------------------ multipathd/cli.h | 7 +- multipathd/multipathc.c | 259 ++++++++++++++++++++++++++++++++++++++++ multipathd/uxclnt.c | 131 +------------------- 6 files changed, 299 insertions(+), 253 deletions(-) create mode 100644 multipathd/multipathc.c diff --git a/.gitignore b/.gitignore index b88608c..821c3e6 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ cscope.out kpartx/kpartx multipath/multipath multipathd/multipathd +multipathd/multipathc mpathpersist/mpathpersist abi.tar.gz abi diff --git a/multipathd/Makefile b/multipathd/Makefile index 7128510..19ab2e9 100644 --- a/multipathd/Makefile +++ b/multipathd/Makefile @@ -27,12 +27,12 @@ LIBDEPS += -L$(multipathdir) -lmultipath -L$(mpathpersistdir) -lmpathpersist \ ifeq ($(READLINE),libedit) -CPPFLAGS += -DUSE_LIBEDIT -LIBDEPS += -ledit +RL_CPPFLAGS = -DUSE_LIBEDIT +RL_LIBDEPS += -ledit endif ifeq ($(READLINE),libreadline) -CPPFLAGS += -DUSE_LIBREADLINE -LIBDEPS += -lreadline +RL_CPPFLAGS += -DUSE_LIBREADLINE +RL_LIBDEPS += -lreadline endif ifdef SYSTEMD @@ -50,6 +50,8 @@ endif OBJS = main.o pidfile.o uxlsnr.o uxclnt.o cli.o cli_handlers.o waiter.o \ dmevents.o init_unwinder.o +CLI_OBJS = multipathc.o cli.o + ifeq ($(FPIN_SUPPORT),1) OBJS += fpin_handlers.o endif @@ -57,18 +59,26 @@ endif EXEC = multipathd +CLI = multipathc -all : $(EXEC) +all : $(EXEC) $(CLI) $(EXEC): $(OBJS) $(multipathdir)/libmultipath.so $(mpathcmddir)/libmpathcmd.so $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $(EXEC) $(LIBDEPS) +multipathc.o: multipathc.c + $(CC) $(CPPFLAGS) $(RL_CPPFLAGS) $(CFLAGS) -Wno-unused-parameter -c -o $@ $< + +$(CLI): $(CLI_OBJS) + $(CC) $(CFLAGS) $(CLI_OBJS) $(LDFLAGS) -o $@ $(CLI_LIBDEPS) $(RL_LIBDEPS) + cli_handlers.o: cli_handlers.c $(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused-parameter -c -o $@ $< install: $(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir) $(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir) + $(INSTALL_PROGRAM) -m 755 $(CLI) $(DESTDIR)$(bindir) ifdef SYSTEMD $(INSTALL_PROGRAM) -d $(DESTDIR)$(unitdir) $(INSTALL_PROGRAM) -m 644 $(EXEC).service $(DESTDIR)$(unitdir) @@ -78,13 +88,13 @@ endif $(INSTALL_PROGRAM) -m 644 $(EXEC).8 $(DESTDIR)$(man8dir) uninstall: - $(RM) $(DESTDIR)$(bindir)/$(EXEC) + $(RM) $(DESTDIR)$(bindir)/$(EXEC) $(DESTDIR)$(bindir)/$(CLI) $(RM) $(DESTDIR)$(man8dir)/$(EXEC).8 $(RM) $(DESTDIR)$(unitdir)/$(EXEC).service $(RM) $(DESTDIR)$(unitdir)/$(EXEC).socket clean: dep_clean - $(RM) core *.o $(EXEC) + $(RM) core *.o $(EXEC) $(CLI) include $(wildcard $(OBJS:.o=.d)) diff --git a/multipathd/cli.c b/multipathd/cli.c index cc56950..d1bfeee 100644 --- a/multipathd/cli.c +++ b/multipathd/cli.c @@ -11,12 +11,6 @@ #include "parser.h" #include "util.h" #include "version.h" -#ifdef USE_LIBEDIT -#include -#endif -#ifdef USE_LIBREADLINE -#include -#endif #include "mpath_cmd.h" #include "cli.h" @@ -26,6 +20,16 @@ static vector keys; static vector handlers; +vector get_keys(void) +{ + return keys; +} + +vector get_handlers(void) +{ + return handlers; +} + static struct key * alloc_key (void) { @@ -225,8 +229,7 @@ load_keys (void) return 0; } -static struct key * -find_key (const char * str) +struct key *find_key (const char * str) { int i; int len, klen; @@ -323,8 +326,7 @@ out: return r; } -static uint64_t -fingerprint(const struct _vector *vec) +uint64_t fingerprint(const struct _vector *vec) { int i; uint64_t fp = 0; @@ -458,111 +460,3 @@ void cli_exit(void) free_keys(keys); keys = NULL; } - -#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) -static int -key_match_fingerprint (struct key * kw, uint64_t fp) -{ - if (!fp) - return 0; - - return ((fp & kw->code) == kw->code); -} - -/* - * This is the readline completion handler - */ -char * -key_generator (const char * str, int state) -{ - static int index, len, has_param; - static uint64_t rlfp; - struct key * kw; - int i; - struct handler *h; - vector v = NULL; - - if (!state) { - index = 0; - has_param = 0; - rlfp = 0; - len = strlen(str); - int r = get_cmdvec(rl_line_buffer, &v); - /* - * If a word completion is in progress, we don't want - * to take an exact keyword match in the fingerprint. - * For ex "show map[tab]" would validate "map" and discard - * "maps" as a valid candidate. - */ - if (v && len) - vector_del_slot(v, VECTOR_SIZE(v) - 1); - /* - * Clean up the mess if we dropped the last slot of a 1-slot - * vector - */ - if (v && !VECTOR_SIZE(v)) { - vector_free(v); - v = NULL; - } - /* - * If last keyword takes a param, don't even try to guess - */ - if (r == EINVAL) { - has_param = 1; - return (strdup("(value)")); - } - /* - * Compute a command fingerprint to find out possible completions. - * Once done, the vector is useless. Free it. - */ - if (v) { - rlfp = fingerprint(v); - free_keys(v); - } - } - /* - * No more completions for parameter placeholder. - * Brave souls might try to add parameter completion by walking paths and - * multipaths vectors. - */ - if (has_param) - return ((char *)NULL); - /* - * Loop through keywords for completion candidates - */ - vector_foreach_slot_after (keys, kw, index) { - if (!strncmp(kw->str, str, len)) { - /* - * Discard keywords already in the command line - */ - if (key_match_fingerprint(kw, rlfp)) { - struct key * curkw = find_key(str); - if (!curkw || (curkw != kw)) - continue; - } - /* - * Discard keywords making syntax errors. - * - * nfp is the candidate fingerprint we try to - * validate against all known command fingerprints. - */ - uint64_t nfp = rlfp | kw->code; - vector_foreach_slot(handlers, h, i) { - if (!rlfp || ((h->fingerprint & nfp) == nfp)) { - /* - * At least one full command is - * possible with this keyword : - * Consider it validated - */ - index++; - return (strdup(kw->str)); - } - } - } - } - /* - * No more candidates - */ - return ((char *)NULL); -} -#endif diff --git a/multipathd/cli.h b/multipathd/cli.h index 2a0c102..cb5bbe2 100644 --- a/multipathd/cli.h +++ b/multipathd/cli.h @@ -151,8 +151,9 @@ void free_keys (vector vec); void free_handlers (void); int cli_init (void); void cli_exit(void); -#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) -char *key_generator (const char * str, int state); -#endif +uint64_t fingerprint(const struct _vector *vec); +vector get_keys(void); +vector get_handlers(void); +struct key *find_key (const char * str); #endif /* _CLI_H_ */ diff --git a/multipathd/multipathc.c b/multipathd/multipathc.c new file mode 100644 index 0000000..a4f9023 --- /dev/null +++ b/multipathd/multipathc.c @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2022 SUSE LLC + * SPDX-License-Identifier: GPL-3.0-or-later + */ +#include +#include +#include +#include +#include +#include + +#include "mpath_cmd.h" +#include "uxclnt.h" +#include "vector.h" +#include "uxsock.h" +#include "util.h" +#include "cli.h" + +#ifdef USE_LIBEDIT +#include +#endif +#ifdef USE_LIBREADLINE +#include +#include +#endif +/* + * Versions of libedit prior to 2016 were using a wrong + * prototype for rl_completion_entry_function in readline.h. + * Internally, libedit casts this to the correct type + * (char *)(*)(const char *, int). + * So we simply cast to the wrong prototype here. + * See http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libedit/readline/readline.h.diff?r1=1.34&r2=1.35 + * Unfortunately, this change isn't reflected in the libedit version. + */ +#ifdef BROKEN_RL_COMPLETION_FUNC +#define RL_COMP_ENTRY_CAST(x) ((int (*)(const char *, int)) (x)) +#else +#define RL_COMP_ENTRY_CAST(x) (x) +#endif + +#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) +static int +key_match_fingerprint (struct key * kw, uint64_t fp) +{ + if (!fp) + return 0; + + return ((fp & kw->code) == kw->code); +} + +/* + * This is the readline completion handler + */ +char * +key_generator (const char * str, int state) +{ + static int index, len, has_param; + static uint64_t rlfp; + struct key * kw; + int i; + struct handler *h; + vector v = NULL; + const vector keys = get_keys(); + const vector handlers = get_handlers(); + + if (!state) { + index = 0; + has_param = 0; + rlfp = 0; + len = strlen(str); + int r = get_cmdvec(rl_line_buffer, &v); + /* + * If a word completion is in progress, we don't want + * to take an exact keyword match in the fingerprint. + * For ex "show map[tab]" would validate "map" and discard + * "maps" as a valid candidate. + */ + if (v && len) + vector_del_slot(v, VECTOR_SIZE(v) - 1); + /* + * Clean up the mess if we dropped the last slot of a 1-slot + * vector + */ + if (v && !VECTOR_SIZE(v)) { + vector_free(v); + v = NULL; + } + /* + * If last keyword takes a param, don't even try to guess + */ + if (r == EINVAL) { + has_param = 1; + return (strdup("(value)")); + } + /* + * Compute a command fingerprint to find out possible completions. + * Once done, the vector is useless. Free it. + */ + if (v) { + rlfp = fingerprint(v); + free_keys(v); + } + } + /* + * No more completions for parameter placeholder. + * Brave souls might try to add parameter completion by walking paths and + * multipaths vectors. + */ + if (has_param) + return ((char *)NULL); + /* + * Loop through keywords for completion candidates + */ + vector_foreach_slot_after (keys, kw, index) { + if (!strncmp(kw->str, str, len)) { + /* + * Discard keywords already in the command line + */ + if (key_match_fingerprint(kw, rlfp)) { + struct key * curkw = find_key(str); + if (!curkw || (curkw != kw)) + continue; + } + /* + * Discard keywords making syntax errors. + * + * nfp is the candidate fingerprint we try to + * validate against all known command fingerprints. + */ + uint64_t nfp = rlfp | kw->code; + vector_foreach_slot(handlers, h, i) { + if (!rlfp || ((h->fingerprint & nfp) == nfp)) { + /* + * At least one full command is + * possible with this keyword : + * Consider it validated + */ + index++; + return (strdup(kw->str)); + } + } + } + } + /* + * No more candidates + */ + return ((char *)NULL); +} +#endif + +static void print_reply(char *s) +{ + if (!s) + return; + + if (isatty(1)) { + printf("%s", s); + return; + } + /* strip ANSI color markers */ + while (*s != '\0') { + if ((*s == 0x1b) && (*(s+1) == '[')) + while ((*s++ != 'm') && (*s != '\0')) {}; + putchar(*s++); + } +} + +static int need_quit(char *str, size_t len) +{ + char *ptr, *start; + size_t trimed_len = len; + + for (ptr = str; trimed_len && isspace(*ptr); + trimed_len--, ptr++) + ; + + start = ptr; + + for (ptr = str + len - 1; trimed_len && isspace(*ptr); + trimed_len--, ptr--) + ; + + if ((trimed_len == 4 && !strncmp(start, "exit", 4)) || + (trimed_len == 4 && !strncmp(start, "quit", 4))) + return 1; + + return 0; +} + +/* + * process the client + */ +static void process(int fd, unsigned int timeout) +{ + +#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) + rl_readline_name = "multipathd"; + rl_completion_entry_function = RL_COMP_ENTRY_CAST(key_generator); +#endif + + cli_init(); + for(;;) + { + char *line __attribute__((cleanup(cleanup_charp))) = NULL; + char *reply __attribute__((cleanup(cleanup_charp))) = NULL; + ssize_t llen; + int ret; + +#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) + line = readline("multipathd> "); + if (!line) + break; + llen = strlen(line); + if (!llen) + continue; +#else + size_t lsize = 0; + + fputs("multipathd> ", stdout); + errno = 0; + llen = getline(&line, &lsize, stdin); + if (llen == -1) { + if (errno != 0) + fprintf(stderr, "Error in getline: %m"); + break; + } + if (!llen || !strcmp(line, "\n")) + continue; +#endif + + if (need_quit(line, llen)) + break; + + if (send_packet(fd, line) != 0) + break; + ret = recv_packet(fd, &reply, timeout); + if (ret != 0) + break; + + print_reply(reply); + +#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) + if (line && *line) + add_history(line); +#endif + } +} + +int main (void) +{ + int fd = mpath_connect(); + + if (fd == -1) + return 1; + + process(fd, DEFAULT_REPLY_TIMEOUT + 100); + mpath_disconnect(fd); + return 0; +} diff --git a/multipathd/uxclnt.c b/multipathd/uxclnt.c index deff565..c3ae5db 100644 --- a/multipathd/uxclnt.c +++ b/multipathd/uxclnt.c @@ -5,133 +5,14 @@ * Copyright (c) 2005 Benjamin Marzinski, Redhat */ #include +#include #include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include - -#ifdef USE_LIBEDIT -#include -#endif -#ifdef USE_LIBREADLINE -#include -#include -#endif #include "mpath_cmd.h" #include "uxsock.h" -#include "defaults.h" - -#include "vector.h" -#include "util.h" -#include "cli.h" #include "uxclnt.h" -static void print_reply(char *s) -{ - if (!s) - return; - - if (isatty(1)) { - printf("%s", s); - return; - } - /* strip ANSI color markers */ - while (*s != '\0') { - if ((*s == 0x1b) && (*(s+1) == '[')) - while ((*s++ != 'm') && (*s != '\0')) {}; - putchar(*s++); - } -} - -static int need_quit(char *str, size_t len) -{ - char *ptr, *start; - size_t trimed_len = len; - - for (ptr = str; trimed_len && isspace(*ptr); - trimed_len--, ptr++) - ; - - start = ptr; - - for (ptr = str + len - 1; trimed_len && isspace(*ptr); - trimed_len--, ptr--) - ; - - if ((trimed_len == 4 && !strncmp(start, "exit", 4)) || - (trimed_len == 4 && !strncmp(start, "quit", 4))) - return 1; - - return 0; -} - -/* - * process the client - */ -static void process(int fd, unsigned int timeout) -{ - -#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) - rl_readline_name = "multipathd"; - rl_completion_entry_function = key_generator; -#endif - - cli_init(); - for(;;) - { - char *line __attribute__((cleanup(cleanup_charp))) = NULL; - char *reply __attribute__((cleanup(cleanup_charp))) = NULL; - ssize_t llen; - int ret; - -#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) - line = readline("multipathd> "); - if (!line) - break; - llen = strlen(line); - if (!llen) - continue; -#else - size_t lsize = 0; - - fputs("multipathd> ", stdout); - errno = 0; - llen = getline(&line, &lsize, stdin); - if (llen == -1) { - if (errno != 0) - fprintf(stderr, "Error in getline: %m"); - break; - } - if (!llen || !strcmp(line, "\n")) - continue; -#endif - - if (need_quit(line, llen)) - break; - - if (send_packet(fd, line) != 0) - break; - ret = recv_packet(fd, &reply, timeout); - if (ret != 0) - break; - - print_reply(reply); - -#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) - if (line && *line) - add_history(line); -#endif - } -} - static int process_req(int fd, char * inbuf, unsigned int timeout) { char *reply; @@ -163,14 +44,14 @@ int uxclnt(char * inbuf, unsigned int timeout) { int fd, ret = 0; + if (!inbuf) + return 1; fd = mpath_connect(); if (fd == -1) - exit(1); + return 1; + + ret = process_req(fd, inbuf, timeout); - if (inbuf) - ret = process_req(fd, inbuf, timeout); - else - process(fd, timeout); mpath_disconnect(fd); return ret; } From patchwork Tue Aug 30 19:27:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12959778 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3F223ECAAD5 for ; Tue, 30 Aug 2022 19:28:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661887711; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=LO5EK8vkN9+qXwAjB/nMkTQM/ueyWKyg2Q0BRnxJLhI=; b=Jb0suru8Tj33Xmu1kfucPFQFuVO/F4CFOtJfgRgnz7bfYsLRJZ3chQEbVylb7Xd4zLgxdq F6tBwA7XV3xqO6wKc/phtrXbpd+tW4N4KOY6tm2cufWx/okoXonmTbE/+SeorUJLTdTau1 t+1KGxgjEVZ8CcmavF6kVmfIouAEcxI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-90-nLYbWINBOjCIJEp-kg7WJw-1; Tue, 30 Aug 2022 15:28:28 -0400 X-MC-Unique: nLYbWINBOjCIJEp-kg7WJw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C7FA819705AA; Tue, 30 Aug 2022 19:28:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7CD44010E3C; Tue, 30 Aug 2022 19:28:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A5F921946A42; Tue, 30 Aug 2022 19:28:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 75B211946A69 for ; Tue, 30 Aug 2022 19:28:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 594722026D64; Tue, 30 Aug 2022 19:28:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 557A62026D4C for ; Tue, 30 Aug 2022 19:28:19 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 37B933C4CA86 for ; Tue, 30 Aug 2022 19:28:19 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-621-YkfO0MNvOEaTz899fSTa6A-1; Tue, 30 Aug 2022 15:28:15 -0400 X-MC-Unique: YkfO0MNvOEaTz899fSTa6A-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id AB7AD21E8C; Tue, 30 Aug 2022 19:28:12 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7852413B0C; Tue, 30 Aug 2022 19:28:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uEmhG8xkDmO5GgAAMHmgww (envelope-from ); Tue, 30 Aug 2022 19:28:12 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Tue, 30 Aug 2022 21:27:11 +0200 Message-Id: <20220830192713.19778-11-mwilck@suse.com> In-Reply-To: <20220830192713.19778-1-mwilck@suse.com> References: <20220830192713.19778-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Subject: [dm-devel] [PATCH v4 10/12] multipathd: exec multipathc in interactive mode X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck A previous patch disabled interactive mode in multipathd, because uxclnt() would return immediately without an input command. With this patch, we reinstate interactive mode for "multipath -k", by just exec()ing the multipathc client. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- multipathd/Makefile | 3 ++- multipathd/main.c | 15 +++++++++++++-- multipathd/multipathc.c | 25 +++++++++++++++++++++---- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/multipathd/Makefile b/multipathd/Makefile index 19ab2e9..8a56304 100644 --- a/multipathd/Makefile +++ b/multipathd/Makefile @@ -17,7 +17,8 @@ endif CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) -I$(mpathpersistdir) -I$(mpathcmddir) -I$(thirdpartydir) \ $(shell $(PKGCONFIG) --modversion liburcu 2>/dev/null | \ - awk -F. '{ printf("-DURCU_VERSION=0x%06x", 256 * ( 256 * $$1 + $$2) + $$3); }') + awk -F. '{ printf("-DURCU_VERSION=0x%06x", 256 * ( 256 * $$1 + $$2) + $$3); }') \ + -DBINDIR='"$(bindir)"' CFLAGS += $(BIN_CFLAGS) LDFLAGS += $(BIN_LDFLAGS) diff --git a/multipathd/main.c b/multipathd/main.c index 5a40894..66177cd 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -3616,7 +3616,7 @@ main (int argc, char *argv[]) extern char *optarg; extern int optind; int arg; - int err; + int err = 0; int foreground = 0; struct config *conf; char *opt_k_arg = NULL; @@ -3710,7 +3710,18 @@ main (int argc, char *argv[]) } c += snprintf(c, s + CMDSIZE - c, "\n"); } - err = uxclnt(s, uxsock_timeout + 100); + if (!s) { + char tmo_buf[16]; + + snprintf(tmo_buf, sizeof(tmo_buf), "%d", + uxsock_timeout + 100); + if (execl(BINDIR "/multipathc", "multipathc", + tmo_buf, NULL) == -1) { + condlog(0, "ERROR: failed to execute multipathc: %m"); + err = 1; + } + } else + err = uxclnt(s, uxsock_timeout + 100); free_config(conf); return err; } diff --git a/multipathd/multipathc.c b/multipathd/multipathc.c index a4f9023..9d49655 100644 --- a/multipathd/multipathc.c +++ b/multipathd/multipathc.c @@ -246,14 +246,31 @@ static void process(int fd, unsigned int timeout) } } -int main (void) +int main (int argc, const char * const argv[]) { - int fd = mpath_connect(); + int fd; + int tmo = DEFAULT_REPLY_TIMEOUT + 100; + char *ep; - if (fd == -1) + if (argc > 2) { + fprintf(stderr, "Usage: %s [timeout]\n", argv[0]); return 1; + } + if (argc == 2) { + tmo = strtol(argv[1], &ep, 10); + if (*argv[1] == '\0' || *ep != '\0' || tmo < 0) { + fprintf(stderr, "ERROR: invalid timeout value\n"); + return 1; + } + } - process(fd, DEFAULT_REPLY_TIMEOUT + 100); + fd = mpath_connect(); + if (fd == -1) { + fprintf(stderr, "ERROR: failed to connect to multipathd\n"); + return 1; + } + + process(fd, tmo); mpath_disconnect(fd); return 0; } From patchwork Tue Aug 30 19:27:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12959771 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C23D5C0502A for ; Tue, 30 Aug 2022 19:28:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661887707; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=zj32ND1gPbmCMZpPsb+hULJh2Pvb62LmrTiCN++fp28=; b=SEseYWiyQ8U67r8zYXm9bd3dy6aVxUkjiSjEghWgkts/7FDBZLt6TMbzh2w53sS+YCNL5J IZ5Iy9wqcxl5ZQgHOm5iyEJoPzIIkfEpz4xN6D4T1e8P2qgaLKUI3G6Nyr9VjQ8St5my1+ ktORPNnWSU0IW7ETXbKgz1WYcl6RzUI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-16-ev8pX1CzM5OJ8ClpRPI20w-1; Tue, 30 Aug 2022 15:28:24 -0400 X-MC-Unique: ev8pX1CzM5OJ8ClpRPI20w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 83DD41C06EFC; Tue, 30 Aug 2022 19:28:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F5A72166B26; Tue, 30 Aug 2022 19:28:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 284DB1946A60; Tue, 30 Aug 2022 19:28:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2FE701946A42 for ; Tue, 30 Aug 2022 19:28:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 029C12166B2A; Tue, 30 Aug 2022 19:28:17 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F31002166B26 for ; Tue, 30 Aug 2022 19:28:16 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D9BA18037AE for ; Tue, 30 Aug 2022 19:28:16 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-253-wBZQw9OTNxCqK8eU0jTIPg-1; Tue, 30 Aug 2022 15:28:15 -0400 X-MC-Unique: wBZQw9OTNxCqK8eU0jTIPg-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E90FF1FB27; Tue, 30 Aug 2022 19:28:12 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B722213B0C; Tue, 30 Aug 2022 19:28:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IMX5KsxkDmO5GgAAMHmgww (envelope-from ); Tue, 30 Aug 2022 19:28:12 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Tue, 30 Aug 2022 21:27:12 +0200 Message-Id: <20220830192713.19778-12-mwilck@suse.com> In-Reply-To: <20220830192713.19778-1-mwilck@suse.com> References: <20220830192713.19778-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Subject: [dm-devel] [PATCH v4 11/12] multipathd: fix incompatible pointer type error with libedit X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck Versions of libedit prior to 2016 were using a wrong prototype for rl_completion_entry_function in readline.h. Internally, libedit casts this to the correct type (char *)(*)(const char *, int) (aka CPFunction in libedit). So we simply cast to the wrong prototype here. See http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libedit/readline/readline.h.diff?r1=1.34&r2=1.35 Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- multipathd/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/multipathd/Makefile b/multipathd/Makefile index 8a56304..28ebdc0 100644 --- a/multipathd/Makefile +++ b/multipathd/Makefile @@ -34,6 +34,10 @@ endif ifeq ($(READLINE),libreadline) RL_CPPFLAGS += -DUSE_LIBREADLINE RL_LIBDEPS += -lreadline +# See comment in uxclnt.c +ifeq ($(shell sed -En 's/.*\ X-Patchwork-Id: 12959769 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9FE5CC0502C for ; Tue, 30 Aug 2022 19:28:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661887706; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MXyrtjcQg/ahC7b3JqoATjwvUkqsjwSdlojdia8ERsI=; b=YDuzOVdnXoZaAwVcSti1Vv7efutEeb+/PpZa8rRGe1RKSeCx72jFPTmohHb+J7fDOZ0e9Y JELKJCYZx8o1o6I37NI3Bxqwn75pf76y/ivEG/hKtnhsBQvhzxK/bcHjxD2Dbzobt1JGiu yDNi22JB6BZm8EJIuUR/gzaYjuqyC8Q= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-116-hEk3b0HANmSL4A8Z2xiPUw-1; Tue, 30 Aug 2022 15:28:25 -0400 X-MC-Unique: hEk3b0HANmSL4A8Z2xiPUw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A874983DE43; Tue, 30 Aug 2022 19:28:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95D3DC15BB3; Tue, 30 Aug 2022 19:28:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5F3611946A7E; Tue, 30 Aug 2022 19:28:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 700FF1946A75 for ; Tue, 30 Aug 2022 19:28:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 64286492C3B; Tue, 30 Aug 2022 19:28:18 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 608ED492CA2 for ; Tue, 30 Aug 2022 19:28:18 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 474EC85A599 for ; Tue, 30 Aug 2022 19:28:18 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-267-PqqQHQlPOZCrj-zzCYnl5A-1; Tue, 30 Aug 2022 15:28:14 -0400 X-MC-Unique: PqqQHQlPOZCrj-zzCYnl5A-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 33A6621E8E; Tue, 30 Aug 2022 19:28:13 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0199913B0C; Tue, 30 Aug 2022 19:28:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OBojOsxkDmO5GgAAMHmgww (envelope-from ); Tue, 30 Aug 2022 19:28:12 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Tue, 30 Aug 2022 21:27:13 +0200 Message-Id: <20220830192713.19778-13-mwilck@suse.com> In-Reply-To: <20220830192713.19778-1-mwilck@suse.com> References: <20220830192713.19778-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Subject: [dm-devel] [PATCH v4 12/12] multipathd: fix use-after-free in handle_path_wwid_change() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck Found by coverity (defect #380536). Fixes: b4eb57e ("libmultipath, multipathd: log failure setting sysfs attributes") Reviewed-by: Benjamin Marzinski --- multipathd/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 66177cd..2d0a7bc 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -951,10 +951,12 @@ handle_path_wwid_change(struct path *pp, struct vectors *vecs) struct udev_device *udd; static const char add[] = "add"; ssize_t ret; + char dev[FILE_NAME_SIZE]; if (!pp || !pp->udev) return; + strlcpy(dev, pp->dev, sizeof(dev)); udd = udev_device_ref(pp->udev); if (!(ev_remove_path(pp, vecs, 1) & REMOVE_PATH_SUCCESS) && pp->mpp) { pp->dmstate = PSTATE_FAILED; @@ -965,8 +967,7 @@ handle_path_wwid_change(struct path *pp, struct vectors *vecs) udev_device_unref(udd); if (ret != sizeof(add) - 1) log_sysfs_attr_set_value(1, ret, - "%s: failed to trigger add event", - pp->dev); + "%s: failed to trigger add event", dev); } bool