mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-02-07 19:14:34 +08:00
fix O_RDWR issue in ELM FatFs.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@912 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
c89ea7615e
commit
3c2c5df6e8
@ -228,6 +228,7 @@ int dfs_elm_open(struct dfs_fd* file)
|
|||||||
mode = FA_READ;
|
mode = FA_READ;
|
||||||
|
|
||||||
if (file->flags & DFS_O_WRONLY) mode |= FA_WRITE;
|
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. */
|
/* Opens the file, if it is existing. If not, a new file is created. */
|
||||||
if (file->flags & DFS_O_CREAT) mode |= FA_OPEN_ALWAYS;
|
if (file->flags & DFS_O_CREAT) mode |= FA_OPEN_ALWAYS;
|
||||||
/* Creates a new file. If the file is existing, it is truncated and overwritten. */
|
/* 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;
|
const char *drivers_oldfn, *drivers_newfn;
|
||||||
|
|
||||||
drivers_oldfn = oldpath;
|
drivers_oldfn = oldpath;
|
||||||
drivers_newfn = oldpath;
|
drivers_newfn = newpath;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
result = f_rename(drivers_oldfn, drivers_newfn);
|
result = f_rename(drivers_oldfn, drivers_newfn);
|
||||||
|
@ -113,7 +113,7 @@ int dfs_romfs_open(struct dfs_fd* file)
|
|||||||
|
|
||||||
root_dirent = (struct romfs_dirent*)file->fs->data;
|
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;
|
return -DFS_STATUS_EINVAL;
|
||||||
|
|
||||||
dirent = dfs_romfs_lookup(root_dirent, file->path);
|
dirent = dfs_romfs_lookup(root_dirent, file->path);
|
||||||
|
92
components/dfs/filesystems/uffs/dfs_uffs.c
Normal file
92
components/dfs/filesystems/uffs/dfs_uffs.c
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
#include <rtthread.h>
|
||||||
|
#include <dfs.h>
|
||||||
|
#include <dfs_fs.h>
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
}
|
20
components/dfs/filesystems/uffs/dfs_uffs.h
Normal file
20
components/dfs/filesystems/uffs/dfs_uffs.h
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user