提交 b3cf2785 编写于 作者: P prife

1) elm fatfs can do mkfs without mounting first, 2) use new mkfs 3)change...

1) elm fatfs can do mkfs without mounting first, 2) use new mkfs 3)change linebreak in dfs_uffs.c to unix
...@@ -222,7 +222,7 @@ static int dfs_jffs2_unmount(struct dfs_filesystem* fs) ...@@ -222,7 +222,7 @@ static int dfs_jffs2_unmount(struct dfs_filesystem* fs)
return -DFS_STATUS_ENOENT; return -DFS_STATUS_ENOENT;
} }
static int dfs_jffs2_mkfs(const char* device_name) static int dfs_jffs2_mkfs(rt_device_t dev_id)
{ {
/* just erase all blocks on this nand partition */ /* just erase all blocks on this nand partition */
return -DFS_STATUS_ENOSYS; return -DFS_STATUS_ENOSYS;
......
...@@ -207,7 +207,7 @@ static int dfs_uffs_unmount(struct dfs_filesystem* fs) ...@@ -207,7 +207,7 @@ static int dfs_uffs_unmount(struct dfs_filesystem* fs)
return -DFS_STATUS_ENOENT; return -DFS_STATUS_ENOENT;
} }
static int dfs_uffs_mkfs(const char* device_name) static int dfs_uffs_mkfs(rt_device_t dev_id)
{ {
rt_base_t index; rt_base_t index;
rt_uint32_t block; rt_uint32_t block;
...@@ -216,15 +216,13 @@ static int dfs_uffs_mkfs(const char* device_name) ...@@ -216,15 +216,13 @@ static int dfs_uffs_mkfs(const char* device_name)
/*1. find the device index */ /*1. find the device index */
for (index = 0; index < UFFS_DEVICE_MAX; index++) for (index = 0; index < UFFS_DEVICE_MAX; index++)
{ {
if (rt_strncmp(nand_part[index].dev->parent.parent.name, if (nand_part[index].dev == (struct rt_mtd_nand_device *)dev_id)
device_name, RT_NAME_MAX) == 0)
break; break;
} }
if (index == UFFS_DEVICE_MAX) if (index == UFFS_DEVICE_MAX)
{ {
/* can't find device driver */ /* can't find device driver */
rt_kprintf("can not find device driver: %s\n", device_name);
return -DFS_STATUS_ENOENT; return -DFS_STATUS_ENOENT;
} }
......
...@@ -35,7 +35,7 @@ struct dfs_filesystem_operation ...@@ -35,7 +35,7 @@ struct dfs_filesystem_operation
int (*unmount) (struct dfs_filesystem *fs); int (*unmount) (struct dfs_filesystem *fs);
/* make a file system */ /* 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 (*statfs) (struct dfs_filesystem *fs, struct statfs *buf);
int (*open) (struct dfs_fd *fd); int (*open) (struct dfs_fd *fd);
......
...@@ -424,6 +424,19 @@ err1: ...@@ -424,6 +424,19 @@ err1:
int dfs_mkfs(const char *fs_name, const char *device_name) int dfs_mkfs(const char *fs_name, const char *device_name)
{ {
int index; 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 */ /* lock file system */
dfs_lock(); dfs_lock();
...@@ -438,7 +451,7 @@ int dfs_mkfs(const char *fs_name, const char *device_name) ...@@ -438,7 +451,7 @@ int dfs_mkfs(const char *fs_name, const char *device_name)
dfs_unlock(); dfs_unlock();
if (ops->mkfs != RT_NULL) if (ops->mkfs != RT_NULL)
return ops->mkfs(device_name); return ops->mkfs(dev_id);
break; break;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册