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 2/3] dumpcap: support temp-dir option
Date: Thu, 26 Jan 2023 10:23:43 -0800	[thread overview]
Message-ID: <20230126182344.90635-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20230126182344.90635-1-stephen@networkplumber.org>

Option for putting output files in different directory.
Same syntax as wireshark.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 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 297b6378aaf2..02bb8b2b2b4f 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -58,6 +58,7 @@ static bool quiet;
 static bool promiscuous_mode = true;
 static bool use_pcapng = true;
 static char *output_name;
+static const char *tmp_dir = "/tmp";
 static const char *filter_str;
 static unsigned int ring_size = 2048;
 static const char *capture_comment;
@@ -126,6 +127,8 @@ static void usage(void)
 	       "  -P                       use libpcap format instead of pcapng\n"
 	       "  --capture-comment <comment>\n"
 	       "                           add a capture comment to the output file\n"
+	       "  --temp-dir <directory>   write temporary files to this directory\n"
+	       "                           (default: /tmp)\n"
 	       "\n"
 	       "Miscellaneous:\n"
 	       "  --file-prefix=<prefix>   prefix to use for multi-process\n"
@@ -327,6 +330,7 @@ static void parse_opts(int argc, char **argv)
 		{ "output-file",     required_argument, NULL, 'w' },
 		{ "ring-buffer",     required_argument, NULL, 'b' },
 		{ "snapshot-length", required_argument, NULL, 's' },
+		{ "temp-dir",        required_argument, NULL, 0 },
 		{ "version",         no_argument,       NULL, 'v' },
 		{ NULL },
 	};
@@ -346,6 +350,9 @@ static void parse_opts(int argc, char **argv)
 			} else if (!strcmp(long_options[option_index].name,
 					   "file-prefix")) {
 				file_prefix = optarg;
+			} else if (!strcmp(long_options[option_index].name,
+					   "temp-dir")) {
+				tmp_dir = optarg;
 			} else {
 				usage();
 				exit(1);
@@ -642,7 +649,7 @@ static dumpcap_out_t create_output(void)
 		strftime(ts, sizeof(ts), "%Y%m%d%H%M%S", tm);
 
 		snprintf(tmp_path, sizeof(tmp_path),
-			 "/tmp/%s_%u_%s_%s.%s",
+			 "%s/%s_%u_%s_%s.%s", tmp_dir,
 			 progname, intf->port, intf->name, ts,
 			 use_pcapng ? "pcapng" : "pcap");
 		output_name = tmp_path;
-- 
2.39.0


  parent reply	other threads:[~2023-01-26 18:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26 18:23 [PATCH 0/3] dumpcap: small enhancements Stephen Hemminger
2023-01-26 18:23 ` [PATCH 1/3] dumpcap: add --interface to help Stephen Hemminger
2023-01-26 18:23 ` Stephen Hemminger [this message]
2023-01-26 18:23 ` [PATCH 3/3] dumpcap: add support statistics mode Stephen Hemminger
2023-02-06  9:46 ` [PATCH 0/3] dumpcap: small enhancements Thomas Monjalon

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=20230126182344.90635-3-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).