1 /*
2  * Copyright (c) 2006-2018, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2022-10-24     flybreak     the first version
9  */
10 
11 #ifndef __DFS_TMPFS_H__
12 #define __DFS_TMPFS_H__
13 
14 #include <rtthread.h>
15 #include <dfs_vfs.h>
16 
17 #define TMPFS_NAME_MAX  32
18 #define TMPFS_MAGIC     0x0B0B0B0B
19 
20 #define TMPFS_TYPE_FILE   0x00
21 #define TMPFS_TYPE_DIR    0x01
22 
23 struct tmpfs_sb;
24 
25 struct tmpfs_file
26 {
27     rt_uint32_t      type;     /* file type */
28     char name[TMPFS_NAME_MAX]; /* file name */
29     struct dfs_vfs_node node;  /* file node in the tmpfs */
30     struct tmpfs_sb *sb;       /* superblock ptr */
31     rt_uint8_t      *data;     /* file date ptr */
32     rt_size_t        size;     /* file size */
33     rt_bool_t       fre_memory;/* Whether to release memory upon close */
34 };
35 
36 
37 struct tmpfs_sb
38 {
39     rt_uint32_t       magic;       /* TMPFS_MAGIC */
40     struct tmpfs_file root;        /* root dir */
41     rt_size_t         df_size;     /* df size */
42     rt_list_t         sibling;     /* sb sibling list */
43     struct rt_spinlock lock;       /* tmpfs lock */
44 };
45 
46 int dfs_tmpfs_init(void);
47 
48 #endif
49 
50