2017-10-20 13:26:47 +08:00
|
|
|
/*
|
2021-03-20 22:39:00 +08:00
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2017-10-20 13:26:47 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
2021-03-20 22:39:00 +08:00
|
|
|
* 2017-04-03 Urey the first version
|
2017-10-20 13:26:47 +08:00
|
|
|
*/
|
|
|
|
#include <rtthread.h>
|
|
|
|
#include <rtdevice.h>
|
|
|
|
|
2022-05-16 13:21:47 +08:00
|
|
|
#define DBG_TAG "FileSystem"
|
|
|
|
#define DBG_LVL DBG_INFO
|
|
|
|
#include <rtdbg.h>
|
|
|
|
|
2017-10-20 13:26:47 +08:00
|
|
|
#ifdef RT_USING_DFS
|
|
|
|
#include <dfs_fs.h>
|
|
|
|
|
2022-05-16 13:21:47 +08:00
|
|
|
static int mnt_init(void)
|
2017-10-20 13:26:47 +08:00
|
|
|
{
|
|
|
|
#ifdef RT_USING_DFS_WINSHAREDIR
|
2018-01-19 11:42:05 +08:00
|
|
|
extern int dfs_win32_init(void);
|
|
|
|
extern rt_err_t rt_win_sharedir_init(const char *name);
|
2021-03-20 22:39:00 +08:00
|
|
|
|
2017-10-20 13:26:47 +08:00
|
|
|
dfs_win32_init();
|
|
|
|
rt_win_sharedir_init("wshare");
|
|
|
|
|
|
|
|
if (dfs_mount("wshare", "/", "wdir", 0, 0) == 0)
|
|
|
|
{
|
2022-05-16 13:21:47 +08:00
|
|
|
LOG_I("[wshare] File System on root ('wshare') initialized!");
|
2017-10-20 13:26:47 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-05-16 13:21:47 +08:00
|
|
|
LOG_E("[wshare] File System on root ('wshare') initialization failed!");
|
2017-10-20 13:26:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dfs_mount("sd0", "/sd", "elm", 0, 0) == 0)
|
|
|
|
{
|
2022-05-16 13:21:47 +08:00
|
|
|
LOG_I("[sd0] File System on SD ('sd0') initialized!");
|
2017-10-20 13:26:47 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-05-16 13:21:47 +08:00
|
|
|
LOG_W("[sd0] File System on SD ('sd0') initialization failed!");
|
|
|
|
LOG_W("[sd0] Try to format and re-mount again...");
|
|
|
|
if (dfs_mkfs("elm", "sd0") == 0)
|
|
|
|
{
|
|
|
|
if (dfs_mount("sd0", "/sd", "elm", 0, 0) == 0)
|
|
|
|
{
|
|
|
|
LOG_I("[sd0] File System on SD ('sd0') initialized!");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LOG_E("[sd0] File System on SD ('sd0') initialization failed!");
|
2017-10-20 13:26:47 +08:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
|
|
|
|
{
|
2022-05-16 13:21:47 +08:00
|
|
|
LOG_I("[sd0] File System on sd initialized!");
|
2017-10-20 13:26:47 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-05-16 13:21:47 +08:00
|
|
|
LOG_E("[sd0] File System on sd initialization failed!");
|
2017-10-20 13:26:47 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-11-30 23:56:52 +08:00
|
|
|
return 0;
|
2017-10-20 13:26:47 +08:00
|
|
|
}
|
2022-04-09 11:33:34 +08:00
|
|
|
INIT_ENV_EXPORT(mnt_init);
|
2017-10-20 13:26:47 +08:00
|
|
|
#endif
|