1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
7 * Stores functions and path defines for files and directories
8 * on the filesystem for Linux, that are used by the Linux EAL.
11 #ifndef EAL_FILESYSTEM_H
12 #define EAL_FILESYSTEM_H
14 /** Path of rte config file. */
15 #define RUNTIME_CONFIG_FMT "%s/.%s_config"
22 #include <rte_string_fns.h>
23 #include "eal_internal_cfg.h"
25 static const char *default_config_dir = "/var/run";
27 static inline const char *
28 eal_runtime_config_path(void)
30 static char buffer[PATH_MAX]; /* static so auto-zeroed */
31 const char *directory = default_config_dir;
32 const char *home_dir = getenv("HOME");
34 if (getuid() != 0 && home_dir != NULL)
36 snprintf(buffer, sizeof(buffer) - 1, RUNTIME_CONFIG_FMT, directory,
37 internal_config.hugefile_prefix);
41 /** Path of primary/secondary communication unix socket file. */
42 #define MP_SOCKET_PATH_FMT "%s/.%s_unix"
43 static inline const char *
44 eal_mp_socket_path(void)
46 static char buffer[PATH_MAX]; /* static so auto-zeroed */
47 const char *directory = default_config_dir;
48 const char *home_dir = getenv("HOME");
50 if (getuid() != 0 && home_dir != NULL)
52 snprintf(buffer, sizeof(buffer) - 1, MP_SOCKET_PATH_FMT,
53 directory, internal_config.hugefile_prefix);
58 /** Path of hugepage info file. */
59 #define HUGEPAGE_INFO_FMT "%s/.%s_hugepage_info"
61 static inline const char *
62 eal_hugepage_info_path(void)
64 static char buffer[PATH_MAX]; /* static so auto-zeroed */
65 const char *directory = default_config_dir;
66 const char *home_dir = getenv("HOME");
68 if (getuid() != 0 && home_dir != NULL)
70 snprintf(buffer, sizeof(buffer) - 1, HUGEPAGE_INFO_FMT, directory,
71 internal_config.hugefile_prefix);
75 /** String format for hugepage map files. */
76 #define HUGEFILE_FMT "%s/%smap_%d"
77 #define TEMP_HUGEFILE_FMT "%s/%smap_temp_%d"
79 static inline const char *
80 eal_get_hugefile_path(char *buffer, size_t buflen, const char *hugedir, int f_id)
82 snprintf(buffer, buflen, HUGEFILE_FMT, hugedir,
83 internal_config.hugefile_prefix, f_id);
84 buffer[buflen - 1] = '\0';
88 /** define the default filename prefix for the %s values above */
89 #define HUGEFILE_PREFIX_DEFAULT "rte"
91 /** Function to read a single numeric value from a file on the filesystem.
92 * Used to read information from files on /sys */
93 int eal_parse_sysfs_value(const char *filename, unsigned long *val);
95 #endif /* EAL_FILESYSTEM_H */