summaryrefslogtreecommitdiff
path: root/components/dfs
diff options
context:
space:
mode:
author[email protected] <[email protected]>2012-12-13 02:13:34 +0000
committer[email protected] <[email protected]>2012-12-13 02:13:34 +0000
commit56ab153b1c92ccfc3695adf9fe8bef3e5230369d (patch)
tree80610849d83ea1332e61619acd4420da74b507ad /components/dfs
parentd8796d9639bb6e9e2c5d5a7cf4d54623ed905b93 (diff)
update dfs to support NFTL
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2478 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/dfs')
-rw-r--r--components/dfs/filesystems/elmfat/dfs_elm.c10
-rw-r--r--components/dfs/filesystems/elmfat/ffconf.h5
-rw-r--r--components/dfs/include/dfs_def.h5
-rw-r--r--components/dfs/include/dfs_posix.h2
-rw-r--r--components/dfs/src/dfs_fs.c11
5 files changed, 28 insertions, 5 deletions
diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c
index cad548b6b5..cbdc1ca262 100644
--- a/components/dfs/filesystems/elmfat/dfs_elm.c
+++ b/components/dfs/filesystems/elmfat/dfs_elm.c
@@ -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;
}
diff --git a/components/dfs/filesystems/elmfat/ffconf.h b/components/dfs/filesystems/elmfat/ffconf.h
index fa77b7e28d..3a4fac7936 100644
--- a/components/dfs/filesystems/elmfat/ffconf.h
+++ b/components/dfs/filesystems/elmfat/ffconf.h
@@ -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. */
diff --git a/components/dfs/include/dfs_def.h b/components/dfs/include/dfs_def.h
index c0fe47fe0c..d467792f2f 100644
--- a/components/dfs/include/dfs_def.h
+++ b/components/dfs/include/dfs_def.h
@@ -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
diff --git a/components/dfs/include/dfs_posix.h b/components/dfs/include/dfs_posix.h
index 9627a4fe73..503099cff6 100644
--- a/components/dfs/include/dfs_posix.h
+++ b/components/dfs/include/dfs_posix.h
@@ -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
diff --git a/components/dfs/src/dfs_fs.c b/components/dfs/src/dfs_fs.c
index 7c319722cd..f747617e5f 100644
--- a/components/dfs/src/dfs_fs.c
+++ b/components/dfs/src/dfs_fs.c
@@ -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);
}