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 
19 #else /* CONFIG_FILE_SYSTEM_MAX_FILE_NAME */
20 /* Select from enabled file systems */
21 
22 #if defined(CONFIG_FAT_FILESYSTEM_ELM)
23 
24 #if defined(CONFIG_FS_FATFS_LFN)
25 #define MAX_FILE_NAME CONFIG_FS_FATFS_MAX_LFN
26 #else /* CONFIG_FS_FATFS_LFN */
27 #define MAX_FILE_NAME 12 /* Uses 8.3 SFN */
28 #endif /* CONFIG_FS_FATFS_LFN */
29 
30 #endif
31 
32 #if !defined(MAX_FILE_NAME) && defined(CONFIG_FILE_SYSTEM_EXT2)
33 #define MAX_FILE_NAME 255
34 #endif
35 
36 #if !defined(MAX_FILE_NAME) && defined(CONFIG_FILE_SYSTEM_LITTLEFS)
37 #define MAX_FILE_NAME 256
38 #endif
39 
40 #if !defined(MAX_FILE_NAME) /* filesystem selection */
41 /* Use standard 8.3 when no filesystem is explicitly selected */
42 #define MAX_FILE_NAME 12
43 #endif /* filesystem selection */
44 
45 #endif /* CONFIG_FILE_SYSTEM_MAX_FILE_NAME */
46 
47 
48 /* Type for fs_open flags */
49 typedef uint8_t fs_mode_t;
50 
51 struct fs_mount_t;
52 
53 /**
54  * @addtogroup file_system_api
55  * @{
56  */
57 
58 /**
59  * @brief File object representing an open file
60  *
61  * The object needs to be initialized with fs_file_t_init().
62  */
63 struct fs_file_t {
64 	/** Pointer to file object structure */
65 	void *filep;
66 	/** Pointer to mount point structure */
67 	const struct fs_mount_t *mp;
68 	/** Open/create flags */
69 	fs_mode_t flags;
70 };
71 
72 /**
73  * @brief Directory object representing an open directory
74  *
75  * The object needs to be initialized with fs_dir_t_init().
76  */
77 struct fs_dir_t {
78 	/** Pointer to directory object structure */
79 	void *dirp;
80 	/** Pointer to mount point structure */
81 	const struct fs_mount_t *mp;
82 };
83 
84 /**
85  * @}
86  */
87 
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 #endif /* ZEPHYR_INCLUDE_FS_FS_INTERFACE_H_ */
93