From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH v3] dumpcap: fix pathname for output file
Date: Thu, 20 Oct 2022 10:28:46 -0700 [thread overview]
Message-ID: <20221020172846.109011-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>
---
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
next prev parent reply other threads:[~2022-10-20 17:28 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 ` [PATCH v2] " Stephen Hemminger
2022-10-20 17:28 ` Stephen Hemminger [this message]
2022-10-21 13:07 ` [PATCH v3] " 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=20221020172846.109011-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).