From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B152BA0553; Thu, 20 Oct 2022 19:28:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9BC09410FC; Thu, 20 Oct 2022 19:28:51 +0200 (CEST) Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by mails.dpdk.org (Postfix) with ESMTP id CE8FE40FAE for ; Thu, 20 Oct 2022 19:28:50 +0200 (CEST) Received: by mail-pg1-f174.google.com with SMTP id u71so166235pgd.2 for ; Thu, 20 Oct 2022 10:28:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jwglGQDPpvbKzXxWSXvpdoBvGqq/fqCpKkFesGCaEds=; b=qbj0s6NdM7lPHVuNlDQwDaWI6UnaLFJ6HreplHBr+PpojH0+RxsIvmQuteW8J9Rk3h jrd4MdRULVan9A0WatiGRH7OtyNT0tr0LaD72mjGVgkfhTruCZwastSoHsWmnFz7qKHs EfX2PVoOSMwDv1qoMe8jmdJXVuVh/sqhk2JrNhMqjJp0iOBE01rVOjTcJ5LYR46NVwjx 124Wbg/9HCNhaxZbMRgGr4unAXErvIb5/GAKfr6UqAyXEAicWEC2mEkw9nJufrH0277p X5MuP903gjq75xbeHf2sX1A+vgJw8pIwRYmM7oHxINT6hC+tcGsv1+rIZ22HwJpTk7QQ Av1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jwglGQDPpvbKzXxWSXvpdoBvGqq/fqCpKkFesGCaEds=; b=xXuPjWzvu0we0tf5NOLQXaoslWaeUd4zYSxq8aVzsWCQQu9zKb2pReKntRToI2wKxN yF2AYsqmOU3ryEJtwJ5rkTiiMLhhhZZt7LFGULUOuB9vKvzKeS2WstTf0JVy2/4iL9rN AD7TkGrJqWRm0KPQFDd1fwUgqFHUnme6ysbZY25bz33rtFIotXwkL9z4+PO4Xeap3lVW wz/29kke9A4LkD/bvRQ+iTmdt6lm8LOpAh6i/+Zs4DQXWO8RWcQINxjqw/jGoM5fE3Hc O/QXNhewB09sf7MjMoNEfD9Zb3tg+050OI+Be+263nEgfVm9ETTpBmnJc7lwqaHZH7oH 9Xpw== X-Gm-Message-State: ACrzQf0uCGzaJYtKOxqDeqRnlgpUHQMlwg11gX5DjvTNooj8yO2smh74 esMxeAO//gZRvaluWpA7kKHCdA574sJSgg== X-Google-Smtp-Source: AMsMyM57RHtMkX8dUY6DcJ+NMjgx11LYCO+IPLFKY7mGx4nTI2Gy4GwwLyjg9PmAkeTuG0nhNh7YNg== X-Received: by 2002:a05:6a00:1bc3:b0:562:ab5f:af2 with SMTP id o3-20020a056a001bc300b00562ab5f0af2mr15287945pfw.58.1666286929592; Thu, 20 Oct 2022 10:28:49 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id l10-20020a170902f68a00b0017834a6966csm13385807plg.176.2022.10.20.10.28.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 10:28:48 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v3] dumpcap: fix pathname for output file Date: Thu, 20 Oct 2022 10:28:46 -0700 Message-Id: <20221020172846.109011-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221019183255.74217-1-stephen@networkplumber.org> References: <20221019183255.74217-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org When dumpcap is run with a longer path name such as when testing, the file prefix would be computed incorrectly. Also, print out the resulting filename which is what similar wireshark program does. Fixes: cbb44143be74 ("app/dumpcap: add new packet capture application") Signed-off-by: Stephen Hemminger --- v3 - get rid of printf app/dumpcap/main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c index e0a3477d912f..32d97df3aafa 100644 --- a/app/dumpcap/main.c +++ b/app/dumpcap/main.c @@ -637,6 +637,7 @@ static dumpcap_out_t create_output(void) else { mode_t mode = group_read ? 0640 : 0600; + fprintf(stderr, "File: %s\n", output_name); fd = open(output_name, O_WRONLY | O_CREAT, mode); if (fd < 0) rte_exit(EXIT_FAILURE, "Can not open \"%s\": %s\n", @@ -784,8 +785,13 @@ int main(int argc, char **argv) struct rte_ring *r; struct rte_mempool *mp; dumpcap_out_t out; + char *p; - progname = argv[0]; + p = strrchr(argv[0], '/'); + if (p == NULL) + progname = argv[0]; + else + progname = p + 1; parse_opts(argc, argv); dpdk_init(); -- 2.35.1