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:
prife
2013-01-08 18:58:45 +08:00
parent 3d0ca0d08f
commit 5646189b29
3 changed files with 122 additions and 64 deletions
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -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);
+14 -1
View File
@@ -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;
}