From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 793D8C544 for ; Thu, 23 Jun 2016 16:38:10 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP; 23 Jun 2016 07:36:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,517,1459839600"; d="scan'208";a="993691004" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 23 Jun 2016 07:36:41 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u5NEafGh016326; Thu, 23 Jun 2016 15:36:41 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id u5NEafe5026766; Thu, 23 Jun 2016 15:36:41 +0100 Received: (from reshmapa@localhost) by sivswdev02.ir.intel.com with id u5NEafg5026762; Thu, 23 Jun 2016 15:36:41 +0100 From: Reshma Pattan To: dev@dpdk.org Cc: Reshma Pattan Date: Thu, 23 Jun 2016 15:36:36 +0100 Message-Id: <1466692599-26716-2-git-send-email-reshma.pattan@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1466692599-26716-1-git-send-email-reshma.pattan@intel.com> References: <1466604475-11864-1-git-send-email-reshma.pattan@intel.com> <1466692599-26716-1-git-send-email-reshma.pattan@intel.com> Subject: [dpdk-dev] [PATCH v3 1/4] pdump: fix default socket path X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jun 2016 14:38:10 -0000 SOCKET_PATH_HOME is to specify environment variable "HOME", so it should not contain "/pdump_sockets" in the macro. So remove "/pdump_sockets" from SOCKET_PATH_HOME and create new macro for "/pdump_sockets". Similary removed "/pdump_sockets" from SOCKET_PATH_VAR_RUN. Changes are done in pdump_get_socket_path() to accommodate new socket path changes. Fixes: 278f945402c5 ("pdump: add new library for packet capture") Signed-off-by: Reshma Pattan --- lib/librte_pdump/rte_pdump.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c index c921f51..5c335ba 100644 --- a/lib/librte_pdump/rte_pdump.c +++ b/lib/librte_pdump/rte_pdump.c @@ -50,8 +50,9 @@ #include "rte_pdump.h" -#define SOCKET_PATH_VAR_RUN "/var/run/pdump_sockets" -#define SOCKET_PATH_HOME "HOME/pdump_sockets" +#define SOCKET_PATH_VAR_RUN "/var/run" +#define SOCKET_PATH_HOME "HOME" +#define SOCKET_DIR "/pdump_sockets" #define SERVER_SOCKET "%s/pdump_server_socket" #define CLIENT_SOCKET "%s/pdump_client_socket_%d_%u" #define DEVICE_ID_SIZE 64 @@ -444,17 +445,20 @@ set_pdump_rxtx_cbs(struct pdump_request *p) static void pdump_get_socket_path(char *buffer, int bufsz, enum rte_pdump_socktype type) { - const char *dir = NULL; + char dir[PATH_MAX] = {0}; + char *dir_home = NULL; if (type == RTE_PDUMP_SOCKET_SERVER && server_socket_dir[0] != 0) - dir = server_socket_dir; + snprintf(dir, sizeof(dir), "%s", server_socket_dir); else if (type == RTE_PDUMP_SOCKET_CLIENT && client_socket_dir[0] != 0) - dir = client_socket_dir; + snprintf(dir, sizeof(dir), "%s", client_socket_dir); else { - if (getuid() != 0) - dir = getenv(SOCKET_PATH_HOME); - else - dir = SOCKET_PATH_VAR_RUN; + if (getuid() != 0) { + dir_home = getenv(SOCKET_PATH_HOME); + strcat(dir, dir_home); + } else + strcat(dir, SOCKET_PATH_VAR_RUN); + strcat(dir, SOCKET_DIR); } mkdir(dir, 700); -- 2.5.0