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);
29 eal_clean_runtime_dir(void);
31 /** Function to return hugefile prefix that's currently set up */
33 eal_get_hugefile_prefix(void);
35 #define RUNTIME_CONFIG_FNAME "config"
36 static inline const char *
37 eal_runtime_config_path(void)
39 static char buffer[PATH_MAX]; /* static so auto-zeroed */
41 snprintf(buffer, sizeof(buffer), "%s/%s", rte_eal_get_runtime_dir(),
42 RUNTIME_CONFIG_FNAME);
46 /** Path of primary/secondary communication unix socket file. */
47 #define MP_SOCKET_FNAME "mp_socket"
48 static inline const char *
49 eal_mp_socket_path(void)
51 static char buffer[PATH_MAX]; /* static so auto-zeroed */
53 snprintf(buffer, sizeof(buffer), "%s/%s", rte_eal_get_runtime_dir(),
58 #define FBARRAY_NAME_FMT "%s/fbarray_%s"
59 static inline const char *
60 eal_get_fbarray_path(char *buffer, size_t buflen, const char *name) {
61 snprintf(buffer, buflen, FBARRAY_NAME_FMT, rte_eal_get_runtime_dir(),
66 /** Path of hugepage info file. */
67 #define HUGEPAGE_INFO_FNAME "hugepage_info"
68 static inline const char *
69 eal_hugepage_info_path(void)
71 static char buffer[PATH_MAX]; /* static so auto-zeroed */
73 snprintf(buffer, sizeof(buffer), "%s/%s", rte_eal_get_runtime_dir(),
78 /** Path of hugepage data file. */
79 #define HUGEPAGE_DATA_FNAME "hugepage_data"
80 static inline const char *
81 eal_hugepage_data_path(void)
83 static char buffer[PATH_MAX]; /* static so auto-zeroed */
85 snprintf(buffer, sizeof(buffer), "%s/%s", rte_eal_get_runtime_dir(),
90 /** String format for hugepage map files. */
91 #define HUGEFILE_FMT "%s/%smap_%d"
92 static inline const char *
93 eal_get_hugefile_path(char *buffer, size_t buflen, const char *hugedir, int f_id)
95 snprintf(buffer, buflen, HUGEFILE_FMT, hugedir,
96 eal_get_hugefile_prefix(), f_id);
100 /** define the default filename prefix for the %s values above */
101 #define HUGEFILE_PREFIX_DEFAULT "rte"
103 /** Function to read a single numeric value from a file on the filesystem.
104 * Used to read information from files on /sys */
105 int eal_parse_sysfs_value(const char *filename, unsigned long *val);
107 #endif /* EAL_FILESYSTEM_H */