MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / dfs_init

Function dfs_init

components/dfs/dfs_v1/src/dfs.c:48–106  ·  view source on GitHub ↗

* this function will initialize device file system. */

Source from the content-addressed store, hash-verified

46 * this function will initialize device file system.
47 */
48int dfs_init(void)
49{
50 static rt_bool_t init_ok = RT_FALSE;
51
52 if (init_ok)
53 {
54 rt_kprintf("dfs already init.\n");
55 return 0;
56 }
57
58 /* init vnode hash table */
59 dfs_vnode_mgr_init();
60
61 /* clear filesystem operations table */
62 rt_memset((void *)filesystem_operation_table, 0, sizeof(filesystem_operation_table));
63 /* clear filesystem table */
64 rt_memset(filesystem_table, 0, sizeof(filesystem_table));
65 /* clean fd table */
66 rt_memset(&_fdtab, 0, sizeof(_fdtab));
67
68 /* create device filesystem lock */
69 rt_mutex_init(&fslock, "fslock", RT_IPC_FLAG_PRIO);
70 rt_mutex_init(&fdlock, "fdlock", RT_IPC_FLAG_PRIO);
71
72#ifdef DFS_USING_WORKDIR
73 /* set current working directory */
74 rt_memset(working_directory, 0, sizeof(working_directory));
75 working_directory[0] = '/';
76#endif
77
78#ifdef RT_USING_DFS_TMPFS
79 {
80 extern int dfs_tmpfs_init(void);
81 dfs_tmpfs_init();
82 }
83#endif
84
85#ifdef RT_USING_DFS_DEVFS
86 {
87 extern int devfs_init(void);
88
89 /* if enable devfs, initialize and mount it as soon as possible */
90 devfs_init();
91
92 dfs_mount(NULL, "/dev", "devfs", 0, 0);
93 }
94#if defined(RT_USING_DEV_BUS) && defined(RT_USING_DFS_TMPFS)
95 mkdir("/dev/shm", 0x777);
96 if (dfs_mount(RT_NULL, "/dev/shm", "tmp", 0, 0) != 0)
97 {
98 rt_kprintf("Dir /dev/shm mount failed!\n");
99 }
100#endif
101#endif
102
103 init_ok = RT_TRUE;
104
105 return 0;

Callers 11

rt_init_thread_entryFunction · 0.50
rt_init_thread_entryFunction · 0.50
rt_init_thread_entryFunction · 0.50
rt_init_thread_entryFunction · 0.50
rt_init_thread_entryFunction · 0.50
rt_init_thread_entryFunction · 0.50
rt_init_thread_entryFunction · 0.50
mnt_initFunction · 0.50
rt_demo_thread_entryFunction · 0.50
rt_init_thread_entryFunction · 0.50
rt_init_thread_entryFunction · 0.50

Calls 8

rt_kprintfFunction · 0.85
dfs_vnode_mgr_initFunction · 0.85
rt_memsetFunction · 0.85
rt_mutex_initFunction · 0.85
devfs_initFunction · 0.85
dfs_mountFunction · 0.70
mkdirFunction · 0.70
dfs_tmpfs_initFunction · 0.50

Tested by

no test coverage detected