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. */
21 #include <rte_string_fns.h>
22 #include "eal_internal_cfg.h"
24 /* sets up platform-specific runtime data dir */
26 eal_create_runtime_dir(void);
28 #define RUNTIME_CONFIG_FNAME "config"
29 static inline const char *
30 eal_runtime_config_path(void)
32 static char buffer[PATH_MAX]; /* static so auto-zeroed */
34 snprintf(buffer, sizeof(buffer) - 1, "%s/%s", rte_eal_get_runtime_dir(),
35 RUNTIME_CONFIG_FNAME);
39 /** Path of primary/secondary communication unix socket file. */
40 #define MP_SOCKET_FNAME "mp_socket"
41 static inline const char *
42 eal_mp_socket_path(void)
44 static char buffer[PATH_MAX]; /* static so auto-zeroed */
46 snprintf(buffer, sizeof(buffer) - 1, "%s/%s", rte_eal_get_runtime_dir(),
51 #define FBARRAY_NAME_FMT "%s/fbarray_%s"
52 static inline const char *
53 eal_get_fbarray_path(char *buffer, size_t buflen, const char *name) {
54 snprintf(buffer, buflen, FBARRAY_NAME_FMT, rte_eal_get_runtime_dir(),
59 /** Path of hugepage info file. */
60 #define HUGEPAGE_INFO_FNAME "hugepage_info"
61 static inline const char *
62 eal_hugepage_info_path(void)
64 static char buffer[PATH_MAX]; /* static so auto-zeroed */
66 snprintf(buffer, sizeof(buffer) - 1, "%s/%s", rte_eal_get_runtime_dir(),
71 /** Path of hugepage data file. */
72 #define HUGEPAGE_DATA_FNAME "hugepage_data"
73 static inline const char *
74 eal_hugepage_data_path(void)
76 static char buffer[PATH_MAX]; /* static so auto-zeroed */
78 snprintf(buffer, sizeof(buffer) - 1, "%s/%s", rte_eal_get_runtime_dir(),
83 /** String format for hugepage map files. */
84 #define HUGEFILE_FMT "%s/%smap_%d"
85 static inline const char *
86 eal_get_hugefile_path(char *buffer, size_t buflen, const char *hugedir, int f_id)
88 snprintf(buffer, buflen, HUGEFILE_FMT, hugedir,
89 internal_config.hugefile_prefix, f_id);
90 buffer[buflen - 1] = '\0';
94 /** String format for hugepage map lock files. */
95 #define HUGEFILE_LOCK_FMT "%s/map_%d.lock"
96 static inline const char *
97 eal_get_hugefile_lock_path(char *buffer, size_t buflen, int f_id)
99 snprintf(buffer, buflen, HUGEFILE_LOCK_FMT, rte_eal_get_runtime_dir(),
101 buffer[buflen - 1] = '\0';
105 /** define the default filename prefix for the %s values above */
106 #define HUGEFILE_PREFIX_DEFAULT "rte"
108 /** Function to read a single numeric value from a file on the filesystem.
109 * Used to read information from files on /sys */
110 int eal_parse_sysfs_value(const char *filename, unsigned long *val);
112 #endif /* EAL_FILESYSTEM_H */