mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-07 00:59:00 +08:00
elm fatfs support mkfs with no need to run dfs_mount elm first; and can mount/umount/mkfs without reset any more
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -35,7 +35,7 @@ struct dfs_filesystem_operation
|
||||
int (*unmount) (struct dfs_filesystem *fs);
|
||||
|
||||
/* make a file system */
|
||||
int (*mkfs) (const char *device_name);
|
||||
int (*mkfs) (rt_device_t devid);
|
||||
int (*statfs) (struct dfs_filesystem *fs, struct statfs *buf);
|
||||
|
||||
int (*open) (struct dfs_fd *fd);
|
||||
|
||||
@@ -424,6 +424,19 @@ err1:
|
||||
int dfs_mkfs(const char *fs_name, const char *device_name)
|
||||
{
|
||||
int index;
|
||||
rt_device_t dev_id;
|
||||
|
||||
/* check device name, and it should not be NULL */
|
||||
if (device_name == RT_NULL)
|
||||
dev_id = RT_NULL;
|
||||
else
|
||||
dev_id = rt_device_find(device_name);
|
||||
|
||||
if (dev_id == RT_NULL)
|
||||
{
|
||||
rt_set_errno(-DFS_STATUS_ENODEV);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* lock file system */
|
||||
dfs_lock();
|
||||
@@ -438,7 +451,7 @@ int dfs_mkfs(const char *fs_name, const char *device_name)
|
||||
dfs_unlock();
|
||||
|
||||
if (ops->mkfs != RT_NULL)
|
||||
return ops->mkfs(device_name);
|
||||
return ops->mkfs(dev_id);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user