DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH v2] dumpcap: fix pathname for output file
Date: Wed, 19 Oct 2022 11:52:44 -0700	[thread overview]
Message-ID: <20221019185244.76519-1-stephen@networkplumber.org> (raw)
In-Reply-To: <20221019183255.74217-1-stephen@networkplumber.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 <stephen@networkplumber.org>
---
v2 - get rid of debug printf

 app/dumpcap/main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
index e0a3477d912f..9f716b1fbe43 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,14 @@ 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;
+	printf("progname = '%s'\n", progname);
 
 	parse_opts(argc, argv);
 	dpdk_init();
-- 
2.35.1


  reply	other threads:[~2022-10-19 18:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-19 18:32 [PATCH] " Stephen Hemminger
2022-10-19 18:52 ` Stephen Hemminger [this message]
2022-10-20 17:28 ` [PATCH v3] " Stephen Hemminger
2022-10-21 13:07   ` David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221019185244.76519-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).