update dfs to support NFTL
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2478 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
d8796d9639
commit
56ab153b1c
|
@ -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,7 +782,13 @@ 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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue