diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c index c2143d51a1f370d6475987b7c60f233d256b3d57..ebed2b8b5d53861f62db77f83030e51bdffdb809 100644 --- a/components/dfs/filesystems/elmfat/dfs_elm.c +++ b/components/dfs/filesystems/elmfat/dfs_elm.c @@ -228,6 +228,7 @@ int dfs_elm_open(struct dfs_fd* file) mode = FA_READ; if (file->flags & DFS_O_WRONLY) mode |= FA_WRITE; + if ((file->flags & DFS_O_ACCMODE) & DFS_O_RDWR) mode |= FA_WRITE; /* Opens the file, if it is existing. If not, a new file is created. */ if (file->flags & DFS_O_CREAT) mode |= FA_OPEN_ALWAYS; /* Creates a new file. If the file is existing, it is truncated and overwritten. */ @@ -489,7 +490,7 @@ int dfs_elm_rename(struct dfs_filesystem* fs, const char* oldpath, const char* n const char *drivers_oldfn, *drivers_newfn; drivers_oldfn = oldpath; - drivers_newfn = oldpath; + drivers_newfn = newpath; #endif result = f_rename(drivers_oldfn, drivers_newfn); diff --git a/components/dfs/filesystems/romfs/dfs_romfs.c b/components/dfs/filesystems/romfs/dfs_romfs.c index 2f466989040f45a74acd1ac81349f719a002767e..efd74e238bdaf30308f2abcc99e9968f4fa099e4 100644 --- a/components/dfs/filesystems/romfs/dfs_romfs.c +++ b/components/dfs/filesystems/romfs/dfs_romfs.c @@ -113,7 +113,7 @@ int dfs_romfs_open(struct dfs_fd* file) root_dirent = (struct romfs_dirent*)file->fs->data; - if (file->flags & DFS_O_CREAT | DFS_O_WRONLY | DFS_O_APPEND | DFS_O_TRUNC) + if (file->flags & (DFS_O_CREAT | DFS_O_WRONLY | DFS_O_APPEND | DFS_O_TRUNC | DFS_O_RDWR)) return -DFS_STATUS_EINVAL; dirent = dfs_romfs_lookup(root_dirent, file->path); diff --git a/components/dfs/filesystems/uffs/dfs_uffs.c b/components/dfs/filesystems/uffs/dfs_uffs.c new file mode 100644 index 0000000000000000000000000000000000000000..43ce7d44968e5c9ceb009c1b9473caf6ed3314d8 --- /dev/null +++ b/components/dfs/filesystems/uffs/dfs_uffs.c @@ -0,0 +1,92 @@ +#include +#include +#include + +/* mount and unmount file system */ +static int dfs_uffs_mount(struct dfs_filesystem* fs, unsigned long rwflag, const void* data) +{ +} + +static int dfs_uffs_unmount(struct dfs_filesystem* fs) +{ +} + +static int dfs_uffs_mkfs(const char* device_name) +{ + return -DFS_STATUS_EIO; +} + +static int dfs_uffs_statfs(struct dfs_filesystem* fs, struct _statfs *buf) +{ +} + +static int dfs_uffs_open(struct dfs_fd* fd) +{ +} + +static int dfs_uffs_close(struct dfs_fd* fd) +{ +} + +static int dfs_uffs_ioctl(struct dfs_fd* fd, int cmd, void *args) +{ +} + +static int dfs_uffs_read(struct dfs_fd* fd, void* buf, rt_size_t count) +{ +} + +static int dfs_uffs_write(struct dfs_fd* fd, const void* buf, rt_size_t count) +{ +} + +static int dfs_uffs_flush(struct dfs_fd* fd) +{ +} + +static int dfs_uffs_lseek(struct dfs_fd* fd, rt_off_t offset) +{ +} + +static int dfs_uffs_getdents(struct dfs_fd* fd, struct _dirent* dirp, rt_uint32_t count) +{ +} + +static int dfs_uffs_unlink(struct dfs_filesystem* fs, const char* pathname) +{ +} + +static int dfs_uffs_stat(struct dfs_filesystem* fs, const char* filename, struct _stat* buf) +{ +} + +static int dfs_uffs_rename(struct dfs_filesystem* fs, const char* oldpath, const char* newpath) +{ +} + +static const struct dfs_filesystem_operation _uffs = +{ + "uffs", + dfs_uffs_mount, + dfs_uffs_unmount, + dfs_uffs_mkfs, + dfs_uffs_statfs, + + dfs_uffs_open, + dfs_uffs_close, + dfs_uffs_ioctl, + dfs_uffs_read, + dfs_uffs_write, + dfs_uffs_flush, + dfs_uffs_lseek, + dfs_uffs_getdents, + dfs_uffs_unlink, + dfs_uffs_stat, + dfs_uffs_rename, +}; + +int dfs_uffs_init(void) +{ + /* register UFFS file system */ + return dfs_register(&_uffs); +} diff --git a/components/dfs/filesystems/uffs/dfs_uffs.h b/components/dfs/filesystems/uffs/dfs_uffs.h new file mode 100644 index 0000000000000000000000000000000000000000..0f6d497c7cd96a6abeeebad6d9afa8a78898f88d --- /dev/null +++ b/components/dfs/filesystems/uffs/dfs_uffs.h @@ -0,0 +1,20 @@ +/* + * File : dfs_uffs.h + * This file is part of Device File System in RT-Thread RTOS + * COPYRIGHT (C) 2004-2010, RT-Thread Development Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE. + * + * Change Logs: + * Date Author Notes + * 2010-09-02 Bernard The first version. + */ + +#ifndef __DFS_UFFS_H__ +#define __DFS_UFFS_H__ + +int dfs_uffs_init(void); + +#endif