From patchwork Thu Jan 26 18:23:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 122587 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3F16B42495; Thu, 26 Jan 2023 19:24:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 980B242D68; Thu, 26 Jan 2023 19:23:52 +0100 (CET) Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) by mails.dpdk.org (Postfix) with ESMTP id 8B5B9400D7 for ; Thu, 26 Jan 2023 19:23:48 +0100 (CET) Received: by mail-pg1-f182.google.com with SMTP id 36so1620175pgp.10 for ; Thu, 26 Jan 2023 10:23:48 -0800 (PST) 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=7TbAFoTJtQwAUYoiyidfziT7q+e4TWVvfpffJMQjyuM=; b=pZbhvUc5OCxGrL7adCXjXyzn7P3iDdTH5I5lqlYnCl2mIRZ5rAcXiyA7qcuUgXO9J6 /FdW85yhswbOi1hVgP3OgE7jiCdJsb7/EFG30R98e3prsd2CrI/xyxI2lfA4ReoyFtD8 zG8UVN+YWO4Y4H/AgZHnuaIrFYNpjlNv3fz2va0xGsw8QsG3qlzKPaSr0jWOLbY8u5NR iRVRlq2h7UAdzv0CR4hf1tQqPcLNDaaAe+WEZP+8mdoZn9CSpPlr9OM0u1JJdajBr4X6 +irIc2eZVO9rvZMhs9VYQ5KLy6pU5bX+ReOptgIK+zYBEoHCeyGj+gutM9Ij+nNpJCYw nmCg== 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=7TbAFoTJtQwAUYoiyidfziT7q+e4TWVvfpffJMQjyuM=; b=yT2hdRYrEXxWWTUTok/v9tyqq0DXoAKRXXOwilAMhJ7jkB6h3qTNXEQq3DxkMRZZ9g QxVSuvsLwKU7xhsuLxe2tUaIVJmPUeMGwhTIvYWm5bin9TyIM8kW55CsQTGnsfTwD71/ ny24xj0BLLJeney6KF8Km1qiuK5GKkO+YrJ8PZTw7vCG27J9GsQswydsIQ7VkAloWWE7 /O4JU1T2XZEPWBcFj4oAC/PUf7L5F75wEyw3wxk3ZEUSU3abuXFoa9+2guchbydTrDVh r5H12QQOGuyT1VRNwgKtNUNqzy5Xr+X/PuV+Kr0KmghOjH41Y2qJydRdRmtNFhPmLf9Z AU+g== X-Gm-Message-State: AO0yUKVSLg5zEAzzXU04gzx5MDNOTs+eLPHLkQo/L6Vg9Hl0D6HuZ9t0 dUAk8YoJtHE2zpJoDj15i2qQpbkuJURYE+9Y3gw= X-Google-Smtp-Source: AK7set8A6MAUms1FOSfsgbkzuP5MWW01JsuUdHZ5KxGJq4Wh3U6fVftZg8geESWDLW/s/0Iok89W7A== X-Received: by 2002:a62:1692:0:b0:592:40cd:ce83 with SMTP id 140-20020a621692000000b0059240cdce83mr2146679pfw.4.1674757427449; Thu, 26 Jan 2023 10:23:47 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id r30-20020aa79ede000000b00582388bd80csm1139852pfq.83.2023.01.26.10.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 10:23:47 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH 2/3] dumpcap: support temp-dir option Date: Thu, 26 Jan 2023 10:23:43 -0800 Message-Id: <20230126182344.90635-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230126182344.90635-1-stephen@networkplumber.org> References: <20230126182344.90635-1-stephen@networkplumber.org> MIME-Version: 1.0 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 Option for putting output files in different directory. Same syntax as wireshark. Signed-off-by: Stephen Hemminger --- 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 \n" " add a capture comment to the output file\n" + " --temp-dir write temporary files to this directory\n" + " (default: /tmp)\n" "\n" "Miscellaneous:\n" " --file-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;