[DFS] prepare for dfs_v2.0 (#7200)

* [DFS] prepare for dfs_v2. dfs_fd -> dfs_file; dfs_fnode -> dfs_vnode.

* [BSP] fix code analysis warning

* [smart] fix the pointer overflow.

* code format

* [smart] fix the lwp->lwp_obj checking.
This commit is contained in:
Bernard Xiong 2023-04-08 22:25:51 +08:00 committed by GitHub
parent 7fbe8bbd49
commit 9600b75b55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
56 changed files with 494 additions and 480 deletions

View File

@ -144,7 +144,7 @@ char * dfs_win32_dirdup(char * path)
return file_path;
}
static int dfs_win32_open(struct dfs_fd *file)
static int dfs_win32_open(struct dfs_file *file)
{
int fd;
uint32_t oflag, mode;
@ -239,7 +239,7 @@ __err:
return win32_result_to_dfs(res);
}
static int dfs_win32_close(struct dfs_fd *file)
static int dfs_win32_close(struct dfs_file *file)
{
if (file->flags & O_DIRECTORY)
{
@ -260,12 +260,12 @@ static int dfs_win32_close(struct dfs_fd *file)
return win32_result_to_dfs(GetLastError());
}
static int dfs_win32_ioctl(struct dfs_fd *file, int cmd, void *args)
static int dfs_win32_ioctl(struct dfs_file *file, int cmd, void *args)
{
return -ENOSYS;
}
static int dfs_win32_read(struct dfs_fd *file, void *buf, size_t len)
static int dfs_win32_read(struct dfs_file *file, void *buf, size_t len)
{
int fd;
int char_read;
@ -280,7 +280,7 @@ static int dfs_win32_read(struct dfs_fd *file, void *buf, size_t len)
return char_read;
}
static int dfs_win32_write(struct dfs_fd *file, const void *buf, size_t len)
static int dfs_win32_write(struct dfs_file *file, const void *buf, size_t len)
{
int fd;
int char_write;
@ -296,12 +296,12 @@ static int dfs_win32_write(struct dfs_fd *file, const void *buf, size_t len)
return char_write;
}
static int dfs_win32_flush(struct dfs_fd *file)
static int dfs_win32_flush(struct dfs_file *file)
{
return 0;
}
static int dfs_win32_seek(struct dfs_fd *file,
static int dfs_win32_seek(struct dfs_file *file,
rt_off_t offset)
{
int result;
@ -325,7 +325,7 @@ static int dfs_win32_seek(struct dfs_fd *file,
}
/* return the size of struct dirent*/
static int dfs_win32_getdents(struct dfs_fd *file, struct dirent *dirp, rt_uint32_t count)
static int dfs_win32_getdents(struct dfs_file *file, struct dirent *dirp, rt_uint32_t count)
{
WINDIR *wdirp;
struct dirent *d = dirp;

View File

@ -107,7 +107,7 @@ int win_getsockname(int s, struct sal_type_sockaddr* name, sal_type_socklen_t* n
int win_ioctlsocket(int s, long cmd, void* arg);
#ifdef SAL_USING_POSIX
int inet_poll(struct dfs_fd* file, struct rt_pollreq* req);
int inet_poll(struct dfs_file* file, struct rt_pollreq* req);
#endif /* SAL_USING_POSIX */

View File

@ -167,9 +167,10 @@ int win_ioctlsocket(int s, long cmd, void *arg)
#ifdef SAL_USING_POSIX
/* use windows poll, but not wait */
int inet_poll(struct dfs_fd* file, struct rt_pollreq* req)
int inet_poll(struct dfs_file* file, struct rt_pollreq* req)
{
/*WSAPOLLFD winpoll;
/*
WSAPOLLFD winpoll;
struct sal_socket* sal_sock;
int mask = 0;
int poll_event = 0;
@ -189,7 +190,10 @@ int inet_poll(struct dfs_fd* file, struct rt_pollreq* req)
if (mask == 0)
return 0;
return winpoll.revents;*/
return winpoll.revents;
*/
return 0;
}
#endif /* SAL_USING_POSIX */

View File

@ -564,7 +564,7 @@ static int dfs_cromfs_unmount(struct dfs_filesystem *fs)
return RT_EOK;
}
static int dfs_cromfs_ioctl(struct dfs_fd *file, int cmd, void *args)
static int dfs_cromfs_ioctl(struct dfs_file *file, int cmd, void *args)
{
return -EIO;
}
@ -718,7 +718,7 @@ end:
return ret;
}
static int dfs_cromfs_read(struct dfs_fd *file, void *buf, size_t count)
static int dfs_cromfs_read(struct dfs_file *file, void *buf, size_t count)
{
rt_err_t result = RT_EOK;
struct dfs_filesystem *fs = NULL;
@ -788,7 +788,7 @@ static int dfs_cromfs_read(struct dfs_fd *file, void *buf, size_t count)
return length;
}
static int dfs_cromfs_lseek(struct dfs_fd *file, off_t offset)
static int dfs_cromfs_lseek(struct dfs_file *file, off_t offset)
{
if (offset <= file->vnode->size)
{
@ -890,7 +890,7 @@ static void deref_file_info(cromfs_info *ci, uint32_t partition_pos)
}
}
static int dfs_cromfs_close(struct dfs_fd *file)
static int dfs_cromfs_close(struct dfs_file *file)
{
file_info *fi = NULL;
struct dfs_filesystem *fs = NULL;
@ -918,7 +918,7 @@ static int dfs_cromfs_close(struct dfs_fd *file)
return RT_EOK;
}
static int dfs_cromfs_open(struct dfs_fd *file)
static int dfs_cromfs_open(struct dfs_file *file)
{
int ret = 0;
struct dfs_filesystem *fs = NULL;
@ -1047,7 +1047,7 @@ static int dfs_cromfs_stat(struct dfs_filesystem *fs, const char *path, struct s
return RT_EOK;
}
static int dfs_cromfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
static int dfs_cromfs_getdents(struct dfs_file *file, struct dirent *dirp, uint32_t count)
{
uint32_t index = 0;
uint8_t *name = NULL;

View File

@ -39,7 +39,7 @@ int dfs_device_fs_statfs(struct dfs_filesystem *fs, struct statfs *buf)
return RT_EOK;
}
int dfs_device_fs_ioctl(struct dfs_fd *file, int cmd, void *args)
int dfs_device_fs_ioctl(struct dfs_file *file, int cmd, void *args)
{
rt_err_t result;
rt_device_t dev_id;
@ -61,7 +61,7 @@ int dfs_device_fs_ioctl(struct dfs_fd *file, int cmd, void *args)
return result;
}
int dfs_device_fs_read(struct dfs_fd *file, void *buf, size_t count)
int dfs_device_fs_read(struct dfs_file *file, void *buf, size_t count)
{
int result;
rt_device_t dev_id;
@ -82,7 +82,7 @@ int dfs_device_fs_read(struct dfs_fd *file, void *buf, size_t count)
return result;
}
int dfs_device_fs_write(struct dfs_fd *file, const void *buf, size_t count)
int dfs_device_fs_write(struct dfs_file *file, const void *buf, size_t count)
{
int result;
rt_device_t dev_id;
@ -103,7 +103,7 @@ int dfs_device_fs_write(struct dfs_fd *file, const void *buf, size_t count)
return result;
}
int dfs_device_fs_close(struct dfs_fd *file)
int dfs_device_fs_close(struct dfs_file *file)
{
rt_err_t result;
rt_device_t dev_id;
@ -144,7 +144,7 @@ int dfs_device_fs_close(struct dfs_fd *file)
return -EIO;
}
int dfs_device_fs_open(struct dfs_fd *file)
int dfs_device_fs_open(struct dfs_file *file)
{
rt_err_t result;
rt_device_t device;
@ -334,7 +334,7 @@ int dfs_device_fs_stat(struct dfs_filesystem *fs, const char *path, struct stat
return -ENOENT;
}
int dfs_device_fs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
int dfs_device_fs_getdents(struct dfs_file *file, struct dirent *dirp, uint32_t count)
{
rt_uint32_t index;
rt_object_t object;
@ -373,7 +373,7 @@ int dfs_device_fs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t co
return index * sizeof(struct dirent);
}
static int dfs_device_fs_poll(struct dfs_fd *fd, struct rt_pollreq *req)
static int dfs_device_fs_poll(struct dfs_file *fd, struct rt_pollreq *req)
{
int mask = 0;

View File

@ -328,7 +328,7 @@ int dfs_elm_statfs(struct dfs_filesystem *fs, struct statfs *buf)
return 0;
}
int dfs_elm_open(struct dfs_fd *file)
int dfs_elm_open(struct dfs_file *file)
{
FIL *fd;
BYTE mode;
@ -464,7 +464,7 @@ int dfs_elm_open(struct dfs_fd *file)
return RT_EOK;
}
int dfs_elm_close(struct dfs_fd *file)
int dfs_elm_close(struct dfs_file *file)
{
FRESULT result;
@ -501,7 +501,7 @@ int dfs_elm_close(struct dfs_fd *file)
return elm_result_to_dfs(result);
}
int dfs_elm_ioctl(struct dfs_fd *file, int cmd, void *args)
int dfs_elm_ioctl(struct dfs_file *file, int cmd, void *args)
{
switch (cmd)
{
@ -537,7 +537,7 @@ int dfs_elm_ioctl(struct dfs_fd *file, int cmd, void *args)
return -ENOSYS;
}
int dfs_elm_read(struct dfs_fd *file, void *buf, size_t len)
int dfs_elm_read(struct dfs_file *file, void *buf, size_t len)
{
FIL *fd;
FRESULT result;
@ -560,7 +560,7 @@ int dfs_elm_read(struct dfs_fd *file, void *buf, size_t len)
return elm_result_to_dfs(result);
}
int dfs_elm_write(struct dfs_fd *file, const void *buf, size_t len)
int dfs_elm_write(struct dfs_file *file, const void *buf, size_t len)
{
FIL *fd;
FRESULT result;
@ -584,7 +584,7 @@ int dfs_elm_write(struct dfs_fd *file, const void *buf, size_t len)
return elm_result_to_dfs(result);
}
int dfs_elm_flush(struct dfs_fd *file)
int dfs_elm_flush(struct dfs_file *file)
{
FIL *fd;
FRESULT result;
@ -596,7 +596,7 @@ int dfs_elm_flush(struct dfs_fd *file)
return elm_result_to_dfs(result);
}
int dfs_elm_lseek(struct dfs_fd *file, off_t offset)
int dfs_elm_lseek(struct dfs_file *file, off_t offset)
{
FRESULT result = FR_OK;
if (file->vnode->type == FT_REGULAR)
@ -635,7 +635,7 @@ int dfs_elm_lseek(struct dfs_fd *file, off_t offset)
return elm_result_to_dfs(result);
}
int dfs_elm_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
int dfs_elm_getdents(struct dfs_file *file, struct dirent *dirp, uint32_t count)
{
DIR *dir;
FILINFO fno;

View File

@ -546,12 +546,12 @@ int nfs_unmount(struct dfs_filesystem *fs)
return 0;
}
int nfs_ioctl(struct dfs_fd *file, int cmd, void *args)
int nfs_ioctl(struct dfs_file *file, int cmd, void *args)
{
return -ENOSYS;
}
int nfs_read(struct dfs_fd *file, void *buf, size_t count)
int nfs_read(struct dfs_file *file, void *buf, size_t count)
{
READ3args args;
READ3res res;
@ -620,7 +620,7 @@ int nfs_read(struct dfs_fd *file, void *buf, size_t count)
return total;
}
int nfs_write(struct dfs_fd *file, const void *buf, size_t count)
int nfs_write(struct dfs_file *file, const void *buf, size_t count)
{
WRITE3args args;
WRITE3res res;
@ -685,7 +685,7 @@ int nfs_write(struct dfs_fd *file, const void *buf, size_t count)
return total;
}
int nfs_lseek(struct dfs_fd *file, off_t offset)
int nfs_lseek(struct dfs_file *file, off_t offset)
{
nfs_file *fd;
nfs_filesystem *nfs;
@ -709,7 +709,7 @@ int nfs_lseek(struct dfs_fd *file, off_t offset)
return -EIO;
}
int nfs_close(struct dfs_fd *file)
int nfs_close(struct dfs_file *file)
{
nfs_filesystem *nfs;
RT_ASSERT(file->vnode->fs != NULL);
@ -746,7 +746,7 @@ int nfs_close(struct dfs_fd *file)
return 0;
}
int nfs_open(struct dfs_fd *file)
int nfs_open(struct dfs_file *file)
{
nfs_filesystem *nfs;
RT_ASSERT(file->vnode->fs != NULL);
@ -1103,7 +1103,7 @@ int nfs_rename(struct dfs_filesystem *fs, const char *src, const char *dest)
return ret;
}
int nfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
int nfs_getdents(struct dfs_file *file, struct dirent *dirp, uint32_t count)
{
nfs_dir *dir;
rt_uint32_t index;

View File

@ -54,7 +54,7 @@ int dfs_ramfs_statfs(struct dfs_filesystem *fs, struct statfs *buf)
return RT_EOK;
}
int dfs_ramfs_ioctl(struct dfs_fd *file, int cmd, void *args)
int dfs_ramfs_ioctl(struct dfs_file *file, int cmd, void *args)
{
return -EIO;
}
@ -92,7 +92,7 @@ struct ramfs_dirent *dfs_ramfs_lookup(struct dfs_ramfs *ramfs,
return NULL;
}
int dfs_ramfs_read(struct dfs_fd *file, void *buf, size_t count)
int dfs_ramfs_read(struct dfs_file *file, void *buf, size_t count)
{
rt_size_t length;
struct ramfs_dirent *dirent;
@ -114,7 +114,7 @@ int dfs_ramfs_read(struct dfs_fd *file, void *buf, size_t count)
return length;
}
int dfs_ramfs_write(struct dfs_fd *fd, const void *buf, size_t count)
int dfs_ramfs_write(struct dfs_file *fd, const void *buf, size_t count)
{
struct ramfs_dirent *dirent;
struct dfs_ramfs *ramfs;
@ -151,7 +151,7 @@ int dfs_ramfs_write(struct dfs_fd *fd, const void *buf, size_t count)
return count;
}
int dfs_ramfs_lseek(struct dfs_fd *file, off_t offset)
int dfs_ramfs_lseek(struct dfs_file *file, off_t offset)
{
if (offset <= (off_t)file->vnode->size)
{
@ -163,7 +163,7 @@ int dfs_ramfs_lseek(struct dfs_fd *file, off_t offset)
return -EIO;
}
int dfs_ramfs_close(struct dfs_fd *file)
int dfs_ramfs_close(struct dfs_file *file)
{
RT_ASSERT(file->vnode->ref_count > 0);
if (file->vnode->ref_count > 1)
@ -176,7 +176,7 @@ int dfs_ramfs_close(struct dfs_fd *file)
return RT_EOK;
}
int dfs_ramfs_open(struct dfs_fd *file)
int dfs_ramfs_open(struct dfs_file *file)
{
rt_size_t size;
struct dfs_ramfs *ramfs;
@ -316,7 +316,7 @@ int dfs_ramfs_stat(struct dfs_filesystem *fs,
return RT_EOK;
}
int dfs_ramfs_getdents(struct dfs_fd *file,
int dfs_ramfs_getdents(struct dfs_file *file,
struct dirent *dirp,
uint32_t count)
{

View File

@ -32,7 +32,7 @@ int dfs_romfs_unmount(struct dfs_filesystem *fs)
return RT_EOK;
}
int dfs_romfs_ioctl(struct dfs_fd *file, int cmd, void *args)
int dfs_romfs_ioctl(struct dfs_file *file, int cmd, void *args)
{
int ret = RT_EOK;
struct romfs_dirent *dirent;
@ -146,7 +146,7 @@ struct romfs_dirent *dfs_romfs_lookup(struct romfs_dirent *root_dirent, const ch
return NULL;
}
int dfs_romfs_read(struct dfs_fd *file, void *buf, size_t count)
int dfs_romfs_read(struct dfs_file *file, void *buf, size_t count)
{
rt_size_t length;
struct romfs_dirent *dirent;
@ -173,7 +173,7 @@ int dfs_romfs_read(struct dfs_fd *file, void *buf, size_t count)
return length;
}
int dfs_romfs_lseek(struct dfs_fd *file, off_t offset)
int dfs_romfs_lseek(struct dfs_file *file, off_t offset)
{
if (offset <= file->vnode->size)
{
@ -184,7 +184,7 @@ int dfs_romfs_lseek(struct dfs_fd *file, off_t offset)
return -EIO;
}
int dfs_romfs_close(struct dfs_fd *file)
int dfs_romfs_close(struct dfs_file *file)
{
RT_ASSERT(file->vnode->ref_count > 0);
if (file->vnode->ref_count > 1)
@ -195,7 +195,7 @@ int dfs_romfs_close(struct dfs_fd *file)
return RT_EOK;
}
int dfs_romfs_open(struct dfs_fd *file)
int dfs_romfs_open(struct dfs_file *file)
{
rt_size_t size;
struct romfs_dirent *dirent;
@ -294,7 +294,7 @@ int dfs_romfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
return RT_EOK;
}
int dfs_romfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
int dfs_romfs_getdents(struct dfs_file *file, struct dirent *dirp, uint32_t count)
{
rt_size_t index;
rt_size_t len;

View File

@ -24,27 +24,27 @@ int dfs_skt_unmount(struct dfs_filesystem *fs)
return RT_EOK;
}
int dfs_skt_ioctl(struct dfs_fd *file, int cmd, void *args)
int dfs_skt_ioctl(struct dfs_file *file, int cmd, void *args)
{
return -RT_EIO;
}
int dfs_skt_read(struct dfs_fd *file, void *buf, rt_size_t count)
int dfs_skt_read(struct dfs_file *file, void *buf, rt_size_t count)
{
return count;
}
int dfs_skt_lseek(struct dfs_fd *file, rt_off_t offset)
int dfs_skt_lseek(struct dfs_file *file, rt_off_t offset)
{
return -RT_EIO;
}
int dfs_skt_close(struct dfs_fd *file)
int dfs_skt_close(struct dfs_file *file)
{
return RT_EOK;
}
int dfs_skt_open(struct dfs_fd *file)
int dfs_skt_open(struct dfs_file *file)
{
return RT_EOK;
}
@ -54,7 +54,7 @@ int dfs_skt_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
return RT_EOK;
}
int dfs_skt_getdents(struct dfs_fd *file, struct dirent *dirp, rt_uint32_t count)
int dfs_skt_getdents(struct dfs_file *file, struct dirent *dirp, rt_uint32_t count)
{
return count * sizeof(struct dirent);
}

View File

@ -162,7 +162,7 @@ int dfs_tmpfs_statfs(struct dfs_filesystem *fs, struct statfs *buf)
return RT_EOK;
}
int dfs_tmpfs_ioctl(struct dfs_fd *file, int cmd, void *args)
int dfs_tmpfs_ioctl(struct dfs_file *file, int cmd, void *args)
{
struct tmpfs_file *d_file;
struct tmpfs_sb *superblock;
@ -263,7 +263,7 @@ find_subpath:
return NULL;
}
int dfs_tmpfs_read(struct dfs_fd *file, void *buf, size_t count)
int dfs_tmpfs_read(struct dfs_file *file, void *buf, size_t count)
{
rt_size_t length;
struct tmpfs_file *d_file;
@ -286,7 +286,7 @@ int dfs_tmpfs_read(struct dfs_fd *file, void *buf, size_t count)
}
int dfs_tmpfs_write(struct dfs_fd *fd, const void *buf, size_t count)
int dfs_tmpfs_write(struct dfs_file *fd, const void *buf, size_t count)
{
struct tmpfs_file *d_file;
struct tmpfs_sb *superblock;
@ -324,7 +324,7 @@ int dfs_tmpfs_write(struct dfs_fd *fd, const void *buf, size_t count)
return count;
}
int dfs_tmpfs_lseek(struct dfs_fd *file, off_t offset)
int dfs_tmpfs_lseek(struct dfs_file *file, off_t offset)
{
if (offset <= (off_t)file->vnode->size)
{
@ -336,7 +336,7 @@ int dfs_tmpfs_lseek(struct dfs_fd *file, off_t offset)
return -EIO;
}
int dfs_tmpfs_close(struct dfs_fd *file)
int dfs_tmpfs_close(struct dfs_file *file)
{
RT_ASSERT(file->vnode->ref_count > 0);
if (file->vnode->ref_count > 1)
@ -349,7 +349,7 @@ int dfs_tmpfs_close(struct dfs_fd *file)
return RT_EOK;
}
int dfs_tmpfs_open(struct dfs_fd *file)
int dfs_tmpfs_open(struct dfs_file *file)
{
rt_size_t size;
struct tmpfs_sb *superblock;
@ -498,7 +498,7 @@ int dfs_tmpfs_stat(struct dfs_filesystem *fs,
return RT_EOK;
}
int dfs_tmpfs_getdents(struct dfs_fd *file,
int dfs_tmpfs_getdents(struct dfs_file *file,
struct dirent *dirp,
uint32_t count)
{

View File

@ -72,7 +72,7 @@ extern "C" {
struct dfs_fdtable
{
uint32_t maxfd;
struct dfs_fd **fds;
struct dfs_file **fds;
};
/* Initialization of dfs */
@ -87,24 +87,26 @@ struct dfs_fdtable *dfs_fdtable_get(void);
void dfs_lock(void);
void dfs_unlock(void);
void dfs_fd_lock(void);
void dfs_fd_unlock(void);
void dfs_file_lock(void);
void dfs_file_unlock(void);
void dfs_fm_lock(void);
void dfs_fm_unlock(void);
#ifdef DFS_USING_POSIX
/* FD APIs */
int fdt_fd_new(struct dfs_fdtable *fdt);
struct dfs_fd *fdt_fd_get(struct dfs_fdtable* fdt, int fd);
struct dfs_file *fdt_fd_get(struct dfs_fdtable* fdt, int fd);
void fdt_fd_release(struct dfs_fdtable* fdt, int fd);
int fd_new(void);
int fd_associate(struct dfs_fdtable *fdt, int fd, struct dfs_fd *file);
struct dfs_fd *fd_get(int fd);
int fd_get_fd_index(struct dfs_fd *file);
struct dfs_file *fd_get(int fd);
void fd_release(int fd);
void fd_init(struct dfs_fd *fd);
void fd_init(struct dfs_file *fd);
int fd_associate(struct dfs_fdtable *fdt, int fd, struct dfs_file *file);
int fd_get_fd_index(struct dfs_file *file);
struct dfs_fdtable *dfs_fdtable_get(void);
struct dfs_fdtable *dfs_fdtable_get_global(void);

View File

@ -22,22 +22,22 @@ struct rt_pollreq;
struct dfs_file_ops
{
int (*open) (struct dfs_fd *fd);
int (*close) (struct dfs_fd *fd);
int (*ioctl) (struct dfs_fd *fd, int cmd, void *args);
int (*read) (struct dfs_fd *fd, void *buf, size_t count);
int (*write) (struct dfs_fd *fd, const void *buf, size_t count);
int (*flush) (struct dfs_fd *fd);
int (*lseek) (struct dfs_fd *fd, off_t offset);
int (*getdents) (struct dfs_fd *fd, struct dirent *dirp, uint32_t count);
int (*open) (struct dfs_file *fd);
int (*close) (struct dfs_file *fd);
int (*ioctl) (struct dfs_file *fd, int cmd, void *args);
int (*read) (struct dfs_file *fd, void *buf, size_t count);
int (*write) (struct dfs_file *fd, const void *buf, size_t count);
int (*flush) (struct dfs_file *fd);
int (*lseek) (struct dfs_file *fd, off_t offset);
int (*getdents) (struct dfs_file *fd, struct dirent *dirp, uint32_t count);
int (*poll) (struct dfs_fd *fd, struct rt_pollreq *req);
int (*poll) (struct dfs_file *fd, struct rt_pollreq *req);
};
/* file descriptor */
#define DFS_FD_MAGIC 0xfdfd
struct dfs_fnode
struct dfs_vnode
{
uint16_t type; /* Type (regular or socket) */
@ -54,13 +54,13 @@ struct dfs_fnode
void *data; /* Specific file system data */
};
struct dfs_fd
struct dfs_file
{
uint16_t magic; /* file descriptor magic number */
uint32_t flags; /* Descriptor flags */
int ref_count; /* Descriptor reference count */
off_t pos; /* Current file position */
struct dfs_fnode *vnode; /* file node struct */
struct dfs_vnode *vnode; /* file node struct */
void *data; /* Specific fd data */
};
@ -75,22 +75,22 @@ struct dfs_mmap2_args
void *ret;
};
void dfs_fnode_mgr_init(void);
void dfs_vnode_mgr_init(void);
int dfs_file_is_open(const char *pathname);
int dfs_file_open(struct dfs_fd *fd, const char *path, int flags);
int dfs_file_close(struct dfs_fd *fd);
int dfs_file_ioctl(struct dfs_fd *fd, int cmd, void *args);
int dfs_file_read(struct dfs_fd *fd, void *buf, size_t len);
int dfs_file_getdents(struct dfs_fd *fd, struct dirent *dirp, size_t nbytes);
int dfs_file_open(struct dfs_file *fd, const char *path, int flags);
int dfs_file_close(struct dfs_file *fd);
int dfs_file_ioctl(struct dfs_file *fd, int cmd, void *args);
int dfs_file_read(struct dfs_file *fd, void *buf, size_t len);
int dfs_file_getdents(struct dfs_file *fd, struct dirent *dirp, size_t nbytes);
int dfs_file_unlink(const char *path);
int dfs_file_write(struct dfs_fd *fd, const void *buf, size_t len);
int dfs_file_flush(struct dfs_fd *fd);
int dfs_file_lseek(struct dfs_fd *fd, off_t offset);
int dfs_file_write(struct dfs_file *fd, const void *buf, size_t len);
int dfs_file_flush(struct dfs_file *fd);
int dfs_file_lseek(struct dfs_file *fd, off_t offset);
int dfs_file_stat(const char *path, struct stat *buf);
int dfs_file_rename(const char *oldpath, const char *newpath);
int dfs_file_ftruncate(struct dfs_fd *fd, off_t length);
int dfs_file_mmap2(struct dfs_fd *fd, struct dfs_mmap2_args *mmap2);
int dfs_file_ftruncate(struct dfs_file *fd, off_t length);
int dfs_file_mmap2(struct dfs_file *fd, struct dfs_mmap2_args *mmap2);
/* 0x5254 is just a magic number to make these relatively unique ("RT") */
#define RT_FIOFTRUNCATE 0x52540000U

View File

@ -21,7 +21,7 @@ extern "C" {
/* Pre-declaration */
struct dfs_filesystem;
struct dfs_fd;
struct dfs_file;
/* File system operations */
struct dfs_filesystem_ops

View File

@ -57,7 +57,7 @@ int dfs_init(void)
}
/* init vnode hash table */
dfs_fnode_mgr_init();
dfs_vnode_mgr_init();
/* clear filesystem operations table */
rt_memset((void *)filesystem_operation_table, 0, sizeof(filesystem_operation_table));
@ -127,7 +127,7 @@ void dfs_lock(void)
}
}
void dfs_fd_lock(void)
void dfs_file_lock(void)
{
rt_err_t result = -RT_EBUSY;
@ -154,7 +154,7 @@ void dfs_unlock(void)
#ifdef DFS_USING_POSIX
void dfs_fd_unlock(void)
void dfs_file_unlock(void)
{
rt_mutex_release(&fdlock);
}
@ -163,7 +163,7 @@ static int fd_slot_expand(struct dfs_fdtable *fdt, int fd)
{
int nr;
int index;
struct dfs_fd **fds = NULL;
struct dfs_file **fds = NULL;
if (fd < fdt->maxfd)
{
@ -179,7 +179,7 @@ static int fd_slot_expand(struct dfs_fdtable *fdt, int fd)
{
nr = DFS_FD_MAX;
}
fds = (struct dfs_fd **)rt_realloc(fdt->fds, nr * sizeof(struct dfs_fd *));
fds = (struct dfs_file **)rt_realloc(fdt->fds, nr * sizeof(struct dfs_file *));
if (!fds)
{
return -1;
@ -223,16 +223,16 @@ static int fd_slot_alloc(struct dfs_fdtable *fdt, int startfd)
static int fd_alloc(struct dfs_fdtable *fdt, int startfd)
{
int idx;
struct dfs_fd *fd = NULL;
struct dfs_file *fd = NULL;
idx = fd_slot_alloc(fdt, startfd);
/* allocate 'struct dfs_fd' */
/* allocate 'struct dfs_file' */
if (idx < 0)
{
return -1;
}
fd = (struct dfs_fd *)rt_calloc(1, sizeof(struct dfs_fd));
fd = (struct dfs_file *)rt_calloc(1, sizeof(struct dfs_file));
if (!fd)
{
return -1;
@ -256,7 +256,7 @@ int fdt_fd_new(struct dfs_fdtable *fdt)
int idx;
/* lock filesystem */
dfs_fd_lock();
dfs_file_lock();
/* find an empty fd entry */
idx = fd_alloc(fdt, DFS_STDIO_OFFSET);
@ -267,7 +267,7 @@ int fdt_fd_new(struct dfs_fdtable *fdt)
LOG_E("DFS fd new is failed! Could not found an empty fd entry.");
}
dfs_fd_unlock();
dfs_file_unlock();
return idx;
}
@ -289,31 +289,31 @@ int fd_new(void)
* pointer.
*/
struct dfs_fd *fdt_fd_get(struct dfs_fdtable* fdt, int fd)
struct dfs_file *fdt_fd_get(struct dfs_fdtable* fdt, int fd)
{
struct dfs_fd *d;
struct dfs_file *d;
if (fd < 0 || fd >= (int)fdt->maxfd)
{
return NULL;
}
dfs_fd_lock();
dfs_file_lock();
d = fdt->fds[fd];
/* check dfs_fd valid or not */
/* check dfs_file valid or not */
if ((d == NULL) || (d->magic != DFS_FD_MAGIC))
{
dfs_fd_unlock();
dfs_file_unlock();
return NULL;
}
dfs_fd_unlock();
dfs_file_unlock();
return d;
}
struct dfs_fd *fd_get(int fd)
struct dfs_file *fd_get(int fd)
{
struct dfs_fdtable *fdt;
@ -328,22 +328,22 @@ struct dfs_fd *fd_get(int fd)
*/
void fdt_fd_release(struct dfs_fdtable* fdt, int fd)
{
struct dfs_fd *fd_slot = NULL;
struct dfs_file *fd_slot = NULL;
RT_ASSERT(fdt != NULL);
dfs_fd_lock();
dfs_file_lock();
if ((fd < 0) || (fd >= fdt->maxfd))
{
dfs_fd_unlock();
dfs_file_unlock();
return;
}
fd_slot = fdt->fds[fd];
if (fd_slot == NULL)
{
dfs_fd_unlock();
dfs_file_unlock();
return;
}
fdt->fds[fd] = NULL;
@ -356,14 +356,14 @@ void fdt_fd_release(struct dfs_fdtable* fdt, int fd)
/* clear this fd entry */
if (fd_slot->ref_count == 0)
{
struct dfs_fnode *vnode = fd_slot->vnode;
struct dfs_vnode *vnode = fd_slot->vnode;
if (vnode)
{
vnode->ref_count--;
}
rt_free(fd_slot);
}
dfs_fd_unlock();
dfs_file_unlock();
}
void fd_release(int fd)
@ -379,7 +379,7 @@ rt_err_t sys_dup(int oldfd)
int newfd = -1;
struct dfs_fdtable *fdt = NULL;
dfs_fd_lock();
dfs_file_lock();
/* check old fd */
fdt = dfs_fdtable_get();
if ((oldfd < 0) || (oldfd >= fdt->maxfd))
@ -399,7 +399,7 @@ rt_err_t sys_dup(int oldfd)
fdt->fds[newfd]->ref_count++;
}
exit:
dfs_fd_unlock();
dfs_file_unlock();
return newfd;
}
@ -419,7 +419,7 @@ int fd_is_open(const char *pathname)
char *fullpath;
unsigned int index;
struct dfs_filesystem *fs;
struct dfs_fd *fd;
struct dfs_file *fd;
struct dfs_fdtable *fdt;
fdt = dfs_fdtable_get();
@ -472,7 +472,7 @@ rt_err_t sys_dup2(int oldfd, int newfd)
int ret = 0;
int retfd = -1;
dfs_fd_lock();
dfs_file_lock();
/* check old fd */
fdt = dfs_fdtable_get();
if ((oldfd < 0) || (oldfd >= fdt->maxfd))
@ -517,11 +517,11 @@ rt_err_t sys_dup2(int oldfd, int newfd)
fdt->fds[newfd]->ref_count++;
retfd = newfd;
exit:
dfs_fd_unlock();
dfs_file_unlock();
return retfd;
}
static int fd_get_fd_index_form_fdt(struct dfs_fdtable *fdt, struct dfs_fd *file)
static int fd_get_fd_index_form_fdt(struct dfs_fdtable *fdt, struct dfs_file *file)
{
int fd = -1;
@ -530,7 +530,7 @@ static int fd_get_fd_index_form_fdt(struct dfs_fdtable *fdt, struct dfs_fd *file
return -1;
}
dfs_fd_lock();
dfs_file_lock();
for(int index = 0; index < (int)fdt->maxfd; index++)
{
@ -541,12 +541,12 @@ static int fd_get_fd_index_form_fdt(struct dfs_fdtable *fdt, struct dfs_fd *file
}
}
dfs_fd_unlock();
dfs_file_unlock();
return fd;
}
int fd_get_fd_index(struct dfs_fd *file)
int fd_get_fd_index(struct dfs_file *file)
{
struct dfs_fdtable *fdt;
@ -554,7 +554,7 @@ int fd_get_fd_index(struct dfs_fd *file)
return fd_get_fd_index_form_fdt(fdt, file);
}
int fd_associate(struct dfs_fdtable *fdt, int fd, struct dfs_fd *file)
int fd_associate(struct dfs_fdtable *fdt, int fd, struct dfs_file *file)
{
int retfd = -1;
@ -567,7 +567,7 @@ int fd_associate(struct dfs_fdtable *fdt, int fd, struct dfs_fd *file)
return retfd;
}
dfs_fd_lock();
dfs_file_lock();
/* check old fd */
if ((fd < 0) || (fd >= fdt->maxfd))
{
@ -583,11 +583,11 @@ int fd_associate(struct dfs_fdtable *fdt, int fd, struct dfs_fd *file)
fdt->fds[fd] = file;
retfd = fd;
exit:
dfs_fd_unlock();
dfs_file_unlock();
return retfd;
}
void fd_init(struct dfs_fd *fd)
void fd_init(struct dfs_file *fd)
{
if (fd)
{
@ -826,7 +826,7 @@ int list_fd(void)
rt_kprintf("-- ------ --- ----- ------\n");
for (index = 0; index < (int)fd_table->maxfd; index++)
{
struct dfs_fd *fd = fd_table->fds[index];
struct dfs_file *fd = fd_table->fds[index];
if (fd && fd->vnode->fops)
{
@ -880,7 +880,7 @@ static int lsofp(int pid)
rt_enter_critical();
for (index = 0; index < (int)fd_table->maxfd; index++)
{
struct dfs_fd *fd = fd_table->fds[index];
struct dfs_file *fd = fd_table->fds[index];
if (fd && fd->vnode->fops)
{

View File

@ -16,15 +16,15 @@
#include <dfs_private.h>
#include <unistd.h>
#define DFS_FNODE_HASH_NR 128
#define DFS_VNODE_HASH_NR 128
struct dfs_fnode_mgr
struct dfs_vnode_mgr
{
struct rt_mutex lock;
rt_list_t head[DFS_FNODE_HASH_NR];
rt_list_t head[DFS_VNODE_HASH_NR];
};
static struct dfs_fnode_mgr dfs_fm;
static struct dfs_vnode_mgr dfs_fm;
void dfs_fm_lock(void)
{
@ -36,12 +36,12 @@ void dfs_fm_unlock(void)
rt_mutex_release(&dfs_fm.lock);
}
void dfs_fnode_mgr_init(void)
void dfs_vnode_mgr_init(void)
{
int i = 0;
rt_mutex_init(&dfs_fm.lock, "dfs_mgr", RT_IPC_FLAG_PRIO);
for (i = 0; i < DFS_FNODE_HASH_NR; i++)
for (i = 0; i < DFS_VNODE_HASH_NR; i++)
{
rt_list_init(&dfs_fm.head[i]);
}
@ -58,12 +58,12 @@ static unsigned int bkdr_hash(const char *str)
hash = hash * seed + (*str++);
}
return (hash % DFS_FNODE_HASH_NR);
return (hash % DFS_VNODE_HASH_NR);
}
static struct dfs_fnode *dfs_fnode_find(const char *path, rt_list_t **hash_head)
static struct dfs_vnode *dfs_vnode_find(const char *path, rt_list_t **hash_head)
{
struct dfs_fnode *vnode = NULL;
struct dfs_vnode *vnode = NULL;
int hash = bkdr_hash(path);
rt_list_t *hh;
@ -76,7 +76,7 @@ static struct dfs_fnode *dfs_fnode_find(const char *path, rt_list_t **hash_head)
while (hh != &dfs_fm.head[hash])
{
vnode = rt_container_of(hh, struct dfs_fnode, list);
vnode = rt_container_of(hh, struct dfs_vnode, list);
if (rt_strcmp(path, vnode->fullpath) == 0)
{
/* found */
@ -103,13 +103,13 @@ static struct dfs_fnode *dfs_fnode_find(const char *path, rt_list_t **hash_head)
int dfs_file_is_open(const char *pathname)
{
char *fullpath = NULL;
struct dfs_fnode *vnode = NULL;
struct dfs_vnode *vnode = NULL;
int ret = 0;
fullpath = dfs_normalize_path(NULL, pathname);
dfs_fm_lock();
vnode = dfs_fnode_find(fullpath, NULL);
vnode = dfs_vnode_find(fullpath, NULL);
if (vnode)
{
ret = 1;
@ -130,12 +130,12 @@ int dfs_file_is_open(const char *pathname)
*
* @return 0 on successful, -1 on failed.
*/
int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
int dfs_file_open(struct dfs_file *fd, const char *path, int flags)
{
struct dfs_filesystem *fs;
char *fullpath;
int result;
struct dfs_fnode *vnode = NULL;
struct dfs_vnode *vnode = NULL;
rt_list_t *hash_head;
/* parameter check */
@ -153,7 +153,7 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
dfs_fm_lock();
/* vnode find */
vnode = dfs_fnode_find(fullpath, &hash_head);
vnode = dfs_vnode_find(fullpath, &hash_head);
if (vnode)
{
vnode->ref_count++;
@ -173,7 +173,7 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
return -ENOENT;
}
vnode = rt_calloc(1, sizeof(struct dfs_fnode));
vnode = rt_calloc(1, sizeof(struct dfs_vnode));
if (!vnode)
{
dfs_fm_unlock();
@ -270,9 +270,9 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
*
* @return 0 on successful, -1 on failed.
*/
int dfs_file_close(struct dfs_fd *fd)
int dfs_file_close(struct dfs_file *fd)
{
struct dfs_fnode *vnode = NULL;
struct dfs_vnode *vnode = NULL;
int result = 0;
if (fd == NULL)
@ -331,7 +331,7 @@ int dfs_file_close(struct dfs_fd *fd)
*
* @return 0 on successful, -1 on failed.
*/
int dfs_file_ioctl(struct dfs_fd *fd, int cmd, void *args)
int dfs_file_ioctl(struct dfs_file *fd, int cmd, void *args)
{
if (fd == NULL)
{
@ -376,7 +376,7 @@ int dfs_file_ioctl(struct dfs_fd *fd, int cmd, void *args)
*
* @return the actual read data bytes or 0 on end of file or failed.
*/
int dfs_file_read(struct dfs_fd *fd, void *buf, size_t len)
int dfs_file_read(struct dfs_file *fd, void *buf, size_t len)
{
int result = 0;
@ -407,7 +407,7 @@ int dfs_file_read(struct dfs_fd *fd, void *buf, size_t len)
*
* @return the read dirent, others on failed.
*/
int dfs_file_getdents(struct dfs_fd *fd, struct dirent *dirp, size_t nbytes)
int dfs_file_getdents(struct dfs_file *fd, struct dirent *dirp, size_t nbytes)
{
/* parameter check */
if (fd == NULL)
@ -490,7 +490,7 @@ __exit:
*
* @return the actual written data length.
*/
int dfs_file_write(struct dfs_fd *fd, const void *buf, size_t len)
int dfs_file_write(struct dfs_file *fd, const void *buf, size_t len)
{
if (fd == NULL)
{
@ -512,7 +512,7 @@ int dfs_file_write(struct dfs_fd *fd, const void *buf, size_t len)
*
* @return 0 on successful, -1 on failed.
*/
int dfs_file_flush(struct dfs_fd *fd)
int dfs_file_flush(struct dfs_file *fd)
{
if (fd == NULL)
return -EINVAL;
@ -531,7 +531,7 @@ int dfs_file_flush(struct dfs_fd *fd)
*
* @return the current position after seek.
*/
int dfs_file_lseek(struct dfs_fd *fd, off_t offset)
int dfs_file_lseek(struct dfs_file *fd, off_t offset)
{
int result;
@ -703,7 +703,7 @@ __exit:
*
* @return the status of truncated.
*/
int dfs_file_ftruncate(struct dfs_fd *fd, off_t length)
int dfs_file_ftruncate(struct dfs_file *fd, off_t length)
{
int result;
@ -723,7 +723,7 @@ int dfs_file_ftruncate(struct dfs_fd *fd, off_t length)
return result;
}
int dfs_file_mmap2(struct dfs_fd *fd, struct dfs_mmap2_args *mmap2)
int dfs_file_mmap2(struct dfs_file *fd, struct dfs_mmap2_args *mmap2)
{
int ret = 0;
@ -752,7 +752,7 @@ int dfs_file_mmap2(struct dfs_fd *fd, struct dfs_mmap2_args *mmap2)
void ls(const char *pathname)
{
struct dfs_fd fd;
struct dfs_file fd;
struct dirent dirent;
struct stat stat;
int length;
@ -834,7 +834,7 @@ FINSH_FUNCTION_EXPORT(rm, remove files or directories);
void cat(const char *filename)
{
struct dfs_fd fd;
struct dfs_file fd;
int length = 0;
char buffer[81];
@ -867,8 +867,8 @@ FINSH_FUNCTION_EXPORT(cat, print file);
#define BUF_SZ 4096
static void copyfile(const char *src, const char *dst)
{
struct dfs_fd fd;
struct dfs_fd src_fd;
struct dfs_file fd;
struct dfs_file src_fd;
rt_uint8_t *block_ptr;
rt_int32_t read_bytes;
@ -928,7 +928,7 @@ static void copydir(const char *src, const char *dst)
struct dirent dirent;
struct stat stat;
int length;
struct dfs_fd cpfd;
struct dfs_file cpfd;
if (dfs_file_open(&cpfd, src, O_DIRECTORY) < 0)
{
rt_kprintf("open %s failed\n", src);

View File

@ -271,7 +271,7 @@ int dfs_mount(const char *device_name,
/* Check if the path exists or not, raw APIs call, fixme */
if ((strcmp(fullpath, "/") != 0) && (strcmp(fullpath, "/dev") != 0))
{
struct dfs_fd fd;
struct dfs_file fd;
fd_init(&fd);
if (dfs_file_open(&fd, fullpath, O_RDONLY | O_DIRECTORY) < 0)

View File

@ -36,7 +36,7 @@
int open(const char *file, int flags, ...)
{
int fd, result;
struct dfs_fd *d;
struct dfs_file *d;
/* allocate a fd */
fd = fd_new();
@ -89,7 +89,7 @@ RTM_EXPORT(creat);
int close(int fd)
{
int result;
struct dfs_fd *d;
struct dfs_file *d;
d = fd_get(fd);
if (d == NULL)
@ -132,7 +132,7 @@ ssize_t read(int fd, void *buf, size_t len)
#endif
{
int result;
struct dfs_fd *d;
struct dfs_file *d;
/* get the fd */
d = fd_get(fd);
@ -172,7 +172,7 @@ ssize_t write(int fd, const void *buf, size_t len)
#endif
{
int result;
struct dfs_fd *d;
struct dfs_file *d;
/* get the fd */
d = fd_get(fd);
@ -208,7 +208,7 @@ RTM_EXPORT(write);
off_t lseek(int fd, off_t offset, int whence)
{
int result;
struct dfs_fd *d;
struct dfs_file *d;
d = fd_get(fd);
if (d == NULL)
@ -342,7 +342,7 @@ RTM_EXPORT(stat);
*/
int fstat(int fildes, struct stat *buf)
{
struct dfs_fd *d;
struct dfs_file *d;
/* get the fd */
d = fd_get(fildes);
@ -370,7 +370,7 @@ RTM_EXPORT(fstat);
int fsync(int fildes)
{
int ret;
struct dfs_fd *d;
struct dfs_file *d;
/* get the fd */
d = fd_get(fildes);
@ -401,7 +401,7 @@ RTM_EXPORT(fsync);
int fcntl(int fildes, int cmd, ...)
{
int ret = -1;
struct dfs_fd *d;
struct dfs_file *d;
/* get the fd */
d = fd_get(fildes);
@ -467,7 +467,7 @@ RTM_EXPORT(ioctl);
int ftruncate(int fd, off_t length)
{
int result;
struct dfs_fd *d;
struct dfs_file *d;
d = fd_get(fd);
if (d == NULL)
@ -531,7 +531,7 @@ RTM_EXPORT(statfs);
*/
int fstatfs(int fildes, struct statfs *buf)
{
struct dfs_fd *d;
struct dfs_file *d;
/* get the fd */
d = fd_get(fildes);
@ -557,7 +557,7 @@ RTM_EXPORT(fstatfs);
int mkdir(const char *path, mode_t mode)
{
int fd;
struct dfs_fd *d;
struct dfs_file *d;
int result;
fd = fd_new();
@ -619,7 +619,7 @@ RTM_EXPORT(rmdir);
*/
DIR *opendir(const char *name)
{
struct dfs_fd *d;
struct dfs_file *d;
int fd, result;
DIR *t;
@ -675,7 +675,7 @@ RTM_EXPORT(opendir);
struct dirent *readdir(DIR *d)
{
int result;
struct dfs_fd *fd;
struct dfs_file *fd;
fd = fd_get(d->fd);
if (fd == NULL)
@ -722,7 +722,7 @@ RTM_EXPORT(readdir);
*/
long telldir(DIR *d)
{
struct dfs_fd *fd;
struct dfs_file *fd;
long result;
fd = fd_get(d->fd);
@ -748,7 +748,7 @@ RTM_EXPORT(telldir);
*/
void seekdir(DIR *d, long offset)
{
struct dfs_fd *fd;
struct dfs_file *fd;
fd = fd_get(d->fd);
if (fd == NULL)
@ -772,7 +772,7 @@ RTM_EXPORT(seekdir);
*/
void rewinddir(DIR *d)
{
struct dfs_fd *fd;
struct dfs_file *fd;
fd = fd_get(d->fd);
if (fd == NULL)
@ -799,7 +799,7 @@ RTM_EXPORT(rewinddir);
int closedir(DIR *d)
{
int result;
struct dfs_fd *fd;
struct dfs_file *fd;
fd = fd_get(d->fd);
if (fd == NULL)

View File

@ -564,7 +564,7 @@ static int dfs_cromfs_unmount(struct dfs_filesystem *fs)
return RT_EOK;
}
static int dfs_cromfs_ioctl(struct dfs_fd *file, int cmd, void *args)
static int dfs_cromfs_ioctl(struct dfs_file *file, int cmd, void *args)
{
return -EIO;
}
@ -718,7 +718,7 @@ end:
return ret;
}
static int dfs_cromfs_read(struct dfs_fd *file, void *buf, size_t count)
static int dfs_cromfs_read(struct dfs_file *file, void *buf, size_t count)
{
rt_err_t result = RT_EOK;
struct dfs_filesystem *fs = NULL;
@ -788,7 +788,7 @@ static int dfs_cromfs_read(struct dfs_fd *file, void *buf, size_t count)
return length;
}
static int dfs_cromfs_lseek(struct dfs_fd *file, off_t offset)
static int dfs_cromfs_lseek(struct dfs_file *file, off_t offset)
{
if (offset <= file->vnode->size)
{
@ -890,7 +890,7 @@ static void deref_file_info(cromfs_info *ci, uint32_t partition_pos)
}
}
static int dfs_cromfs_close(struct dfs_fd *file)
static int dfs_cromfs_close(struct dfs_file *file)
{
file_info *fi = NULL;
struct dfs_filesystem *fs = NULL;
@ -918,7 +918,7 @@ static int dfs_cromfs_close(struct dfs_fd *file)
return RT_EOK;
}
static int dfs_cromfs_open(struct dfs_fd *file)
static int dfs_cromfs_open(struct dfs_file *file)
{
int ret = 0;
struct dfs_filesystem *fs = NULL;
@ -1047,7 +1047,7 @@ static int dfs_cromfs_stat(struct dfs_filesystem *fs, const char *path, struct s
return RT_EOK;
}
static int dfs_cromfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
static int dfs_cromfs_getdents(struct dfs_file *file, struct dirent *dirp, uint32_t count)
{
uint32_t index = 0;
uint8_t *name = NULL;

View File

@ -39,7 +39,7 @@ int dfs_device_fs_statfs(struct dfs_filesystem *fs, struct statfs *buf)
return RT_EOK;
}
int dfs_device_fs_ioctl(struct dfs_fd *file, int cmd, void *args)
int dfs_device_fs_ioctl(struct dfs_file *file, int cmd, void *args)
{
rt_err_t result;
rt_device_t dev_id;
@ -61,7 +61,7 @@ int dfs_device_fs_ioctl(struct dfs_fd *file, int cmd, void *args)
return result;
}
int dfs_device_fs_read(struct dfs_fd *file, void *buf, size_t count)
int dfs_device_fs_read(struct dfs_file *file, void *buf, size_t count)
{
int result;
rt_device_t dev_id;
@ -82,7 +82,7 @@ int dfs_device_fs_read(struct dfs_fd *file, void *buf, size_t count)
return result;
}
int dfs_device_fs_write(struct dfs_fd *file, const void *buf, size_t count)
int dfs_device_fs_write(struct dfs_file *file, const void *buf, size_t count)
{
int result;
rt_device_t dev_id;
@ -103,7 +103,7 @@ int dfs_device_fs_write(struct dfs_fd *file, const void *buf, size_t count)
return result;
}
int dfs_device_fs_close(struct dfs_fd *file)
int dfs_device_fs_close(struct dfs_file *file)
{
rt_err_t result;
rt_device_t dev_id;
@ -144,7 +144,7 @@ int dfs_device_fs_close(struct dfs_fd *file)
return -EIO;
}
int dfs_device_fs_open(struct dfs_fd *file)
int dfs_device_fs_open(struct dfs_file *file)
{
rt_err_t result;
rt_device_t device;
@ -334,7 +334,7 @@ int dfs_device_fs_stat(struct dfs_filesystem *fs, const char *path, struct stat
return -ENOENT;
}
int dfs_device_fs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
int dfs_device_fs_getdents(struct dfs_file *file, struct dirent *dirp, uint32_t count)
{
rt_uint32_t index;
rt_object_t object;
@ -373,7 +373,7 @@ int dfs_device_fs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t co
return index * sizeof(struct dirent);
}
static int dfs_device_fs_poll(struct dfs_fd *fd, struct rt_pollreq *req)
static int dfs_device_fs_poll(struct dfs_file *fd, struct rt_pollreq *req)
{
int mask = 0;

View File

@ -328,7 +328,7 @@ int dfs_elm_statfs(struct dfs_filesystem *fs, struct statfs *buf)
return 0;
}
int dfs_elm_open(struct dfs_fd *file)
int dfs_elm_open(struct dfs_file *file)
{
FIL *fd;
BYTE mode;
@ -464,7 +464,7 @@ int dfs_elm_open(struct dfs_fd *file)
return RT_EOK;
}
int dfs_elm_close(struct dfs_fd *file)
int dfs_elm_close(struct dfs_file *file)
{
FRESULT result;
@ -501,7 +501,7 @@ int dfs_elm_close(struct dfs_fd *file)
return elm_result_to_dfs(result);
}
int dfs_elm_ioctl(struct dfs_fd *file, int cmd, void *args)
int dfs_elm_ioctl(struct dfs_file *file, int cmd, void *args)
{
switch (cmd)
{
@ -537,7 +537,7 @@ int dfs_elm_ioctl(struct dfs_fd *file, int cmd, void *args)
return -ENOSYS;
}
int dfs_elm_read(struct dfs_fd *file, void *buf, size_t len)
int dfs_elm_read(struct dfs_file *file, void *buf, size_t len)
{
FIL *fd;
FRESULT result;
@ -560,7 +560,7 @@ int dfs_elm_read(struct dfs_fd *file, void *buf, size_t len)
return elm_result_to_dfs(result);
}
int dfs_elm_write(struct dfs_fd *file, const void *buf, size_t len)
int dfs_elm_write(struct dfs_file *file, const void *buf, size_t len)
{
FIL *fd;
FRESULT result;
@ -584,7 +584,7 @@ int dfs_elm_write(struct dfs_fd *file, const void *buf, size_t len)
return elm_result_to_dfs(result);
}
int dfs_elm_flush(struct dfs_fd *file)
int dfs_elm_flush(struct dfs_file *file)
{
FIL *fd;
FRESULT result;
@ -596,7 +596,7 @@ int dfs_elm_flush(struct dfs_fd *file)
return elm_result_to_dfs(result);
}
int dfs_elm_lseek(struct dfs_fd *file, off_t offset)
int dfs_elm_lseek(struct dfs_file *file, off_t offset)
{
FRESULT result = FR_OK;
if (file->vnode->type == FT_REGULAR)
@ -635,7 +635,7 @@ int dfs_elm_lseek(struct dfs_fd *file, off_t offset)
return elm_result_to_dfs(result);
}
int dfs_elm_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
int dfs_elm_getdents(struct dfs_file *file, struct dirent *dirp, uint32_t count)
{
DIR *dir;
FILINFO fno;

View File

@ -546,12 +546,12 @@ int nfs_unmount(struct dfs_filesystem *fs)
return 0;
}
int nfs_ioctl(struct dfs_fd *file, int cmd, void *args)
int nfs_ioctl(struct dfs_file *file, int cmd, void *args)
{
return -ENOSYS;
}
int nfs_read(struct dfs_fd *file, void *buf, size_t count)
int nfs_read(struct dfs_file *file, void *buf, size_t count)
{
READ3args args;
READ3res res;
@ -620,7 +620,7 @@ int nfs_read(struct dfs_fd *file, void *buf, size_t count)
return total;
}
int nfs_write(struct dfs_fd *file, const void *buf, size_t count)
int nfs_write(struct dfs_file *file, const void *buf, size_t count)
{
WRITE3args args;
WRITE3res res;
@ -685,7 +685,7 @@ int nfs_write(struct dfs_fd *file, const void *buf, size_t count)
return total;
}
int nfs_lseek(struct dfs_fd *file, off_t offset)
int nfs_lseek(struct dfs_file *file, off_t offset)
{
nfs_file *fd;
nfs_filesystem *nfs;
@ -709,7 +709,7 @@ int nfs_lseek(struct dfs_fd *file, off_t offset)
return -EIO;
}
int nfs_close(struct dfs_fd *file)
int nfs_close(struct dfs_file *file)
{
nfs_filesystem *nfs;
RT_ASSERT(file->vnode->fs != NULL);
@ -746,7 +746,7 @@ int nfs_close(struct dfs_fd *file)
return 0;
}
int nfs_open(struct dfs_fd *file)
int nfs_open(struct dfs_file *file)
{
nfs_filesystem *nfs;
RT_ASSERT(file->vnode->fs != NULL);
@ -1103,7 +1103,7 @@ int nfs_rename(struct dfs_filesystem *fs, const char *src, const char *dest)
return ret;
}
int nfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
int nfs_getdents(struct dfs_file *file, struct dirent *dirp, uint32_t count)
{
nfs_dir *dir;
rt_uint32_t index;

View File

@ -54,7 +54,7 @@ int dfs_ramfs_statfs(struct dfs_filesystem *fs, struct statfs *buf)
return RT_EOK;
}
int dfs_ramfs_ioctl(struct dfs_fd *file, int cmd, void *args)
int dfs_ramfs_ioctl(struct dfs_file *file, int cmd, void *args)
{
return -EIO;
}
@ -92,7 +92,7 @@ struct ramfs_dirent *dfs_ramfs_lookup(struct dfs_ramfs *ramfs,
return NULL;
}
int dfs_ramfs_read(struct dfs_fd *file, void *buf, size_t count)
int dfs_ramfs_read(struct dfs_file *file, void *buf, size_t count)
{
rt_size_t length;
struct ramfs_dirent *dirent;
@ -114,7 +114,7 @@ int dfs_ramfs_read(struct dfs_fd *file, void *buf, size_t count)
return length;
}
int dfs_ramfs_write(struct dfs_fd *fd, const void *buf, size_t count)
int dfs_ramfs_write(struct dfs_file *fd, const void *buf, size_t count)
{
struct ramfs_dirent *dirent;
struct dfs_ramfs *ramfs;
@ -151,7 +151,7 @@ int dfs_ramfs_write(struct dfs_fd *fd, const void *buf, size_t count)
return count;
}
int dfs_ramfs_lseek(struct dfs_fd *file, off_t offset)
int dfs_ramfs_lseek(struct dfs_file *file, off_t offset)
{
if (offset <= (off_t)file->vnode->size)
{
@ -163,7 +163,7 @@ int dfs_ramfs_lseek(struct dfs_fd *file, off_t offset)
return -EIO;
}
int dfs_ramfs_close(struct dfs_fd *file)
int dfs_ramfs_close(struct dfs_file *file)
{
RT_ASSERT(file->vnode->ref_count > 0);
if (file->vnode->ref_count > 1)
@ -176,7 +176,7 @@ int dfs_ramfs_close(struct dfs_fd *file)
return RT_EOK;
}
int dfs_ramfs_open(struct dfs_fd *file)
int dfs_ramfs_open(struct dfs_file *file)
{
rt_size_t size;
struct dfs_ramfs *ramfs;
@ -316,7 +316,7 @@ int dfs_ramfs_stat(struct dfs_filesystem *fs,
return RT_EOK;
}
int dfs_ramfs_getdents(struct dfs_fd *file,
int dfs_ramfs_getdents(struct dfs_file *file,
struct dirent *dirp,
uint32_t count)
{

View File

@ -32,7 +32,7 @@ int dfs_romfs_unmount(struct dfs_filesystem *fs)
return RT_EOK;
}
int dfs_romfs_ioctl(struct dfs_fd *file, int cmd, void *args)
int dfs_romfs_ioctl(struct dfs_file *file, int cmd, void *args)
{
int ret = RT_EOK;
struct romfs_dirent *dirent;
@ -146,7 +146,7 @@ struct romfs_dirent *dfs_romfs_lookup(struct romfs_dirent *root_dirent, const ch
return NULL;
}
int dfs_romfs_read(struct dfs_fd *file, void *buf, size_t count)
int dfs_romfs_read(struct dfs_file *file, void *buf, size_t count)
{
rt_size_t length;
struct romfs_dirent *dirent;
@ -173,7 +173,7 @@ int dfs_romfs_read(struct dfs_fd *file, void *buf, size_t count)
return length;
}
int dfs_romfs_lseek(struct dfs_fd *file, off_t offset)
int dfs_romfs_lseek(struct dfs_file *file, off_t offset)
{
if (offset <= file->vnode->size)
{
@ -184,7 +184,7 @@ int dfs_romfs_lseek(struct dfs_fd *file, off_t offset)
return -EIO;
}
int dfs_romfs_close(struct dfs_fd *file)
int dfs_romfs_close(struct dfs_file *file)
{
RT_ASSERT(file->vnode->ref_count > 0);
if (file->vnode->ref_count > 1)
@ -195,7 +195,7 @@ int dfs_romfs_close(struct dfs_fd *file)
return RT_EOK;
}
int dfs_romfs_open(struct dfs_fd *file)
int dfs_romfs_open(struct dfs_file *file)
{
rt_size_t size;
struct romfs_dirent *dirent;
@ -294,7 +294,7 @@ int dfs_romfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
return RT_EOK;
}
int dfs_romfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
int dfs_romfs_getdents(struct dfs_file *file, struct dirent *dirp, uint32_t count)
{
rt_size_t index;
rt_size_t len;

View File

@ -24,27 +24,27 @@ int dfs_skt_unmount(struct dfs_filesystem *fs)
return RT_EOK;
}
int dfs_skt_ioctl(struct dfs_fd *file, int cmd, void *args)
int dfs_skt_ioctl(struct dfs_file *file, int cmd, void *args)
{
return -RT_EIO;
}
int dfs_skt_read(struct dfs_fd *file, void *buf, rt_size_t count)
int dfs_skt_read(struct dfs_file *file, void *buf, rt_size_t count)
{
return count;
}
int dfs_skt_lseek(struct dfs_fd *file, rt_off_t offset)
int dfs_skt_lseek(struct dfs_file *file, rt_off_t offset)
{
return -RT_EIO;
}
int dfs_skt_close(struct dfs_fd *file)
int dfs_skt_close(struct dfs_file *file)
{
return RT_EOK;
}
int dfs_skt_open(struct dfs_fd *file)
int dfs_skt_open(struct dfs_file *file)
{
return RT_EOK;
}
@ -54,7 +54,7 @@ int dfs_skt_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
return RT_EOK;
}
int dfs_skt_getdents(struct dfs_fd *file, struct dirent *dirp, rt_uint32_t count)
int dfs_skt_getdents(struct dfs_file *file, struct dirent *dirp, rt_uint32_t count)
{
return count * sizeof(struct dirent);
}

View File

@ -162,7 +162,7 @@ int dfs_tmpfs_statfs(struct dfs_filesystem *fs, struct statfs *buf)
return RT_EOK;
}
int dfs_tmpfs_ioctl(struct dfs_fd *file, int cmd, void *args)
int dfs_tmpfs_ioctl(struct dfs_file *file, int cmd, void *args)
{
struct tmpfs_file *d_file;
struct tmpfs_sb *superblock;
@ -263,7 +263,7 @@ find_subpath:
return NULL;
}
int dfs_tmpfs_read(struct dfs_fd *file, void *buf, size_t count)
int dfs_tmpfs_read(struct dfs_file *file, void *buf, size_t count)
{
rt_size_t length;
struct tmpfs_file *d_file;
@ -286,7 +286,7 @@ int dfs_tmpfs_read(struct dfs_fd *file, void *buf, size_t count)
}
int dfs_tmpfs_write(struct dfs_fd *fd, const void *buf, size_t count)
int dfs_tmpfs_write(struct dfs_file *fd, const void *buf, size_t count)
{
struct tmpfs_file *d_file;
struct tmpfs_sb *superblock;
@ -324,7 +324,7 @@ int dfs_tmpfs_write(struct dfs_fd *fd, const void *buf, size_t count)
return count;
}
int dfs_tmpfs_lseek(struct dfs_fd *file, off_t offset)
int dfs_tmpfs_lseek(struct dfs_file *file, off_t offset)
{
if (offset <= (off_t)file->vnode->size)
{
@ -336,7 +336,7 @@ int dfs_tmpfs_lseek(struct dfs_fd *file, off_t offset)
return -EIO;
}
int dfs_tmpfs_close(struct dfs_fd *file)
int dfs_tmpfs_close(struct dfs_file *file)
{
RT_ASSERT(file->vnode->ref_count > 0);
if (file->vnode->ref_count > 1)
@ -349,7 +349,7 @@ int dfs_tmpfs_close(struct dfs_fd *file)
return RT_EOK;
}
int dfs_tmpfs_open(struct dfs_fd *file)
int dfs_tmpfs_open(struct dfs_file *file)
{
rt_size_t size;
struct tmpfs_sb *superblock;
@ -498,7 +498,7 @@ int dfs_tmpfs_stat(struct dfs_filesystem *fs,
return RT_EOK;
}
int dfs_tmpfs_getdents(struct dfs_fd *file,
int dfs_tmpfs_getdents(struct dfs_file *file,
struct dirent *dirp,
uint32_t count)
{

View File

@ -72,7 +72,7 @@ extern "C" {
struct dfs_fdtable
{
uint32_t maxfd;
struct dfs_fd **fds;
struct dfs_file **fds;
};
/* Initialization of dfs */
@ -87,8 +87,8 @@ struct dfs_fdtable *dfs_fdtable_get(void);
void dfs_lock(void);
void dfs_unlock(void);
void dfs_fd_lock(void);
void dfs_fd_unlock(void);
void dfs_file_lock(void);
void dfs_file_unlock(void);
void dfs_fm_lock(void);
void dfs_fm_unlock(void);
@ -96,15 +96,15 @@ void dfs_fm_unlock(void);
#ifdef DFS_USING_POSIX
/* FD APIs */
int fdt_fd_new(struct dfs_fdtable *fdt);
struct dfs_fd *fdt_fd_get(struct dfs_fdtable* fdt, int fd);
struct dfs_file *fdt_fd_get(struct dfs_fdtable* fdt, int fd);
void fdt_fd_release(struct dfs_fdtable* fdt, int fd);
int fd_new(void);
int fd_associate(struct dfs_fdtable *fdt, int fd, struct dfs_fd *file);
struct dfs_fd *fd_get(int fd);
int fd_get_fd_index(struct dfs_fd *file);
int fd_associate(struct dfs_fdtable *fdt, int fd, struct dfs_file *file);
struct dfs_file *fd_get(int fd);
int fd_get_fd_index(struct dfs_file *file);
void fd_release(int fd);
void fd_init(struct dfs_fd *fd);
void fd_init(struct dfs_file *fd);
struct dfs_fdtable *dfs_fdtable_get(void);
struct dfs_fdtable *dfs_fdtable_get_global(void);

View File

@ -22,22 +22,22 @@ struct rt_pollreq;
struct dfs_file_ops
{
int (*open) (struct dfs_fd *fd);
int (*close) (struct dfs_fd *fd);
int (*ioctl) (struct dfs_fd *fd, int cmd, void *args);
int (*read) (struct dfs_fd *fd, void *buf, size_t count);
int (*write) (struct dfs_fd *fd, const void *buf, size_t count);
int (*flush) (struct dfs_fd *fd);
int (*lseek) (struct dfs_fd *fd, off_t offset);
int (*getdents) (struct dfs_fd *fd, struct dirent *dirp, uint32_t count);
int (*open) (struct dfs_file *fd);
int (*close) (struct dfs_file *fd);
int (*ioctl) (struct dfs_file *fd, int cmd, void *args);
int (*read) (struct dfs_file *fd, void *buf, size_t count);
int (*write) (struct dfs_file *fd, const void *buf, size_t count);
int (*flush) (struct dfs_file *fd);
int (*lseek) (struct dfs_file *fd, off_t offset);
int (*getdents) (struct dfs_file *fd, struct dirent *dirp, uint32_t count);
int (*poll) (struct dfs_fd *fd, struct rt_pollreq *req);
int (*poll) (struct dfs_file *fd, struct rt_pollreq *req);
};
/* file descriptor */
#define DFS_FD_MAGIC 0xfdfd
struct dfs_fnode
struct dfs_vnode
{
uint16_t type; /* Type (regular or socket) */
@ -54,13 +54,13 @@ struct dfs_fnode
void *data; /* Specific file system data */
};
struct dfs_fd
struct dfs_file
{
uint16_t magic; /* file descriptor magic number */
uint32_t flags; /* Descriptor flags */
int ref_count; /* Descriptor reference count */
off_t pos; /* Current file position */
struct dfs_fnode *vnode; /* file node struct */
struct dfs_vnode *vnode; /* file node struct */
void *data; /* Specific fd data */
};
@ -75,22 +75,22 @@ struct dfs_mmap2_args
void *ret;
};
void dfs_fnode_mgr_init(void);
void dfs_vnode_mgr_init(void);
int dfs_file_is_open(const char *pathname);
int dfs_file_open(struct dfs_fd *fd, const char *path, int flags);
int dfs_file_close(struct dfs_fd *fd);
int dfs_file_ioctl(struct dfs_fd *fd, int cmd, void *args);
int dfs_file_read(struct dfs_fd *fd, void *buf, size_t len);
int dfs_file_getdents(struct dfs_fd *fd, struct dirent *dirp, size_t nbytes);
int dfs_file_open(struct dfs_file *fd, const char *path, int flags);
int dfs_file_close(struct dfs_file *fd);
int dfs_file_ioctl(struct dfs_file *fd, int cmd, void *args);
int dfs_file_read(struct dfs_file *fd, void *buf, size_t len);
int dfs_file_getdents(struct dfs_file *fd, struct dirent *dirp, size_t nbytes);
int dfs_file_unlink(const char *path);
int dfs_file_write(struct dfs_fd *fd, const void *buf, size_t len);
int dfs_file_flush(struct dfs_fd *fd);
int dfs_file_lseek(struct dfs_fd *fd, off_t offset);
int dfs_file_write(struct dfs_file *fd, const void *buf, size_t len);
int dfs_file_flush(struct dfs_file *fd);
int dfs_file_lseek(struct dfs_file *fd, off_t offset);
int dfs_file_stat(const char *path, struct stat *buf);
int dfs_file_rename(const char *oldpath, const char *newpath);
int dfs_file_ftruncate(struct dfs_fd *fd, off_t length);
int dfs_file_mmap2(struct dfs_fd *fd, struct dfs_mmap2_args *mmap2);
int dfs_file_ftruncate(struct dfs_file *fd, off_t length);
int dfs_file_mmap2(struct dfs_file *fd, struct dfs_mmap2_args *mmap2);
/* 0x5254 is just a magic number to make these relatively unique ("RT") */
#define RT_FIOFTRUNCATE 0x52540000U

View File

@ -21,7 +21,7 @@ extern "C" {
/* Pre-declaration */
struct dfs_filesystem;
struct dfs_fd;
struct dfs_file;
/* File system operations */
struct dfs_filesystem_ops

View File

@ -57,7 +57,7 @@ int dfs_init(void)
}
/* init vnode hash table */
dfs_fnode_mgr_init();
dfs_vnode_mgr_init();
/* clear filesystem operations table */
rt_memset((void *)filesystem_operation_table, 0, sizeof(filesystem_operation_table));
@ -127,7 +127,7 @@ void dfs_lock(void)
}
}
void dfs_fd_lock(void)
void dfs_file_lock(void)
{
rt_err_t result = -RT_EBUSY;
@ -154,7 +154,7 @@ void dfs_unlock(void)
#ifdef DFS_USING_POSIX
void dfs_fd_unlock(void)
void dfs_file_unlock(void)
{
rt_mutex_release(&fdlock);
}
@ -163,7 +163,7 @@ static int fd_slot_expand(struct dfs_fdtable *fdt, int fd)
{
int nr;
int index;
struct dfs_fd **fds = NULL;
struct dfs_file **fds = NULL;
if (fd < fdt->maxfd)
{
@ -179,7 +179,7 @@ static int fd_slot_expand(struct dfs_fdtable *fdt, int fd)
{
nr = DFS_FD_MAX;
}
fds = (struct dfs_fd **)rt_realloc(fdt->fds, nr * sizeof(struct dfs_fd *));
fds = (struct dfs_file **)rt_realloc(fdt->fds, nr * sizeof(struct dfs_file *));
if (!fds)
{
return -1;
@ -223,16 +223,16 @@ static int fd_slot_alloc(struct dfs_fdtable *fdt, int startfd)
static int fd_alloc(struct dfs_fdtable *fdt, int startfd)
{
int idx;
struct dfs_fd *fd = NULL;
struct dfs_file *fd = NULL;
idx = fd_slot_alloc(fdt, startfd);
/* allocate 'struct dfs_fd' */
/* allocate 'struct dfs_file' */
if (idx < 0)
{
return -1;
}
fd = (struct dfs_fd *)rt_calloc(1, sizeof(struct dfs_fd));
fd = (struct dfs_file *)rt_calloc(1, sizeof(struct dfs_file));
if (!fd)
{
return -1;
@ -256,7 +256,7 @@ int fdt_fd_new(struct dfs_fdtable *fdt)
int idx;
/* lock filesystem */
dfs_fd_lock();
dfs_file_lock();
/* find an empty fd entry */
idx = fd_alloc(fdt, DFS_STDIO_OFFSET);
@ -267,7 +267,7 @@ int fdt_fd_new(struct dfs_fdtable *fdt)
LOG_E("DFS fd new is failed! Could not found an empty fd entry.");
}
dfs_fd_unlock();
dfs_file_unlock();
return idx;
}
@ -289,31 +289,31 @@ int fd_new(void)
* pointer.
*/
struct dfs_fd *fdt_fd_get(struct dfs_fdtable* fdt, int fd)
struct dfs_file *fdt_fd_get(struct dfs_fdtable* fdt, int fd)
{
struct dfs_fd *d;
struct dfs_file *d;
if (fd < 0 || fd >= (int)fdt->maxfd)
{
return NULL;
}
dfs_fd_lock();
dfs_file_lock();
d = fdt->fds[fd];
/* check dfs_fd valid or not */
/* check dfs_file valid or not */
if ((d == NULL) || (d->magic != DFS_FD_MAGIC))
{
dfs_fd_unlock();
dfs_file_unlock();
return NULL;
}
dfs_fd_unlock();
dfs_file_unlock();
return d;
}
struct dfs_fd *fd_get(int fd)
struct dfs_file *fd_get(int fd)
{
struct dfs_fdtable *fdt;
@ -328,22 +328,22 @@ struct dfs_fd *fd_get(int fd)
*/
void fdt_fd_release(struct dfs_fdtable* fdt, int fd)
{
struct dfs_fd *fd_slot = NULL;
struct dfs_file *fd_slot = NULL;
RT_ASSERT(fdt != NULL);
dfs_fd_lock();
dfs_file_lock();
if ((fd < 0) || (fd >= fdt->maxfd))
{
dfs_fd_unlock();
dfs_file_unlock();
return;
}
fd_slot = fdt->fds[fd];
if (fd_slot == NULL)
{
dfs_fd_unlock();
dfs_file_unlock();
return;
}
fdt->fds[fd] = NULL;
@ -356,14 +356,14 @@ void fdt_fd_release(struct dfs_fdtable* fdt, int fd)
/* clear this fd entry */
if (fd_slot->ref_count == 0)
{
struct dfs_fnode *vnode = fd_slot->vnode;
struct dfs_vnode *vnode = fd_slot->vnode;
if (vnode)
{
vnode->ref_count--;
}
rt_free(fd_slot);
}
dfs_fd_unlock();
dfs_file_unlock();
}
void fd_release(int fd)
@ -379,7 +379,7 @@ rt_err_t sys_dup(int oldfd)
int newfd = -1;
struct dfs_fdtable *fdt = NULL;
dfs_fd_lock();
dfs_file_lock();
/* check old fd */
fdt = dfs_fdtable_get();
if ((oldfd < 0) || (oldfd >= fdt->maxfd))
@ -399,7 +399,7 @@ rt_err_t sys_dup(int oldfd)
fdt->fds[newfd]->ref_count++;
}
exit:
dfs_fd_unlock();
dfs_file_unlock();
return newfd;
}
@ -419,7 +419,7 @@ int fd_is_open(const char *pathname)
char *fullpath;
unsigned int index;
struct dfs_filesystem *fs;
struct dfs_fd *fd;
struct dfs_file *fd;
struct dfs_fdtable *fdt;
fdt = dfs_fdtable_get();
@ -472,7 +472,7 @@ rt_err_t sys_dup2(int oldfd, int newfd)
int ret = 0;
int retfd = -1;
dfs_fd_lock();
dfs_file_lock();
/* check old fd */
fdt = dfs_fdtable_get();
if ((oldfd < 0) || (oldfd >= fdt->maxfd))
@ -517,11 +517,11 @@ rt_err_t sys_dup2(int oldfd, int newfd)
fdt->fds[newfd]->ref_count++;
retfd = newfd;
exit:
dfs_fd_unlock();
dfs_file_unlock();
return retfd;
}
static int fd_get_fd_index_form_fdt(struct dfs_fdtable *fdt, struct dfs_fd *file)
static int fd_get_fd_index_form_fdt(struct dfs_fdtable *fdt, struct dfs_file *file)
{
int fd = -1;
@ -530,7 +530,7 @@ static int fd_get_fd_index_form_fdt(struct dfs_fdtable *fdt, struct dfs_fd *file
return -1;
}
dfs_fd_lock();
dfs_file_lock();
for(int index = 0; index < (int)fdt->maxfd; index++)
{
@ -541,12 +541,12 @@ static int fd_get_fd_index_form_fdt(struct dfs_fdtable *fdt, struct dfs_fd *file
}
}
dfs_fd_unlock();
dfs_file_unlock();
return fd;
}
int fd_get_fd_index(struct dfs_fd *file)
int fd_get_fd_index(struct dfs_file *file)
{
struct dfs_fdtable *fdt;
@ -554,7 +554,7 @@ int fd_get_fd_index(struct dfs_fd *file)
return fd_get_fd_index_form_fdt(fdt, file);
}
int fd_associate(struct dfs_fdtable *fdt, int fd, struct dfs_fd *file)
int fd_associate(struct dfs_fdtable *fdt, int fd, struct dfs_file *file)
{
int retfd = -1;
@ -567,7 +567,7 @@ int fd_associate(struct dfs_fdtable *fdt, int fd, struct dfs_fd *file)
return retfd;
}
dfs_fd_lock();
dfs_file_lock();
/* check old fd */
if ((fd < 0) || (fd >= fdt->maxfd))
{
@ -583,11 +583,11 @@ int fd_associate(struct dfs_fdtable *fdt, int fd, struct dfs_fd *file)
fdt->fds[fd] = file;
retfd = fd;
exit:
dfs_fd_unlock();
dfs_file_unlock();
return retfd;
}
void fd_init(struct dfs_fd *fd)
void fd_init(struct dfs_file *fd)
{
if (fd)
{
@ -826,7 +826,7 @@ int list_fd(void)
rt_kprintf("-- ------ --- ----- ------\n");
for (index = 0; index < (int)fd_table->maxfd; index++)
{
struct dfs_fd *fd = fd_table->fds[index];
struct dfs_file *fd = fd_table->fds[index];
if (fd && fd->vnode->fops)
{
@ -880,7 +880,7 @@ static int lsofp(int pid)
rt_enter_critical();
for (index = 0; index < (int)fd_table->maxfd; index++)
{
struct dfs_fd *fd = fd_table->fds[index];
struct dfs_file *fd = fd_table->fds[index];
if (fd && fd->vnode->fops)
{

View File

@ -18,13 +18,13 @@
#define DFS_FNODE_HASH_NR 128
struct dfs_fnode_mgr
struct dfs_vnode_mgr
{
struct rt_mutex lock;
rt_list_t head[DFS_FNODE_HASH_NR];
};
static struct dfs_fnode_mgr dfs_fm;
static struct dfs_vnode_mgr dfs_fm;
void dfs_fm_lock(void)
{
@ -36,7 +36,7 @@ void dfs_fm_unlock(void)
rt_mutex_release(&dfs_fm.lock);
}
void dfs_fnode_mgr_init(void)
void dfs_vnode_mgr_init(void)
{
int i = 0;
@ -61,9 +61,9 @@ static unsigned int bkdr_hash(const char *str)
return (hash % DFS_FNODE_HASH_NR);
}
static struct dfs_fnode *dfs_fnode_find(const char *path, rt_list_t **hash_head)
static struct dfs_vnode *dfs_vnode_find(const char *path, rt_list_t **hash_head)
{
struct dfs_fnode *vnode = NULL;
struct dfs_vnode *vnode = NULL;
int hash = bkdr_hash(path);
rt_list_t *hh;
@ -76,7 +76,7 @@ static struct dfs_fnode *dfs_fnode_find(const char *path, rt_list_t **hash_head)
while (hh != &dfs_fm.head[hash])
{
vnode = rt_container_of(hh, struct dfs_fnode, list);
vnode = rt_container_of(hh, struct dfs_vnode, list);
if (rt_strcmp(path, vnode->fullpath) == 0)
{
/* found */
@ -103,13 +103,13 @@ static struct dfs_fnode *dfs_fnode_find(const char *path, rt_list_t **hash_head)
int dfs_file_is_open(const char *pathname)
{
char *fullpath = NULL;
struct dfs_fnode *vnode = NULL;
struct dfs_vnode *vnode = NULL;
int ret = 0;
fullpath = dfs_normalize_path(NULL, pathname);
dfs_fm_lock();
vnode = dfs_fnode_find(fullpath, NULL);
vnode = dfs_vnode_find(fullpath, NULL);
if (vnode)
{
ret = 1;
@ -130,12 +130,12 @@ int dfs_file_is_open(const char *pathname)
*
* @return 0 on successful, -1 on failed.
*/
int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
int dfs_file_open(struct dfs_file *fd, const char *path, int flags)
{
struct dfs_filesystem *fs;
char *fullpath;
int result;
struct dfs_fnode *vnode = NULL;
struct dfs_vnode *vnode = NULL;
rt_list_t *hash_head;
/* parameter check */
@ -153,7 +153,7 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
dfs_fm_lock();
/* vnode find */
vnode = dfs_fnode_find(fullpath, &hash_head);
vnode = dfs_vnode_find(fullpath, &hash_head);
if (vnode)
{
vnode->ref_count++;
@ -173,7 +173,7 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
return -ENOENT;
}
vnode = rt_calloc(1, sizeof(struct dfs_fnode));
vnode = rt_calloc(1, sizeof(struct dfs_vnode));
if (!vnode)
{
dfs_fm_unlock();
@ -270,9 +270,9 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
*
* @return 0 on successful, -1 on failed.
*/
int dfs_file_close(struct dfs_fd *fd)
int dfs_file_close(struct dfs_file *fd)
{
struct dfs_fnode *vnode = NULL;
struct dfs_vnode *vnode = NULL;
int result = 0;
if (fd == NULL)
@ -331,7 +331,7 @@ int dfs_file_close(struct dfs_fd *fd)
*
* @return 0 on successful, -1 on failed.
*/
int dfs_file_ioctl(struct dfs_fd *fd, int cmd, void *args)
int dfs_file_ioctl(struct dfs_file *fd, int cmd, void *args)
{
if (fd == NULL)
{
@ -376,7 +376,7 @@ int dfs_file_ioctl(struct dfs_fd *fd, int cmd, void *args)
*
* @return the actual read data bytes or 0 on end of file or failed.
*/
int dfs_file_read(struct dfs_fd *fd, void *buf, size_t len)
int dfs_file_read(struct dfs_file *fd, void *buf, size_t len)
{
int result = 0;
@ -407,7 +407,7 @@ int dfs_file_read(struct dfs_fd *fd, void *buf, size_t len)
*
* @return the read dirent, others on failed.
*/
int dfs_file_getdents(struct dfs_fd *fd, struct dirent *dirp, size_t nbytes)
int dfs_file_getdents(struct dfs_file *fd, struct dirent *dirp, size_t nbytes)
{
/* parameter check */
if (fd == NULL)
@ -490,7 +490,7 @@ __exit:
*
* @return the actual written data length.
*/
int dfs_file_write(struct dfs_fd *fd, const void *buf, size_t len)
int dfs_file_write(struct dfs_file *fd, const void *buf, size_t len)
{
if (fd == NULL)
{
@ -512,7 +512,7 @@ int dfs_file_write(struct dfs_fd *fd, const void *buf, size_t len)
*
* @return 0 on successful, -1 on failed.
*/
int dfs_file_flush(struct dfs_fd *fd)
int dfs_file_flush(struct dfs_file *fd)
{
if (fd == NULL)
return -EINVAL;
@ -531,7 +531,7 @@ int dfs_file_flush(struct dfs_fd *fd)
*
* @return the current position after seek.
*/
int dfs_file_lseek(struct dfs_fd *fd, off_t offset)
int dfs_file_lseek(struct dfs_file *fd, off_t offset)
{
int result;
@ -703,7 +703,7 @@ __exit:
*
* @return the status of truncated.
*/
int dfs_file_ftruncate(struct dfs_fd *fd, off_t length)
int dfs_file_ftruncate(struct dfs_file *fd, off_t length)
{
int result;
@ -723,7 +723,7 @@ int dfs_file_ftruncate(struct dfs_fd *fd, off_t length)
return result;
}
int dfs_file_mmap2(struct dfs_fd *fd, struct dfs_mmap2_args *mmap2)
int dfs_file_mmap2(struct dfs_file *fd, struct dfs_mmap2_args *mmap2)
{
int ret = 0;
@ -752,7 +752,7 @@ int dfs_file_mmap2(struct dfs_fd *fd, struct dfs_mmap2_args *mmap2)
void ls(const char *pathname)
{
struct dfs_fd fd;
struct dfs_file fd;
struct dirent dirent;
struct stat stat;
int length;
@ -834,7 +834,7 @@ FINSH_FUNCTION_EXPORT(rm, remove files or directories);
void cat(const char *filename)
{
struct dfs_fd fd;
struct dfs_file fd;
int length = 0;
char buffer[81];
@ -867,8 +867,8 @@ FINSH_FUNCTION_EXPORT(cat, print file);
#define BUF_SZ 4096
static void copyfile(const char *src, const char *dst)
{
struct dfs_fd fd;
struct dfs_fd src_fd;
struct dfs_file fd;
struct dfs_file src_fd;
rt_uint8_t *block_ptr;
rt_int32_t read_bytes;
@ -928,7 +928,7 @@ static void copydir(const char *src, const char *dst)
struct dirent dirent;
struct stat stat;
int length;
struct dfs_fd cpfd;
struct dfs_file cpfd;
if (dfs_file_open(&cpfd, src, O_DIRECTORY) < 0)
{
rt_kprintf("open %s failed\n", src);

View File

@ -271,7 +271,7 @@ int dfs_mount(const char *device_name,
/* Check if the path exists or not, raw APIs call, fixme */
if ((strcmp(fullpath, "/") != 0) && (strcmp(fullpath, "/dev") != 0))
{
struct dfs_fd fd;
struct dfs_file fd;
fd_init(&fd);
if (dfs_file_open(&fd, fullpath, O_RDONLY | O_DIRECTORY) < 0)

View File

@ -36,7 +36,7 @@
int open(const char *file, int flags, ...)
{
int fd, result;
struct dfs_fd *d;
struct dfs_file *d;
/* allocate a fd */
fd = fd_new();
@ -89,7 +89,7 @@ RTM_EXPORT(creat);
int close(int fd)
{
int result;
struct dfs_fd *d;
struct dfs_file *d;
d = fd_get(fd);
if (d == NULL)
@ -132,7 +132,7 @@ ssize_t read(int fd, void *buf, size_t len)
#endif
{
int result;
struct dfs_fd *d;
struct dfs_file *d;
/* get the fd */
d = fd_get(fd);
@ -172,7 +172,7 @@ ssize_t write(int fd, const void *buf, size_t len)
#endif
{
int result;
struct dfs_fd *d;
struct dfs_file *d;
/* get the fd */
d = fd_get(fd);
@ -208,7 +208,7 @@ RTM_EXPORT(write);
off_t lseek(int fd, off_t offset, int whence)
{
int result;
struct dfs_fd *d;
struct dfs_file *d;
d = fd_get(fd);
if (d == NULL)
@ -342,7 +342,7 @@ RTM_EXPORT(stat);
*/
int fstat(int fildes, struct stat *buf)
{
struct dfs_fd *d;
struct dfs_file *d;
/* get the fd */
d = fd_get(fildes);
@ -370,7 +370,7 @@ RTM_EXPORT(fstat);
int fsync(int fildes)
{
int ret;
struct dfs_fd *d;
struct dfs_file *d;
/* get the fd */
d = fd_get(fildes);
@ -401,7 +401,7 @@ RTM_EXPORT(fsync);
int fcntl(int fildes, int cmd, ...)
{
int ret = -1;
struct dfs_fd *d;
struct dfs_file *d;
/* get the fd */
d = fd_get(fildes);
@ -467,7 +467,7 @@ RTM_EXPORT(ioctl);
int ftruncate(int fd, off_t length)
{
int result;
struct dfs_fd *d;
struct dfs_file *d;
d = fd_get(fd);
if (d == NULL)
@ -531,7 +531,7 @@ RTM_EXPORT(statfs);
*/
int fstatfs(int fildes, struct statfs *buf)
{
struct dfs_fd *d;
struct dfs_file *d;
/* get the fd */
d = fd_get(fildes);
@ -557,7 +557,7 @@ RTM_EXPORT(fstatfs);
int mkdir(const char *path, mode_t mode)
{
int fd;
struct dfs_fd *d;
struct dfs_file *d;
int result;
fd = fd_new();
@ -619,7 +619,7 @@ RTM_EXPORT(rmdir);
*/
DIR *opendir(const char *name)
{
struct dfs_fd *d;
struct dfs_file *d;
int fd, result;
DIR *t;
@ -675,7 +675,7 @@ RTM_EXPORT(opendir);
struct dirent *readdir(DIR *d)
{
int result;
struct dfs_fd *fd;
struct dfs_file *fd;
fd = fd_get(d->fd);
if (fd == NULL)
@ -722,7 +722,7 @@ RTM_EXPORT(readdir);
*/
long telldir(DIR *d)
{
struct dfs_fd *fd;
struct dfs_file *fd;
long result;
fd = fd_get(d->fd);
@ -748,7 +748,7 @@ RTM_EXPORT(telldir);
*/
void seekdir(DIR *d, long offset)
{
struct dfs_fd *fd;
struct dfs_file *fd;
fd = fd_get(d->fd);
if (fd == NULL)
@ -772,7 +772,7 @@ RTM_EXPORT(seekdir);
*/
void rewinddir(DIR *d)
{
struct dfs_fd *fd;
struct dfs_file *fd;
fd = fd_get(d->fd);
if (fd == NULL)
@ -799,7 +799,7 @@ RTM_EXPORT(rewinddir);
int closedir(DIR *d)
{
int result;
struct dfs_fd *fd;
struct dfs_file *fd;
fd = fd_get(d->fd);
if (fd == NULL)

View File

@ -52,7 +52,7 @@ static resource_id_t id_mgr = RESOURCE_ID_INIT(RT_UNAMED_PIPE_NUMBER, resoure_id
* When the return value is -1, it means the file descriptor is invalid.
* When the return value is -RT_ENOMEM, it means insufficient memory allocation failed.
*/
static int pipe_fops_open(struct dfs_fd *fd)
static int pipe_fops_open(struct dfs_file *fd)
{
int rc = 0;
rt_pipe_t *pipe;
@ -99,7 +99,7 @@ __exit:
* When the return value is 0, it means the operation is successful.
* When the return value is -1, it means the file descriptor is invalid.
*/
static int pipe_fops_close(struct dfs_fd *fd)
static int pipe_fops_close(struct dfs_file *fd)
{
rt_device_t device;
rt_pipe_t *pipe;
@ -164,7 +164,7 @@ static int pipe_fops_close(struct dfs_fd *fd)
* When the return value is 0, it means the operation is successful.
* When the return value is -EINVAL, it means the command is invalid.
*/
static int pipe_fops_ioctl(struct dfs_fd *fd, int cmd, void *args)
static int pipe_fops_ioctl(struct dfs_file *fd, int cmd, void *args)
{
rt_pipe_t *pipe;
int ret = 0;
@ -200,7 +200,7 @@ static int pipe_fops_ioctl(struct dfs_fd *fd, int cmd, void *args)
* When the return value is 0, it means O_NONBLOCK is enabled and there is no thread that has the pipe open for writing.
* When the return value is -EAGAIN, it means there are no data to be read.
*/
static int pipe_fops_read(struct dfs_fd *fd, void *buf, size_t count)
static int pipe_fops_read(struct dfs_file *fd, void *buf, size_t count)
{
int len = 0;
rt_pipe_t *pipe;
@ -254,7 +254,7 @@ out:
* When the return value is -EAGAIN, it means O_NONBLOCK is enabled and there are no space to be written.
* When the return value is -EPIPE, it means there is no thread that has the pipe open for reading.
*/
static int pipe_fops_write(struct dfs_fd *fd, const void *buf, size_t count)
static int pipe_fops_write(struct dfs_file *fd, const void *buf, size_t count)
{
int len;
rt_pipe_t *pipe;
@ -325,7 +325,7 @@ static int pipe_fops_write(struct dfs_fd *fd, const void *buf, size_t count)
* POLLOUT means there is space to be written.
* POLLERR means there is no thread that occupied the pipe to open for reading.
*/
static int pipe_fops_poll(struct dfs_fd *fd, rt_pollreq_t *req)
static int pipe_fops_poll(struct dfs_file *fd, rt_pollreq_t *req)
{
int mask = 0;
rt_pipe_t *pipe;

View File

@ -25,13 +25,13 @@
#include <sys/ioctl.h>
#include <dfs_file.h>
static int bus_fops_open(struct dfs_fd *fd)
static int bus_fops_open(struct dfs_file *fd)
{
LOG_D("bus fops open");
return 0;
}
static int bus_fops_close(struct dfs_fd *fd)
static int bus_fops_close(struct dfs_file *fd)
{
LOG_D("bus fops close");
return 0;

View File

@ -64,7 +64,7 @@ static rt_err_t serial_fops_rx_ind(rt_device_t dev, rt_size_t size)
}
/* fops for serial */
static int serial_fops_open(struct dfs_fd *fd)
static int serial_fops_open(struct dfs_file *fd)
{
rt_err_t ret = 0;
rt_uint16_t flags = 0;
@ -100,7 +100,7 @@ static int serial_fops_open(struct dfs_fd *fd)
return ret;
}
static int serial_fops_close(struct dfs_fd *fd)
static int serial_fops_close(struct dfs_file *fd)
{
rt_device_t device;
@ -112,7 +112,7 @@ static int serial_fops_close(struct dfs_fd *fd)
return 0;
}
static int serial_fops_ioctl(struct dfs_fd *fd, int cmd, void *args)
static int serial_fops_ioctl(struct dfs_file *fd, int cmd, void *args)
{
rt_device_t device;
int flags = (int)(rt_base_t)args;
@ -135,7 +135,7 @@ static int serial_fops_ioctl(struct dfs_fd *fd, int cmd, void *args)
return rt_device_control(device, cmd, args);
}
static int serial_fops_read(struct dfs_fd *fd, void *buf, size_t count)
static int serial_fops_read(struct dfs_file *fd, void *buf, size_t count)
{
int size = 0;
rt_device_t device;
@ -169,7 +169,7 @@ static int serial_fops_read(struct dfs_fd *fd, void *buf, size_t count)
return size;
}
static int serial_fops_write(struct dfs_fd *fd, const void *buf, size_t count)
static int serial_fops_write(struct dfs_file *fd, const void *buf, size_t count)
{
rt_device_t device;
@ -177,7 +177,7 @@ static int serial_fops_write(struct dfs_fd *fd, const void *buf, size_t count)
return rt_device_write(device, -1, buf, count);
}
static int serial_fops_poll(struct dfs_fd *fd, struct rt_pollreq *req)
static int serial_fops_poll(struct dfs_file *fd, struct rt_pollreq *req)
{
int mask = 0;
int flags = 0;

View File

@ -43,7 +43,7 @@ static rt_err_t serial_fops_rx_ind(rt_device_t dev, rt_size_t size)
}
/* fops for serial */
static int serial_fops_open(struct dfs_fd *fd)
static int serial_fops_open(struct dfs_file *fd)
{
rt_err_t ret = 0;
rt_uint16_t flags = 0;
@ -79,7 +79,7 @@ static int serial_fops_open(struct dfs_fd *fd)
return ret;
}
static int serial_fops_close(struct dfs_fd *fd)
static int serial_fops_close(struct dfs_file *fd)
{
rt_device_t device;
@ -91,7 +91,7 @@ static int serial_fops_close(struct dfs_fd *fd)
return 0;
}
static int serial_fops_ioctl(struct dfs_fd *fd, int cmd, void *args)
static int serial_fops_ioctl(struct dfs_file *fd, int cmd, void *args)
{
rt_device_t device;
int flags = (int)(rt_base_t)args;
@ -114,7 +114,7 @@ static int serial_fops_ioctl(struct dfs_fd *fd, int cmd, void *args)
return rt_device_control(device, cmd, args);
}
static int serial_fops_read(struct dfs_fd *fd, void *buf, size_t count)
static int serial_fops_read(struct dfs_file *fd, void *buf, size_t count)
{
int size = 0;
rt_device_t device;
@ -139,7 +139,7 @@ static int serial_fops_read(struct dfs_fd *fd, void *buf, size_t count)
return size;
}
static int serial_fops_write(struct dfs_fd *fd, const void *buf, size_t count)
static int serial_fops_write(struct dfs_file *fd, const void *buf, size_t count)
{
rt_device_t device;
@ -147,7 +147,7 @@ static int serial_fops_write(struct dfs_fd *fd, const void *buf, size_t count)
return rt_device_write(device, -1, buf, count);
}
static int serial_fops_poll(struct dfs_fd *fd, struct rt_pollreq *req)
static int serial_fops_poll(struct dfs_file *fd, struct rt_pollreq *req)
{
int mask = 0;
int flags = 0;

View File

@ -23,16 +23,16 @@ struct tty_ldisc_ops
char *name;
int num;
int (*open) (struct dfs_fd *fd);
int (*open) (struct dfs_file *fd);
int (*close) (struct tty_struct *tty);
int (*ioctl) (struct dfs_fd *fd, int cmd, void *args);
int (*read) (struct dfs_fd *fd, void *buf, size_t count);
int (*write) (struct dfs_fd *fd, const void *buf, size_t count);
int (*flush) (struct dfs_fd *fd);
int (*lseek) (struct dfs_fd *fd, off_t offset);
int (*getdents) (struct dfs_fd *fd, struct dirent *dirp, uint32_t count);
int (*ioctl) (struct dfs_file *fd, int cmd, void *args);
int (*read) (struct dfs_file *fd, void *buf, size_t count);
int (*write) (struct dfs_file *fd, const void *buf, size_t count);
int (*flush) (struct dfs_file *fd);
int (*lseek) (struct dfs_file *fd, off_t offset);
int (*getdents) (struct dfs_file *fd, struct dirent *dirp, uint32_t count);
int (*poll) (struct dfs_fd *fd, struct rt_pollreq *req);
int (*poll) (struct dfs_file *fd, struct rt_pollreq *req);
void (*set_termios) (struct tty_struct *tty, struct termios *old);
int (*receive_buf) (struct tty_struct *tty,char *cp, int count);

View File

@ -1112,7 +1112,7 @@ void console_ldata_init(struct tty_struct *tty)
return;
}
static int n_tty_open(struct dfs_fd *fd)
static int n_tty_open(struct dfs_file *fd)
{
int ret = 0;
struct n_tty_data *ldata = RT_NULL;
@ -1332,7 +1332,7 @@ static int n_tty_close(struct tty_struct *tty)
return ret;
}
static int n_tty_ioctl(struct dfs_fd *fd, int cmd, void *args)
static int n_tty_ioctl(struct dfs_file *fd, int cmd, void *args)
{
int ret = 0;
struct tty_struct *real_tty = RT_NULL;
@ -1845,7 +1845,7 @@ static int job_control(struct tty_struct *tty)
return __tty_check_change(tty, SIGTTIN);
}
static int n_tty_read(struct dfs_fd *fd, void *buf, size_t count)
static int n_tty_read(struct dfs_file *fd, void *buf, size_t count)
{
int level = 0;
char *b = (char *)buf;
@ -1906,7 +1906,7 @@ static int n_tty_read(struct dfs_fd *fd, void *buf, size_t count)
return retval;
}
static int n_tty_write(struct dfs_fd *fd, const void *buf, size_t count)
static int n_tty_write(struct dfs_file *fd, const void *buf, size_t count)
{
int retval = 0;
char *b = (char *)buf;
@ -1987,22 +1987,22 @@ break_out:
return retval;
}
static int n_tty_flush(struct dfs_fd *fd)
static int n_tty_flush(struct dfs_file *fd)
{
return 0;
}
static int n_tty_lseek(struct dfs_fd *fd, off_t offset)
static int n_tty_lseek(struct dfs_file *fd, off_t offset)
{
return 0;
}
static int n_tty_getdents(struct dfs_fd *fd, struct dirent *dirp, uint32_t count)
static int n_tty_getdents(struct dfs_file *fd, struct dirent *dirp, uint32_t count)
{
return 0;
}
static int n_tty_poll(struct dfs_fd *fd, struct rt_pollreq *req)
static int n_tty_poll(struct dfs_file *fd, struct rt_pollreq *req)
{
rt_base_t level = 0;
int mask = POLLOUT;

View File

@ -175,7 +175,7 @@ static rt_err_t pty_device_control(rt_device_t dev, int cmd, void *args)
return -ENOIOCTLCMD;
}
static int ptmx_open(struct dfs_fd *fd)
static int ptmx_open(struct dfs_file *fd)
{
int ret = 0;
struct tty_struct *tty = RT_NULL;

View File

@ -210,7 +210,7 @@ int tty_check_change(struct tty_struct *tty)
return __tty_check_change(tty, SIGTTOU);
}
static int tty_open(struct dfs_fd *fd)
static int tty_open(struct dfs_file *fd)
{
int ret = 0;
int noctty = 0;
@ -251,7 +251,7 @@ static int tty_open(struct dfs_fd *fd)
return ret;
}
static int tty_close(struct dfs_fd *fd)
static int tty_close(struct dfs_file *fd)
{
int ret = 0;
struct tty_struct *tty = RT_NULL;
@ -304,7 +304,7 @@ static int tiocsctty(struct tty_struct *tty, int arg)
return 0;
}
static int tty_ioctl(struct dfs_fd *fd, int cmd, void *args)
static int tty_ioctl(struct dfs_file *fd, int cmd, void *args)
{
int ret = 0;
struct tty_struct *tty = RT_NULL;
@ -335,7 +335,7 @@ static int tty_ioctl(struct dfs_fd *fd, int cmd, void *args)
return ret;
}
static int tty_read(struct dfs_fd *fd, void *buf, size_t count)
static int tty_read(struct dfs_file *fd, void *buf, size_t count)
{
int ret = 0;
struct tty_struct *tty = RT_NULL;
@ -351,7 +351,7 @@ static int tty_read(struct dfs_fd *fd, void *buf, size_t count)
return ret;
}
static int tty_write(struct dfs_fd *fd, const void *buf, size_t count)
static int tty_write(struct dfs_file *fd, const void *buf, size_t count)
{
int ret = 0;
struct tty_struct *tty = RT_NULL;
@ -367,7 +367,7 @@ static int tty_write(struct dfs_fd *fd, const void *buf, size_t count)
return ret;
}
static int tty_poll(struct dfs_fd *fd, struct rt_pollreq *req)
static int tty_poll(struct dfs_file *fd, struct rt_pollreq *req)
{
int ret = 0;
struct tty_struct *tty = RT_NULL;

View File

@ -406,7 +406,7 @@ const static struct rt_device_ops char_dev_ops =
#include <sys/statfs.h> /* statfs() */
/* RT-Thread device filesystem interface */
static int char_dev_fopen(struct dfs_fd *fd)
static int char_dev_fopen(struct dfs_file *fd)
{
struct fal_char_device *part = (struct fal_char_device *) fd->vnode->data;
@ -429,7 +429,7 @@ static int char_dev_fopen(struct dfs_fd *fd)
return RT_EOK;
}
static int char_dev_fread(struct dfs_fd *fd, void *buf, size_t count)
static int char_dev_fread(struct dfs_file *fd, void *buf, size_t count)
{
int ret = 0;
struct fal_char_device *part = (struct fal_char_device *) fd->vnode->data;
@ -449,7 +449,7 @@ static int char_dev_fread(struct dfs_fd *fd, void *buf, size_t count)
return ret;
}
static int char_dev_fwrite(struct dfs_fd *fd, const void *buf, size_t count)
static int char_dev_fwrite(struct dfs_file *fd, const void *buf, size_t count)
{
int ret = 0;
struct fal_char_device *part = (struct fal_char_device *) fd->vnode->data;

View File

@ -122,7 +122,7 @@ static int do_pollfd(struct pollfd *pollfd, rt_pollreq_t *req)
if (fd >= 0)
{
struct dfs_fd *f = fd_get(fd);
struct dfs_file *f = fd_get(fd);
mask = POLLNVAL;
if (f)

View File

@ -1059,7 +1059,7 @@ void lwp_cleanup(struct rt_thread *tid)
static void lwp_copy_stdio_fdt(struct rt_lwp *lwp)
{
struct dfs_fd *d;
struct dfs_file *d;
struct dfs_fdtable *lwp_fdt;
lwp_fdt = &lwp->fdt;

View File

@ -783,7 +783,7 @@ static int lwp_fd_new(int fdt_type)
return fdt_fd_new(fdt);
}
static struct dfs_fd *lwp_fd_get(int fdt_type, int fd)
static struct dfs_file *lwp_fd_get(int fdt_type, int fd)
{
struct dfs_fdtable *fdt;
@ -830,7 +830,7 @@ static int _chfd_alloc(int fdt_type)
static void _chfd_free(int fd, int fdt_type)
{
struct dfs_fd *d;
struct dfs_file *d;
d = lwp_fd_get(fdt_type, fd);
if (d == RT_NULL)
@ -841,7 +841,7 @@ static void _chfd_free(int fd, int fdt_type)
}
/* for fops */
static int channel_fops_poll(struct dfs_fd *file, struct rt_pollreq *req)
static int channel_fops_poll(struct dfs_file *file, struct rt_pollreq *req)
{
int mask = POLLOUT;
rt_channel_t ch;
@ -859,7 +859,7 @@ static int channel_fops_poll(struct dfs_fd *file, struct rt_pollreq *req)
return mask;
}
static int channel_fops_close(struct dfs_fd *file)
static int channel_fops_close(struct dfs_file *file)
{
rt_channel_t ch;
rt_base_t level;
@ -902,7 +902,7 @@ int lwp_channel_open(int fdt_type, const char *name, int flags)
{
int fd;
rt_channel_t ch = RT_NULL;
struct dfs_fd *d;
struct dfs_file *d;
fd = _chfd_alloc(fdt_type); /* allocate an IPC channel descriptor */
if (fd == -1)
@ -910,7 +910,7 @@ int lwp_channel_open(int fdt_type, const char *name, int flags)
goto quit;
}
d = lwp_fd_get(fdt_type, fd);
d->vnode = (struct dfs_fnode *)rt_malloc(sizeof(struct dfs_fnode));
d->vnode = (struct dfs_vnode *)rt_malloc(sizeof(struct dfs_vnode));
if (!d->vnode)
{
_chfd_free(fd, fdt_type);
@ -921,7 +921,7 @@ int lwp_channel_open(int fdt_type, const char *name, int flags)
ch = rt_raw_channel_open(name, flags);
if (ch)
{
rt_memset(d->vnode, 0, sizeof(struct dfs_fnode));
rt_memset(d->vnode, 0, sizeof(struct dfs_vnode));
rt_list_init(&d->vnode->list);
d->vnode->type = FT_USER;
d->vnode->path = NULL;
@ -934,7 +934,7 @@ int lwp_channel_open(int fdt_type, const char *name, int flags)
d->pos = 0;
d->vnode->ref_count = 1;
/* set socket to the data of dfs_fd */
/* set socket to the data of dfs_file */
d->vnode->data = (void *)ch;
}
else
@ -950,7 +950,7 @@ quit:
static rt_channel_t fd_2_channel(int fdt_type, int fd)
{
struct dfs_fd *d;
struct dfs_file *d;
d = lwp_fd_get(fdt_type, fd);
if (d)
@ -969,8 +969,8 @@ static rt_channel_t fd_2_channel(int fdt_type, int fd)
rt_err_t lwp_channel_close(int fdt_type, int fd)
{
rt_channel_t ch;
struct dfs_fd *d;
struct dfs_fnode *vnode;
struct dfs_file *d;
struct dfs_vnode *vnode;
d = lwp_fd_get(fdt_type, fd);
if (!d)

View File

@ -135,7 +135,7 @@ static void __exit_files(struct rt_lwp *lwp)
while (fd >= 0)
{
struct dfs_fd *d;
struct dfs_file *d;
d = lwp->fdt.fds[fd];
if (d)

View File

@ -1636,12 +1636,12 @@ static int lwp_copy_files(struct rt_lwp *dst, struct rt_lwp *src)
dst_fdt->fds = rt_calloc(src_fdt->maxfd, sizeof(void *));
if (dst_fdt->fds)
{
struct dfs_fd *d_s;
struct dfs_file *d_s;
int i;
dst_fdt->maxfd = src_fdt->maxfd;
dfs_fd_lock();
dfs_file_lock();
/* dup files */
for (i = 0; i < src_fdt->maxfd; i++)
{
@ -1652,7 +1652,7 @@ static int lwp_copy_files(struct rt_lwp *dst, struct rt_lwp *src)
d_s->ref_count++;
}
}
dfs_fd_unlock();
dfs_file_unlock();
return 0;
}
return -RT_ERROR;
@ -3729,7 +3729,7 @@ struct libc_dirent {
sysret_t sys_getdents(int fd, struct libc_dirent *dirp, size_t nbytes)
{
int ret = -1;
struct dfs_fd *dfs_fd;
struct dfs_file *file;
size_t cnt = (nbytes / sizeof(struct libc_dirent));
size_t rtt_nbytes = 0;
struct dirent *rtt_dirp;
@ -3751,8 +3751,8 @@ sysret_t sys_getdents(int fd, struct libc_dirent *dirp, size_t nbytes)
{
return -ENOMEM;
}
dfs_fd = fd_get(fd);
ret = dfs_file_getdents(dfs_fd, rtt_dirp, rtt_nbytes);
file = fd_get(fd);
ret = dfs_file_getdents(file, rtt_dirp, rtt_nbytes);
if (ret > 0)
{
size_t i = 0;
@ -4064,9 +4064,9 @@ sysret_t sys_getrlimit(unsigned int resource, unsigned long rlim[2])
{
struct dfs_fdtable *fdt = dfs_fdtable_get();
dfs_fd_lock();
dfs_file_lock();
rlim[0] = fdt->maxfd;
dfs_fd_unlock();
dfs_file_unlock();
rlim[1] = DFS_FD_MAX;
ret = 0;
}
@ -4161,7 +4161,7 @@ ssize_t sys_readlink(char* path, char *buf, size_t bufsz)
size_t len, copy_len;
int err, rtn;
int fd = -1;
struct dfs_fd *d;
struct dfs_file *d;
char *copy_path;
len = lwp_user_strlen(path, &err);
@ -4565,18 +4565,20 @@ sysret_t sys_mq_close(mqd_t mqd)
rt_weak sysret_t sys_cacheflush(void *addr, int size, int cache)
{
if (addr < addr + size &&
(size_t)addr >= USER_VADDR_START &&
(size_t)addr + size < USER_VADDR_TOP)
if (((size_t)addr < (size_t)addr + size) &&
((size_t)addr >= USER_VADDR_START) &&
((size_t)addr + size < USER_VADDR_TOP))
{
if ((cache & DCACHE))
{
rt_hw_cpu_dcache_clean_and_invalidate(addr, size);
}
if ((cache & ICACHE))
{
rt_hw_cpu_icache_invalidate(addr, size);
}
return 0;
}
return -EFAULT;

View File

@ -39,10 +39,12 @@ static void _init_lwp_objs(struct rt_lwp_objs *lwp_objs, rt_aspace_t aspace);
int lwp_user_space_init(struct rt_lwp *lwp, rt_bool_t is_fork)
{
int err = -RT_ENOMEM;
lwp->lwp_obj = rt_malloc(sizeof(struct rt_lwp_objs));
_init_lwp_objs(lwp->lwp_obj, lwp->aspace);
if (lwp->lwp_obj)
{
_init_lwp_objs(lwp->lwp_obj, lwp->aspace);
err = arch_user_space_init(lwp);
if (!is_fork && err == RT_EOK)
{
@ -52,6 +54,7 @@ int lwp_user_space_init(struct rt_lwp *lwp, rt_bool_t is_fork)
MMU_MAP_U_RWCB, 0, &lwp->lwp_obj->mem_obj, 0);
}
}
return err;
}
@ -167,18 +170,21 @@ static void _user_do_page_fault(struct rt_varea *varea,
static void _init_lwp_objs(struct rt_lwp_objs *lwp_objs, rt_aspace_t aspace)
{
/**
* @brief one lwp_obj represent an base layout of page based memory in user space
* This is useful on duplication. Where we only have a (lwp_objs and offset) to
* provide identical memory. This is implemented by lwp_objs->source.
*/
lwp_objs->source = NULL;
lwp_objs->mem_obj.get_name = user_get_name;
lwp_objs->mem_obj.hint_free = NULL;
lwp_objs->mem_obj.on_page_fault = _user_do_page_fault;
lwp_objs->mem_obj.on_page_offload = rt_mm_dummy_mapper.on_page_offload;
lwp_objs->mem_obj.on_varea_open = rt_mm_dummy_mapper.on_varea_open;
lwp_objs->mem_obj.on_varea_close = rt_mm_dummy_mapper.on_varea_close;
if (lwp_objs)
{
/**
* @brief one lwp_obj represent an base layout of page based memory in user space
* This is useful on duplication. Where we only have a (lwp_objs and offset) to
* provide identical memory. This is implemented by lwp_objs->source.
*/
lwp_objs->source = NULL;
lwp_objs->mem_obj.get_name = user_get_name;
lwp_objs->mem_obj.hint_free = NULL;
lwp_objs->mem_obj.on_page_fault = _user_do_page_fault;
lwp_objs->mem_obj.on_page_offload = rt_mm_dummy_mapper.on_page_offload;
lwp_objs->mem_obj.on_varea_open = rt_mm_dummy_mapper.on_varea_open;
lwp_objs->mem_obj.on_varea_close = rt_mm_dummy_mapper.on_varea_close;
}
}
static void *_lwp_map_user(struct rt_lwp *lwp, void *map_va, size_t map_size,
@ -206,8 +212,8 @@ static void *_lwp_map_user(struct rt_lwp *lwp, void *map_va, size_t map_size,
int lwp_unmap_user(struct rt_lwp *lwp, void *va)
{
int err;
err = rt_aspace_unmap(lwp->aspace, va);
int err = rt_aspace_unmap(lwp->aspace, va);
return err;
}
@ -525,7 +531,7 @@ void *lwp_mmap2(void *addr, size_t length, int prot, int flags, int fd,
}
else
{
struct dfs_fd *d;
struct dfs_file *d;
d = fd_get(fd);
if (d && d->vnode->type == FT_DEVICE)

View File

@ -21,18 +21,18 @@
int dfs_net_getsocket(int fd)
{
int socket;
struct dfs_fd *_dfs_fd;
struct dfs_file *file;
_dfs_fd = fd_get(fd);
if (_dfs_fd == NULL) return -1;
file = fd_get(fd);
if (file == NULL) return -1;
if (_dfs_fd->vnode->type != FT_SOCKET) socket = -1;
else socket = (int)(size_t)_dfs_fd->vnode->data;
if (file->vnode->type != FT_SOCKET) socket = -1;
else socket = (int)(size_t)file->vnode->data;
return socket;
}
static int dfs_net_ioctl(struct dfs_fd* file, int cmd, void* args)
static int dfs_net_ioctl(struct dfs_file* file, int cmd, void* args)
{
int ret;
int socket = (int)(size_t)file->vnode->data;
@ -46,7 +46,7 @@ static int dfs_net_ioctl(struct dfs_fd* file, int cmd, void* args)
return ret;
}
static int dfs_net_read(struct dfs_fd* file, void *buf, size_t count)
static int dfs_net_read(struct dfs_file* file, void *buf, size_t count)
{
int ret;
int socket = (int)(size_t)file->vnode->data;
@ -60,11 +60,11 @@ static int dfs_net_read(struct dfs_fd* file, void *buf, size_t count)
return ret;
}
static int dfs_net_write(struct dfs_fd *file, const void *buf, size_t count)
static int dfs_net_write(struct dfs_file *file, const void *buf, size_t count)
{
int ret;
int socket = (int)(size_t)file->vnode->data;
ret = sal_sendto(socket, buf, count, 0, NULL, 0);
if (ret < 0)
{
@ -73,7 +73,7 @@ static int dfs_net_write(struct dfs_fd *file, const void *buf, size_t count)
}
return ret;
}
static int dfs_net_close(struct dfs_fd* file)
static int dfs_net_close(struct dfs_file* file)
{
int socket;
int ret = 0;
@ -86,9 +86,9 @@ static int dfs_net_close(struct dfs_fd* file)
return ret;
}
static int dfs_net_poll(struct dfs_fd *file, struct rt_pollreq *req)
static int dfs_net_poll(struct dfs_file *file, struct rt_pollreq *req)
{
extern int sal_poll(struct dfs_fd *file, struct rt_pollreq *req);
extern int sal_poll(struct dfs_file *file, struct rt_pollreq *req);
return sal_poll(file, req);
}

View File

@ -25,7 +25,7 @@
#ifdef SAL_USING_AT
#ifdef SAL_USING_POSIX
static int at_poll(struct dfs_fd *file, struct rt_pollreq *req)
static int at_poll(struct dfs_file *file, struct rt_pollreq *req)
{
int mask = 0;
struct at_socket *sock;

View File

@ -243,7 +243,7 @@ int inet_ioctlsocket(int socket, long cmd, void *arg)
}
#ifdef SAL_USING_POSIX
static int inet_poll(struct dfs_fd *file, struct rt_pollreq *req)
static int inet_poll(struct dfs_file *file, struct rt_pollreq *req)
{
int mask = 0;
struct lwip_sock *sock;

View File

@ -80,7 +80,7 @@ struct sal_socket_ops
int (*getsockname)(int s, struct sockaddr *name, socklen_t *namelen);
int (*ioctlsocket)(int s, long cmd, void *arg);
#ifdef SAL_USING_POSIX
int (*poll) (struct dfs_fd *file, struct rt_pollreq *req);
int (*poll) (struct dfs_file *file, struct rt_pollreq *req);
#endif
};

View File

@ -26,7 +26,7 @@ int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
/* this is a new socket, create it in file system fd */
int fd;
struct dfs_fd *d;
struct dfs_file *d;
/* allocate a fd */
fd = fd_new();
@ -41,7 +41,7 @@ int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
if(d)
{
/* this is a socket fd */
d->vnode = (struct dfs_fnode *)rt_malloc(sizeof(struct dfs_fnode));
d->vnode = (struct dfs_vnode *)rt_malloc(sizeof(struct dfs_vnode));
if (!d->vnode)
{
/* release fd */
@ -49,7 +49,7 @@ int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
rt_set_errno(-ENOMEM);
return -1;
}
rt_memset(d->vnode, 0, sizeof(struct dfs_fnode));
rt_memset(d->vnode, 0, sizeof(struct dfs_vnode));
rt_list_init(&d->vnode->list);
d->vnode->type = FT_SOCKET;
@ -61,7 +61,7 @@ int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
d->vnode->size = 0;
d->pos = 0;
/* set socket to the data of dfs_fd */
/* set socket to the data of dfs_file */
d->vnode->data = (void *)(size_t)new_socket;
return fd;
@ -99,7 +99,7 @@ int shutdown(int s, int how)
{
int error = 0;
int socket = -1;
struct dfs_fd *d;
struct dfs_file *d;
socket = dfs_net_getsocket(s);
if (socket < 0)
@ -227,7 +227,7 @@ int socket(int domain, int type, int protocol)
/* create a BSD socket */
int fd;
int socket;
struct dfs_fd *d;
struct dfs_file *d;
/* allocate a fd */
fd = fd_new();
@ -238,7 +238,7 @@ int socket(int domain, int type, int protocol)
return -1;
}
d = fd_get(fd);
d->vnode = (struct dfs_fnode *)rt_malloc(sizeof(struct dfs_fnode));
d->vnode = (struct dfs_vnode *)rt_malloc(sizeof(struct dfs_vnode));
if (!d->vnode)
{
/* release fd */
@ -254,11 +254,11 @@ int socket(int domain, int type, int protocol)
}
#endif /* SAL_USING_AF_UNIX */
/* create socket and then put it to the dfs_fd */
/* create socket and then put it to the dfs_file */
socket = sal_socket(domain, type, protocol);
if (socket >= 0)
{
rt_memset(d->vnode, 0, sizeof(struct dfs_fnode));
rt_memset(d->vnode, 0, sizeof(struct dfs_vnode));
rt_list_init(&d->vnode->list);
/* this is a socket fd */
d->vnode->type = FT_SOCKET;
@ -271,7 +271,7 @@ int socket(int domain, int type, int protocol)
d->vnode->size = 0;
d->pos = 0;
/* set socket to the data of dfs_fd */
/* set socket to the data of dfs_file */
d->vnode->data = (void *)(size_t)socket;
}
else
@ -291,7 +291,7 @@ int closesocket(int s)
{
int error = 0;
int socket = -1;
struct dfs_fd *d;
struct dfs_file *d;
socket = dfs_net_getsocket(s);
if (socket < 0)

View File

@ -1062,7 +1062,7 @@ int sal_ioctlsocket(int socket, long cmd, void *arg)
addr = (struct sockaddr *)&(ifr->ifr_ifru.ifru_addr);
sal_sockaddr_to_ipaddr(addr,&input_ipaddr);
netdev_set_ipaddr(sock->netdev,&input_ipaddr);
return 0;
return 0;
case SIOCGIFNETMASK:
addr_in = (struct sockaddr_in *)&(ifr->ifr_ifru.ifru_netmask);
@ -1079,7 +1079,7 @@ int sal_ioctlsocket(int socket, long cmd, void *arg)
addr = (struct sockaddr *)&(ifr->ifr_ifru.ifru_netmask);
sal_sockaddr_to_ipaddr(addr,&input_ipaddr);
netdev_set_netmask(sock->netdev,&input_ipaddr);
return 0;
return 0;
case SIOCGIFHWADDR:
addr = (struct sockaddr *)&(ifr->ifr_ifru.ifru_hwaddr);
@ -1088,7 +1088,7 @@ int sal_ioctlsocket(int socket, long cmd, void *arg)
case SIOCGIFMTU:
ifr->ifr_ifru.ifru_mtu = sock->netdev->mtu;
return 0;
return 0;
default:
break;
@ -1098,7 +1098,7 @@ int sal_ioctlsocket(int socket, long cmd, void *arg)
}
#ifdef SAL_USING_POSIX
int sal_poll(struct dfs_fd *file, struct rt_pollreq *req)
int sal_poll(struct dfs_file *file, struct rt_pollreq *req)
{
struct sal_socket *sock;
struct sal_proto_family *pf;

View File

@ -25,7 +25,7 @@
#include <sys/statfs.h>
#include <poll.h>
int rtlink_fops_open(struct dfs_fd *fd)
int rtlink_fops_open(struct dfs_file *fd)
{
rt_uint16_t flags = 0;
rt_device_t device;
@ -58,7 +58,7 @@ int rtlink_fops_open(struct dfs_fd *fd)
return rt_device_open(device, flags);
}
int rtlink_fops_close(struct dfs_fd *fd)
int rtlink_fops_close(struct dfs_file *fd)
{
rt_device_t device;
device = (rt_device_t)fd->vnode->data;
@ -67,7 +67,7 @@ int rtlink_fops_close(struct dfs_fd *fd)
return rt_device_close(device);
}
int rtlink_fops_ioctl(struct dfs_fd *fd, int cmd, void *args)
int rtlink_fops_ioctl(struct dfs_file *fd, int cmd, void *args)
{
rt_device_t device;
device = (rt_device_t)fd->vnode->data;
@ -82,7 +82,7 @@ int rtlink_fops_ioctl(struct dfs_fd *fd, int cmd, void *args)
}
}
int rtlink_fops_read(struct dfs_fd *fd, void *buf, size_t count)
int rtlink_fops_read(struct dfs_file *fd, void *buf, size_t count)
{
int size = 0;
rt_device_t device;
@ -96,7 +96,7 @@ int rtlink_fops_read(struct dfs_fd *fd, void *buf, size_t count)
return size;
}
int rtlink_fops_write(struct dfs_fd *fd, const void *buf, size_t count)
int rtlink_fops_write(struct dfs_file *fd, const void *buf, size_t count)
{
int size = 0;
rt_device_t device;
@ -110,7 +110,7 @@ int rtlink_fops_write(struct dfs_fd *fd, const void *buf, size_t count)
return size;
}
int rtlink_fops_poll(struct dfs_fd *fd, struct rt_pollreq *req)
int rtlink_fops_poll(struct dfs_file *fd, struct rt_pollreq *req)
{
int mask = 0;
int flags = 0;

View File

@ -685,7 +685,7 @@ struct sal_socket_ops
int (*getsockname)(int s, struct sockaddr *name, socklen_t *namelen);
int (*ioctlsocket)(int s, long cmd, void *arg);
#ifdef SAL_USING_POSIX
int (*poll) (struct dfs_fd *file, struct rt_pollreq *req);
int (*poll) (struct dfs_file *file, struct rt_pollreq *req);
#endif
};
@ -732,7 +732,7 @@ The following is the access registration process implemented by AT Socket networ
#ifdef SAL_USING_AT
/* A custom poll execution function that handles the events received in the poll */
static int at_poll(struct dfs_fd *file, struct rt_pollreq *req)
static int at_poll(struct dfs_file *file, struct rt_pollreq *req)
{
int mask = 0;
struct at_socket *sock;