From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 62B39A00C5; Fri, 24 Dec 2021 00:39:13 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E5E044068C; Fri, 24 Dec 2021 00:39:12 +0100 (CET) Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by mails.dpdk.org (Postfix) with ESMTP id 2A7FC4067B for ; Fri, 24 Dec 2021 00:39:11 +0100 (CET) Received: by mail-pg1-f173.google.com with SMTP id l10so6150997pgm.7 for ; Thu, 23 Dec 2021 15:39:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=f+8B0eO8zQOApRJBZFD+qQGrKpgRL926r86mkpPcm/s=; b=ydvoE0C6ijWKmdSxzwlnFGHuCyNo8FWW15zuFFzPD4lX4TG0zHQIB5F5AG4o3ShNzp oqVubpzjHxxbwPVnID5Zb02nUqH79mnJsFF9ZHD+yBDwhPbFZGJKidZM+b1yZLBXO2xa kuD2WiU5IF1aivBdybwBFcPrF786yPkUv7sKB4I9ivyDZTbf1qEL266u/2P95eBKpHC3 +dSC80T1F1TJlG+eubJsfhjVoouqEHPwwcjys0wWuETt2o/npPcJHR53VhUOJe4E4iFJ 3S36ehIrc6UfWInupza/ChzpI8aI9MH9uMbFNxhhWSACSxVJyaSRm8K0FFPZ3wEg7I94 ZvPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=f+8B0eO8zQOApRJBZFD+qQGrKpgRL926r86mkpPcm/s=; b=8PvmPRTP3R/gk9+R1B9UmNGyLX6QpR9V7Y7wq6HKBveTb2sum3Ys25N+0MTO0Y0uTQ W0A2xJGwmQe4a88CDkeACSduEUAXi0AFwSulBKbquvWYf+7oImFm9iHQoDLlIB+HOGNs eAHOYH/YU2SY88iVh0tWhswnevtcWZ034vJDNnKVefDKgBKrk0muuCWUQctF03piv5zV YcV/V/LkKWcOn0q++pLMNdd7l3OCYdGmSWNQfgN95VQQzadLb0EgUAS61hoJalyC0OFz 4n3wYSdgYKrnCyM5gBC7g5jnANO9paPfWDIYSpj8S60lALXBxhQJUHcfKmLIMOU5fjZ7 k0Gg== X-Gm-Message-State: AOAM532mzs1Pj0TUSFyiajzT813+CBw4iNwSA28sktpw68gmIDqL48D8 +h4xcYpCkDq+YuGQLmdVqvAXkBoRYZmQmQ== X-Google-Smtp-Source: ABdhPJwBtTnaWTZVfZXmUcoLpeCEYfwFEZuzSt7ZhfyVGoqWZHhanKCNNe5gJ/fSSYo8fgXqhxce5A== X-Received: by 2002:a63:5d61:: with SMTP id o33mr3898367pgm.341.1640302749818; Thu, 23 Dec 2021 15:39:09 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id v12sm5696590pgc.13.2021.12.23.15.39.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 15:39:09 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [RFC] eal: support systemd service convention for runtime directory Date: Thu, 23 Dec 2021 15:39:07 -0800 Message-Id: <20211223233907.181033-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Systemd.exec supports configuring the runtime directory of a service via RuntimeDirectory=. This creates the directory with the necessary permissions which actual service may not have if running in container. The change to DPDK is to look for the environment RUNTIME_DIRECTORY first and use that in preference to the fallback alternatives. Signed-off-by: Stephen Hemminger --- lib/eal/linux/eal.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 60b49248388e..e729c713b393 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -86,25 +86,26 @@ struct lcore_config lcore_config[RTE_MAX_LCORE]; /* used by rte_rdtsc() */ int rte_cycles_vmware_tsc_map; -static const char *default_runtime_dir = "/var/run"; - int eal_create_runtime_dir(void) { - const char *directory = default_runtime_dir; - const char *xdg_runtime_dir = getenv("XDG_RUNTIME_DIR"); - const char *fallback = "/tmp"; + const char *directory; char run_dir[PATH_MAX]; char tmp[PATH_MAX]; int ret; - if (getuid() != 0) { - /* try XDG path first, fall back to /tmp */ - if (xdg_runtime_dir != NULL) - directory = xdg_runtime_dir; - else - directory = fallback; + /* from RuntimeDirectory= see systemd.exec */ + directory = getenv("RUNTIME_DIRECTORY"); + if (directory == NULL) { + if (getuid() == 0) + directory = "/var/run"; + else { + directory = getenv("XDG_RUNTIME_DIR"); + if (directory == NULL) + directory = "/tmp"; + } } + /* create DPDK subdirectory under runtime dir */ ret = snprintf(tmp, sizeof(tmp), "%s/dpdk", directory); if (ret < 0 || ret == sizeof(tmp)) { -- 2.30.2