1 /*
2  * Copyright (c) 2016 Intel Corporation.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_INCLUDE_FS_FS_INTERFACE_H_
8 #define ZEPHYR_INCLUDE_FS_FS_INTERFACE_H_
9 
10 #include <stdint.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 #if (CONFIG_FILE_SYSTEM_MAX_FILE_NAME - 0) > 0
17 #define MAX_FILE_NAME CONFIG_FILE_SYSTEM_MAX_FILE_NAME
18 #else /* CONFIG_FILE_SYSTEM_MAX_FILE_NAME */
19 /* Select from enabled file systems */
20 #if defined(CONFIG_FILE_SYSTEM_LITTLEFS)
21 #define MAX_FILE_NAME 256
22 #elif defined(CONFIG_FAT_FILESYSTEM_ELM)
23 #if defined(CONFIG_FS_FATFS_LFN)
24 #define MAX_FILE_NAME CONFIG_FS_FATFS_MAX_LFN
25 #else /* CONFIG_FS_FATFS_LFN */
26 #define MAX_FILE_NAME 12 /* Uses 8.3 SFN */
27 #endif /* CONFIG_FS_FATFS_LFN */
28 #else /* filesystem selection */
29 /* Use standard 8.3 when no filesystem is explicitly selected */
30 #define MAX_FILE_NAME 12
31 #endif /* filesystem selection */
32 #endif /* CONFIG_FILE_SYSTEM_MAX_FILE_NAME */
33 
34 
35 /* Type for fs_open flags */
36 typedef uint8_t fs_mode_t;
37 
38 struct fs_mount_t;
39 
40 /**
41  * @addtogroup file_system_api
42  * @{
43  */
44 
45 /**
46  * @brief File object representing an open file
47  *
48  * The object needs to be initialized with function fs_file_t_init().
49  *
50  * @param Pointer to FATFS file object structure
51  * @param mp Pointer to mount point structure
52  */
53 struct fs_file_t {
54 	void *filep;
55 	const struct fs_mount_t *mp;
56 	fs_mode_t flags;
57 };
58 
59 /**
60  * @brief Directory object representing an open directory
61  *
62  * The object needs to be initialized with function fs_dir_t_init().
63  *
64  * @param dirp Pointer to directory object structure
65  * @param mp Pointer to mount point structure
66  */
67 struct fs_dir_t {
68 	void *dirp;
69 	const struct fs_mount_t *mp;
70 };
71 
72 /**
73  * @}
74  */
75 
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif /* ZEPHYR_INCLUDE_FS_FS_INTERFACE_H_ */
81