add full path options (DFS_FS_FLAG_FULLPATH) to the file system.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1904 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong@gmail.com committed 2012-01-01 13:37:21 +00:00
1 parent 76e81a9977
commit beaf51ff82
8 files changed
+677 -651

No files matched your search

+1
View File
@@ -248,6 +248,7 @@ int dfs_device_fs_getdents(struct dfs_fd* file, struct dirent* dirp, rt_uint32_t
static const struct dfs_filesystem_operation _device_fs =
{
"devfs",
DFS_FS_FLAG_DEFAULT,
dfs_device_fs_mount,
RT_NULL,
RT_NULL,
@@ -647,6 +647,7 @@ int dfs_elm_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
static const struct dfs_filesystem_operation dfs_elm =
{
"elm",
DFS_FS_FLAG_DEFAULT,
dfs_elm_mount,
dfs_elm_unmount,
dfs_elm_mkfs,
+2 -1
View File
@@ -1056,7 +1056,8 @@ int nfs_getdents(struct dfs_fd *file, struct dirent *dirp, rt_uint32_t count)
static const struct dfs_filesystem_operation _nfs =
{
"nfs",
"nfs",
DFS_FS_FLAG_DEFAULT,
nfs_mount,
nfs_unmount,
RT_NULL, /* mkfs */
File diff suppressed because it is too large. Load diff
@@ -55,6 +55,7 @@ int dfs_skt_getdents(struct dfs_fd* file, struct dirent* dirp, rt_uint32_t count
static const struct dfs_filesystem_operation _skt_fs =
{
"skt",
DFS_FS_FLAG_DEFAULT,
dfs_skt_mount,
dfs_skt_unmount,
RT_NULL,
File diff suppressed because it is too large. Load diff
+4
View File
@@ -17,6 +17,9 @@
#include <dfs_def.h>
#define DFS_FS_FLAG_DEFAULT 0x00 /* default flag */
#define DFS_FS_FLAG_FULLPATH 0x01 /* set full path to underlaying file system */
/* Pre-declaration */
struct dfs_filesystem;
struct dfs_fd;
@@ -25,6 +28,7 @@ struct dfs_fd;
struct dfs_filesystem_operation
{
char *name;
rt_uint32_t flags; /* flags for file system operations */
/* mount and unmount file system */
int (*mount) (struct dfs_filesystem *fs, unsigned long rwflag, const void *data);
+26 -10
View File
@@ -66,13 +66,20 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
fd->size = 0;
fd->pos = 0;
if (dfs_subdir(fs->path, fullpath) == RT_NULL)
fd->path = rt_strdup("/");
if (!(fs->ops->flags & DFS_FS_FLAG_FULLPATH))
{
if (dfs_subdir(fs->path, fullpath) == RT_NULL)
fd->path = rt_strdup("/");
else
fd->path = rt_strdup(dfs_subdir(fs->path, fullpath));
rt_free(fullpath);
dfs_log(DFS_DEBUG_INFO, ("Actual file path: %s\n", fd->path));
}
else
fd->path = rt_strdup(dfs_subdir(fs->path, fullpath));
rt_free(fullpath);
dfs_log(DFS_DEBUG_INFO, ("Actual file path: %s\n", fd->path));
{
fd->path = fullpath;
}
/* specific file system open routine */
if (fs->ops->open == RT_NULL)
{
@@ -241,10 +248,15 @@ int dfs_file_unlink(const char *path)
if (fs->ops->unlink != RT_NULL)
{
if (dfs_subdir(fs->path, fullpath) == RT_NULL)
result = fs->ops->unlink(fs, "/");
if (!(fs->ops->flags & DFS_FS_FLAG_FULLPATH))
{
if (dfs_subdir(fs->path, fullpath) == RT_NULL)
result = fs->ops->unlink(fs, "/");
else
result = fs->ops->unlink(fs, dfs_subdir(fs->path, fullpath));
}
else
result = fs->ops->unlink(fs, dfs_subdir(fs->path, fullpath));
result = fs->ops->unlink(fs, fullpath);
}
else result = -DFS_STATUS_ENOSYS;
@@ -380,7 +392,11 @@ int dfs_file_stat(const char *path, struct stat *buf)
}
/* get the real file path and get file stat */
result = fs->ops->stat(fs, dfs_subdir(fs->path, fullpath), buf);
if (fs->ops->flags & DFS_FS_FLAG_FULLPATH)
result = fs->ops->stat(fs, fullpath, buf);
else
result = fs->ops->stat(fs, dfs_subdir(fs->path, fullpath), buf);
}
rt_free(fullpath);