提交 56ab153b 编写于 作者: G goprife@gmail.com

update dfs to support NFTL

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2478 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 d8796d96
......@@ -172,7 +172,7 @@ int dfs_elm_mkfs(const char *device_name)
for (drv = 0; drv < _VOLUMES; drv ++)
{
dev = disk[drv];
if (rt_strncmp(dev->parent.name, device_name, RT_NAME_MAX) == 0)
if (dev != RT_NULL && rt_strncmp(dev->parent.name, device_name, RT_NAME_MAX) == 0)
{
/* 1: no partition table */
/* 0: auto selection of cluster size */
......@@ -782,8 +782,14 @@ DRESULT disk_ioctl(BYTE drv, BYTE ctrl, void *buff)
*(DWORD *)buff = geometry.block_size/geometry.bytes_per_sector;
}
else if (ctrl == CTRL_SYNC)
{
rt_device_control(device, RT_DEVICE_CTRL_BLK_SYNC, RT_NULL);
}
else if (ctrl == CTRL_ERASE_SECTOR)
{
rt_device_control(device, RT_DEVICE_CTRL_BLK_ERASE, buff);
}
return RES_OK;
}
......
......@@ -163,8 +163,11 @@
/ it can mount only first primaly partition. When it is set to 1, each volume
/ is tied to the partitions listed in VolToPart[]. */
#ifdef RT_DFS_ELM_USE_ERASE
#define _USE_ERASE 1
#else
#define _USE_ERASE 0 /* 0:Disable or 1:Enable */
#endif
/* To enable sector erase feature, set _USE_ERASE to 1. CTRL_ERASE_SECTOR command
/ should be added to the disk_ioctl functio. */
......
......@@ -198,6 +198,11 @@
#define DFS_SEEK_SET SEEK_SET
#define DFS_SEEK_CUR SEEK_CUR
#define DFS_SEEK_END SEEK_END
#elif defined(_MSC_VER)
#include <stdio.h>
#define DFS_SEEK_SET SEEK_SET
#define DFS_SEEK_CUR SEEK_CUR
#define DFS_SEEK_END SEEK_END
#else
#define DFS_SEEK_SET 0
#define DFS_SEEK_CUR 1
......
......@@ -69,6 +69,8 @@
#if defined(__CC_ARM)
#include <stdio.h>
#elif defined(_MSC_VER)
#include <stdio.h>
#else
#define SEEK_SET DFS_SEEK_SET
#define SEEK_CUR DFS_SEEK_CUR
......
......@@ -400,7 +400,7 @@ int dfs_mkfs(const char *fs_name, const char *device_name)
{
int index;
/* lock filesystem */
/* lock file system */
dfs_lock();
/* find the file system operations */
for (index = 0; index < DFS_FILESYSTEM_TYPES_MAX; index++)
......@@ -420,6 +420,7 @@ int dfs_mkfs(const char *fs_name, const char *device_name)
}
dfs_unlock();
rt_kprintf("Can not find the file system which named as %s.\n", fs_name);
return -1;
}
......@@ -455,9 +456,15 @@ FINSH_FUNCTION_EXPORT(mkfs, make a file system);
void df(const char *path)
{
int result;
struct statfs buffer;
if (dfs_statfs(path, &buffer) == 0)
if (path == RT_NULL)
result = dfs_statfs("/", &buffer);
else
result = dfs_statfs(path, &buffer);
if (result == 0)
{
rt_kprintf("disk free: %d block[%d bytes per block]\n", buffer.f_bfree, buffer.f_bsize);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册