From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 39416A04DD; Wed, 21 Oct 2020 22:31:56 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A4B07A54C; Wed, 21 Oct 2020 22:31:49 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 95DBAA54C for ; Wed, 21 Oct 2020 22:31:47 +0200 (CEST) IronPort-SDR: Y48YTWAjAXcyDg7X9t49idPS/M++anC3KXpK+adpFdc7pT2B/syLC3kyHLdAeObcu35p3Yrczi cyX3Qu6dWHxw== X-IronPort-AV: E=McAfee;i="6000,8403,9781"; a="167522438" X-IronPort-AV: E=Sophos;i="5.77,402,1596524400"; d="scan'208";a="167522438" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2020 13:31:45 -0700 IronPort-SDR: WyNV7o4lkF4vCcPp/0MikffGI36RI+INGMUQKY6ZU4FX1BBV9XGVBTHcqTuioa7+7iDB0fX02l Wr/SDov9kf3w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,402,1596524400"; d="scan'208";a="522874955" Received: from win-dpdk-pallavi.jf.intel.com (HELO localhost.localdomain) ([10.166.188.111]) by fmsmga006.fm.intel.com with ESMTP; 21 Oct 2020 13:31:44 -0700 From: Pallavi Kadam To: dev@dpdk.org, thomas@monjalon.net Cc: ranjit.menon@intel.com, dmitry.kozliuk@gmail.com, Narcisa.Vasile@microsoft.com, talshn@nvidia.com, pallavi.kadam@intel.com Date: Wed, 21 Oct 2020 13:26:16 -0700 Message-Id: <20201021202616.2732-1-pallavi.kadam@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 Subject: [dpdk-dev] [PATCH] eal: create a runtime directory on windows X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Added eal_create_runtime_dir() function in order to run any application as a user that does not have administrator access. Currently, since there is no runtime directory set, the code tries to create a file in C:\ which is only writable with administrator privileges. As a result, if the user is not admin, the application will fail. Signed-off-by: Ranjit Menon Signed-off-by: Pallavi Kadam --- lib/librte_eal/windows/eal.c | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c index 6334aca03..b0f356405 100644 --- a/lib/librte_eal/windows/eal.c +++ b/lib/librte_eal/windows/eal.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -34,6 +35,55 @@ static int mem_cfg_fd = -1; /* internal configuration (per-core) */ struct lcore_config lcore_config[RTE_MAX_LCORE]; +int +eal_create_runtime_dir(void) +{ + char temp_dir[PATH_MAX]; + char runtime_dir[PATH_MAX]; + int ret; + + /* get user-writable temp path */ + if (GetTempPathA(sizeof(temp_dir), temp_dir) == 0) { + RTE_LOG_WIN32_ERR("GetTempPath"); + return -1; + } + + /* create DPDK runtime subdirectory under temp dir */ + ret = strcat_s(temp_dir, sizeof(temp_dir), "dpdk"); + if (ret != 0) { + RTE_LOG(ERR, EAL, "Error creating DPDK runtime path name\n"); + return -1; + } + + /* create prefix-specific subdirectory under DPDK runtime dir */ + ret = snprintf(runtime_dir, sizeof(runtime_dir), "%s\\%s", + temp_dir, eal_get_hugefile_prefix()); + if (ret < 0 || ret == sizeof(runtime_dir)) { + RTE_LOG(ERR, EAL, "Error creating prefix-specific runtime path\n"); + return -1; + } + + /* create the path if it doesn't exist - step by step */ + ret = _mkdir(temp_dir); + if (ret < 0 && errno != EEXIST) { + RTE_LOG(ERR, EAL, "Error creating '%s': %s\n", + temp_dir, strerror(errno)); + return -1; + } + + ret = _mkdir(runtime_dir); + if (ret < 0 && errno != EEXIST) { + RTE_LOG(ERR, EAL, "Error creating '%s': %s\n", + runtime_dir, strerror(errno)); + return -1; + } + + if (eal_set_runtime_dir(runtime_dir, sizeof(runtime_dir))) + return -1; + + return 0; +} + /* Detect if we are a primary or a secondary process */ enum rte_proc_type_t eal_proc_type_detect(void) @@ -181,6 +231,13 @@ eal_parse_args(int argc, char **argv) } } + /* create runtime data directory */ + if (internal_conf->no_shconf == 0 && + eal_create_runtime_dir() < 0) { + RTE_LOG(ERR, EAL, "Cannot create runtime directory\n"); + return -1; + } + if (eal_adjust_config(internal_conf) != 0) return -1; -- 2.18.0.windows.1