[v6,03/10] eal: include filesystem implementation for windows
Checks
Commit Message
Adding eal_filesystem.h to support functions and
path defines for files and directories on Windows.
Signed-off-by: Antara Ganesh Kolar <antara.ganesh.kolar@intel.com>
Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
Reviewed-by: Keith Wiles <keith.wiles@intel.com>
---
.../windows/eal/include/eal_filesystem.h | 94 +++++++++++++++++++
1 file changed, 94 insertions(+)
create mode 100644 lib/librte_eal/windows/eal/include/eal_filesystem.h
Comments
Hello Pallavi,
> +#include "eal_internal_cfg.h"
> +
> +/* sets up platform-specific runtime data dir */
> +int
> +eal_create_runtime_dir(void);
> +
> +/* returns runtime dir */
> +const char *
> +eal_get_runtime_dir(void);
Any reason not to #include "eal_filesystem.h"?
> +
> +static inline const char *
> +eal_runtime_config_path(void)
> +{
> + static char buffer[PATH_MAX]; /* static so auto-zeroed */
> + char Directory[PATH_MAX];
Should be "directory" according to the style guide.
> +
> + GetTempPathA(sizeof(Directory), Directory);
> + snprintf(buffer, sizeof(buffer)-1, RUNTIME_CONFIG_FMT, Directory,
Style guide requires spaces around binary "-".
> +static inline const char *
> +eal_hugepage_info_path(void)
> +{
> + static char buffer[PATH_MAX]; /* static so auto-zeroed */
> + TCHAR Directory[PATH_MAX];
Should be "directory", see above.
Hi Dmitry,
Thank you for reviewing the code and for your comments.
On 1/30/2020 10:04 PM, Dmitry Kozliuk wrote:
> Hello Pallavi,
>
>> +#include "eal_internal_cfg.h"
>> +
>> +/* sets up platform-specific runtime data dir */
>> +int
>> +eal_create_runtime_dir(void);
>> +
>> +/* returns runtime dir */
>> +const char *
>> +eal_get_runtime_dir(void);
> Any reason not to #include "eal_filesystem.h"?
Do you mean, we can exclude "eal_filesystem.h" in the current patchset?
If so, you are correct. This file was required before to include
eal_runtime_config_path() when compiling with VS/ ICC, I think.
But, now 'common' version of eal_filesystem.h can be used for Windows.
For other function definitions, we can always #include "eal_filesystem.h"
if require later.
>
>> +
>> +static inline const char *
>> +eal_runtime_config_path(void)
>> +{
>> + static char buffer[PATH_MAX]; /* static so auto-zeroed */
>> + char Directory[PATH_MAX];
> Should be "directory" according to the style guide.
Thanks, will be sending out new version and excluding this file
as mentioned above.
>
>> +
>> + GetTempPathA(sizeof(Directory), Directory);
>> + snprintf(buffer, sizeof(buffer)-1, RUNTIME_CONFIG_FMT, Directory,
> Style guide requires spaces around binary "-".
>
>> +static inline const char *
>> +eal_hugepage_info_path(void)
>> +{
>> + static char buffer[PATH_MAX]; /* static so auto-zeroed */
>> + TCHAR Directory[PATH_MAX];
> Should be "directory", see above.
new file mode 100644
@@ -0,0 +1,94 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+/**
+ * @file
+ * Stores functions and path defines for files and directories
+ * on the filesystem for Windows, that are used by the Windows EAL.
+ */
+
+#ifndef EAL_FILESYSTEM_H
+#define EAL_FILESYSTEM_H
+
+#include "eal_internal_cfg.h"
+
+/* sets up platform-specific runtime data dir */
+int
+eal_create_runtime_dir(void);
+
+/* returns runtime dir */
+const char *
+eal_get_runtime_dir(void);
+
+/* define the default filename prefix for the %s values below */
+#define HUGEFILE_PREFIX_DEFAULT "rte"
+
+/** Path of rte config file */
+#define RUNTIME_CONFIG_FMT "%s\\%s.config"
+
+static inline const char *
+eal_runtime_config_path(void)
+{
+ static char buffer[PATH_MAX]; /* static so auto-zeroed */
+ char Directory[PATH_MAX];
+
+ GetTempPathA(sizeof(Directory), Directory);
+ snprintf(buffer, sizeof(buffer)-1, RUNTIME_CONFIG_FMT, Directory,
+ internal_config.hugefile_prefix);
+
+ return buffer;
+}
+
+/* Path of file backed array */
+#define FBARRAY_NAME_FMT "%s\\fbarray_%s"
+
+static inline const char *
+eal_get_fbarray_path(char *buffer, size_t buflen, const char *name) {
+ snprintf(buffer, buflen, FBARRAY_NAME_FMT, eal_get_runtime_dir(), name);
+ return buffer;
+}
+
+/* Path of primary/secondary communication unix socket file. */
+#define MP_SOCKET_FNAME "mp_socket"
+
+static inline const char *
+eal_mp_socket_path(void)
+{
+ static char buffer[PATH_MAX]; /* static so auto-zeroed */
+
+ snprintf(buffer, sizeof(buffer) - 1, "%s/%s", eal_get_runtime_dir(),
+ MP_SOCKET_FNAME);
+ return buffer;
+}
+
+/** Path of hugepage info file */
+#define HUGEPAGE_INFO_FMT "%s\\.%s_hugepage_info"
+
+static inline const char *
+eal_hugepage_info_path(void)
+{
+ static char buffer[PATH_MAX]; /* static so auto-zeroed */
+ TCHAR Directory[PATH_MAX];
+
+ GetSystemDirectory(Directory, sizeof(Directory));
+ snprintf(buffer, sizeof(buffer)-1, HUGEPAGE_INFO_FMT, Directory,
+ internal_config.hugefile_prefix);
+ return buffer;
+}
+
+/** String format for hugepage map files */
+#define HUGEFILE_FMT "%s/%smap_%d"
+#define TEMP_HUGEFILE_FMT "%s/%smap_temp_%d"
+
+static inline const char *
+eal_get_hugefile_path(char *buffer, size_t buflen, const char *hugedir,
+ int f_id)
+{
+ snprintf(buffer, buflen, HUGEFILE_FMT, hugedir,
+ internal_config.hugefile_prefix, f_id);
+ buffer[buflen - 1] = '\0';
+ return buffer;
+}
+
+#endif /* EAL_FILESYSTEM_H */