diff --git a/bsp/simulator/drivers/dfs_win32.c b/bsp/simulator/drivers/dfs_win32.c index 6d144fe6e560ace599edd21ce4c9f3bd6d5714c6..ebf1d741c9723129cbd5fd5421390673f8027b42 100644 --- a/bsp/simulator/drivers/dfs_win32.c +++ b/bsp/simulator/drivers/dfs_win32.c @@ -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; diff --git a/bsp/simulator/drivers/winsock/rtt_winsock.h b/bsp/simulator/drivers/winsock/rtt_winsock.h index 63c8fae6005398d32ed44d19fc9f5ed154370e1c..d0ec540c2cd276779583f58602e87b2c77f853e5 100644 --- a/bsp/simulator/drivers/winsock/rtt_winsock.h +++ b/bsp/simulator/drivers/winsock/rtt_winsock.h @@ -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 */ diff --git a/bsp/simulator/drivers/winsock/sal_winsock.c b/bsp/simulator/drivers/winsock/sal_winsock.c index 6a43670f5d0eb15f8fe0dbe890ac300f45a4ffe2..715ac4e250c6329c2a53299c916389209dea4dbd 100644 --- a/bsp/simulator/drivers/winsock/sal_winsock.c +++ b/bsp/simulator/drivers/winsock/sal_winsock.c @@ -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 */ diff --git a/components/dfs/dfs_v1/filesystems/cromfs/dfs_cromfs.c b/components/dfs/dfs_v1/filesystems/cromfs/dfs_cromfs.c index f2a8424bb414c0e1d14e3c06507bf563ca603488..fee8b8dbd15349e96e246e43f1b6262e00003efe 100644 --- a/components/dfs/dfs_v1/filesystems/cromfs/dfs_cromfs.c +++ b/components/dfs/dfs_v1/filesystems/cromfs/dfs_cromfs.c @@ -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; diff --git a/components/dfs/dfs_v1/filesystems/devfs/devfs.c b/components/dfs/dfs_v1/filesystems/devfs/devfs.c index f0b7327ecdd7730f5400199fc92b984f1e5a4ff2..0779a594d048d1390b315dc2c9d35068b14cbcf6 100644 --- a/components/dfs/dfs_v1/filesystems/devfs/devfs.c +++ b/components/dfs/dfs_v1/filesystems/devfs/devfs.c @@ -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; diff --git a/components/dfs/dfs_v1/filesystems/elmfat/dfs_elm.c b/components/dfs/dfs_v1/filesystems/elmfat/dfs_elm.c index 7e35dac79a8a8589f192201990786e0f9e793d11..a2a6258f36ed2b45ce9e5b7d53934a17d5fc58ad 100644 --- a/components/dfs/dfs_v1/filesystems/elmfat/dfs_elm.c +++ b/components/dfs/dfs_v1/filesystems/elmfat/dfs_elm.c @@ -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; diff --git a/components/dfs/dfs_v1/filesystems/nfs/dfs_nfs.c b/components/dfs/dfs_v1/filesystems/nfs/dfs_nfs.c index aca6cf611a0bd2cafc871c2983a97ebe117e1998..9adc5b6c4214a45a8a33a1d54f334689f818bbde 100644 --- a/components/dfs/dfs_v1/filesystems/nfs/dfs_nfs.c +++ b/components/dfs/dfs_v1/filesystems/nfs/dfs_nfs.c @@ -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; diff --git a/components/dfs/dfs_v1/filesystems/ramfs/dfs_ramfs.c b/components/dfs/dfs_v1/filesystems/ramfs/dfs_ramfs.c index f31b76f0e2754713f23dc6ba21d855dd7084bc3a..fd7326bd01845c4869329b4abd0267143fb3760e 100644 --- a/components/dfs/dfs_v1/filesystems/ramfs/dfs_ramfs.c +++ b/components/dfs/dfs_v1/filesystems/ramfs/dfs_ramfs.c @@ -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) { diff --git a/components/dfs/dfs_v1/filesystems/romfs/dfs_romfs.c b/components/dfs/dfs_v1/filesystems/romfs/dfs_romfs.c index bdce2a8bb2e00a1a888ac25bac65eef1659b963f..8c80b5690e5940cf7d414eface13a0ea75ff24d5 100644 --- a/components/dfs/dfs_v1/filesystems/romfs/dfs_romfs.c +++ b/components/dfs/dfs_v1/filesystems/romfs/dfs_romfs.c @@ -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; diff --git a/components/dfs/dfs_v1/filesystems/skeleton/skeleton.c b/components/dfs/dfs_v1/filesystems/skeleton/skeleton.c index b8dc06e9b5713c9a6fc3f43a5ca0d686f96d745a..5c35cd1ffc301a8a5e2c507026e84233830971f5 100644 --- a/components/dfs/dfs_v1/filesystems/skeleton/skeleton.c +++ b/components/dfs/dfs_v1/filesystems/skeleton/skeleton.c @@ -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); } diff --git a/components/dfs/dfs_v1/filesystems/tmpfs/dfs_tmpfs.c b/components/dfs/dfs_v1/filesystems/tmpfs/dfs_tmpfs.c index 5dbd17428601b7f78e3a8bb64bcd62ae6b174fea..f8a4a8bc5889d587dc747e339786363fda88e748 100644 --- a/components/dfs/dfs_v1/filesystems/tmpfs/dfs_tmpfs.c +++ b/components/dfs/dfs_v1/filesystems/tmpfs/dfs_tmpfs.c @@ -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) { diff --git a/components/dfs/dfs_v1/include/dfs.h b/components/dfs/dfs_v1/include/dfs.h index b2575fbf4d66abcb0c46effa915c71fe046cfac8..1fbe6b77cd9cd9142e00610f2222a5f5772237de 100644 --- a/components/dfs/dfs_v1/include/dfs.h +++ b/components/dfs/dfs_v1/include/dfs.h @@ -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); diff --git a/components/dfs/dfs_v1/include/dfs_file.h b/components/dfs/dfs_v1/include/dfs_file.h index 72581273319153d81e5df2860355c1b55b708779..b81861436548937ecef58d384a61ba9b23346c78 100644 --- a/components/dfs/dfs_v1/include/dfs_file.h +++ b/components/dfs/dfs_v1/include/dfs_file.h @@ -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 (*poll) (struct dfs_fd *fd, struct rt_pollreq *req); + 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_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 diff --git a/components/dfs/dfs_v1/include/dfs_fs.h b/components/dfs/dfs_v1/include/dfs_fs.h index 985017afe027bb779b6d8f5bde85a5a9b057b536..adfed8d787a1b0f0483dcf2bc3c49d2489234429 100644 --- a/components/dfs/dfs_v1/include/dfs_fs.h +++ b/components/dfs/dfs_v1/include/dfs_fs.h @@ -21,7 +21,7 @@ extern "C" { /* Pre-declaration */ struct dfs_filesystem; -struct dfs_fd; +struct dfs_file; /* File system operations */ struct dfs_filesystem_ops diff --git a/components/dfs/dfs_v1/src/dfs.c b/components/dfs/dfs_v1/src/dfs.c index e2928f5e1b97a8fcbb195b71c322240d9b16f494..cd68bf5828ffc3c09f4df2a2944e20ca6c0623de 100644 --- a/components/dfs/dfs_v1/src/dfs.c +++ b/components/dfs/dfs_v1/src/dfs.c @@ -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) { diff --git a/components/dfs/dfs_v1/src/dfs_file.c b/components/dfs/dfs_v1/src/dfs_file.c index 56a28f5331669c5df39b079ab280a2229c66b31f..fe63fc987a40c7ccaef97ef13f6e0b093bf1d31f 100644 --- a/components/dfs/dfs_v1/src/dfs_file.c +++ b/components/dfs/dfs_v1/src/dfs_file.c @@ -16,15 +16,15 @@ #include #include -#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); diff --git a/components/dfs/dfs_v1/src/dfs_fs.c b/components/dfs/dfs_v1/src/dfs_fs.c index 7724afc7bc40d44018ed0a5d3a98230d9abc045c..e9be89106801c1fb8301ec93a84a62a06b850ba1 100644 --- a/components/dfs/dfs_v1/src/dfs_fs.c +++ b/components/dfs/dfs_v1/src/dfs_fs.c @@ -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) diff --git a/components/dfs/dfs_v1/src/dfs_posix.c b/components/dfs/dfs_v1/src/dfs_posix.c index ce1a3329d3855bd6eac2cb1fa26d0344a5bdf6b0..8c37c4afe1d7824c02836ff9f4154fad33ef8f3a 100644 --- a/components/dfs/dfs_v1/src/dfs_posix.c +++ b/components/dfs/dfs_v1/src/dfs_posix.c @@ -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) diff --git a/components/dfs/dfs_v2/filesystems/cromfs/dfs_cromfs.c b/components/dfs/dfs_v2/filesystems/cromfs/dfs_cromfs.c index f2a8424bb414c0e1d14e3c06507bf563ca603488..fee8b8dbd15349e96e246e43f1b6262e00003efe 100644 --- a/components/dfs/dfs_v2/filesystems/cromfs/dfs_cromfs.c +++ b/components/dfs/dfs_v2/filesystems/cromfs/dfs_cromfs.c @@ -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; diff --git a/components/dfs/dfs_v2/filesystems/devfs/devfs.c b/components/dfs/dfs_v2/filesystems/devfs/devfs.c index f0b7327ecdd7730f5400199fc92b984f1e5a4ff2..0779a594d048d1390b315dc2c9d35068b14cbcf6 100644 --- a/components/dfs/dfs_v2/filesystems/devfs/devfs.c +++ b/components/dfs/dfs_v2/filesystems/devfs/devfs.c @@ -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; diff --git a/components/dfs/dfs_v2/filesystems/elmfat/dfs_elm.c b/components/dfs/dfs_v2/filesystems/elmfat/dfs_elm.c index 7e35dac79a8a8589f192201990786e0f9e793d11..a2a6258f36ed2b45ce9e5b7d53934a17d5fc58ad 100644 --- a/components/dfs/dfs_v2/filesystems/elmfat/dfs_elm.c +++ b/components/dfs/dfs_v2/filesystems/elmfat/dfs_elm.c @@ -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; diff --git a/components/dfs/dfs_v2/filesystems/nfs/dfs_nfs.c b/components/dfs/dfs_v2/filesystems/nfs/dfs_nfs.c index aca6cf611a0bd2cafc871c2983a97ebe117e1998..9adc5b6c4214a45a8a33a1d54f334689f818bbde 100644 --- a/components/dfs/dfs_v2/filesystems/nfs/dfs_nfs.c +++ b/components/dfs/dfs_v2/filesystems/nfs/dfs_nfs.c @@ -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; diff --git a/components/dfs/dfs_v2/filesystems/ramfs/dfs_ramfs.c b/components/dfs/dfs_v2/filesystems/ramfs/dfs_ramfs.c index f31b76f0e2754713f23dc6ba21d855dd7084bc3a..fd7326bd01845c4869329b4abd0267143fb3760e 100644 --- a/components/dfs/dfs_v2/filesystems/ramfs/dfs_ramfs.c +++ b/components/dfs/dfs_v2/filesystems/ramfs/dfs_ramfs.c @@ -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) { diff --git a/components/dfs/dfs_v2/filesystems/romfs/dfs_romfs.c b/components/dfs/dfs_v2/filesystems/romfs/dfs_romfs.c index bdce2a8bb2e00a1a888ac25bac65eef1659b963f..8c80b5690e5940cf7d414eface13a0ea75ff24d5 100644 --- a/components/dfs/dfs_v2/filesystems/romfs/dfs_romfs.c +++ b/components/dfs/dfs_v2/filesystems/romfs/dfs_romfs.c @@ -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; diff --git a/components/dfs/dfs_v2/filesystems/skeleton/skeleton.c b/components/dfs/dfs_v2/filesystems/skeleton/skeleton.c index b8dc06e9b5713c9a6fc3f43a5ca0d686f96d745a..5c35cd1ffc301a8a5e2c507026e84233830971f5 100644 --- a/components/dfs/dfs_v2/filesystems/skeleton/skeleton.c +++ b/components/dfs/dfs_v2/filesystems/skeleton/skeleton.c @@ -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); } diff --git a/components/dfs/dfs_v2/filesystems/tmpfs/dfs_tmpfs.c b/components/dfs/dfs_v2/filesystems/tmpfs/dfs_tmpfs.c index 5dbd17428601b7f78e3a8bb64bcd62ae6b174fea..f8a4a8bc5889d587dc747e339786363fda88e748 100644 --- a/components/dfs/dfs_v2/filesystems/tmpfs/dfs_tmpfs.c +++ b/components/dfs/dfs_v2/filesystems/tmpfs/dfs_tmpfs.c @@ -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) { diff --git a/components/dfs/dfs_v2/include/dfs.h b/components/dfs/dfs_v2/include/dfs.h index b2575fbf4d66abcb0c46effa915c71fe046cfac8..450100fc328173dad64e633cfbedd9d69708a50b 100644 --- a/components/dfs/dfs_v2/include/dfs.h +++ b/components/dfs/dfs_v2/include/dfs.h @@ -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); diff --git a/components/dfs/dfs_v2/include/dfs_file.h b/components/dfs/dfs_v2/include/dfs_file.h index 72581273319153d81e5df2860355c1b55b708779..b81861436548937ecef58d384a61ba9b23346c78 100644 --- a/components/dfs/dfs_v2/include/dfs_file.h +++ b/components/dfs/dfs_v2/include/dfs_file.h @@ -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 (*poll) (struct dfs_fd *fd, struct rt_pollreq *req); + 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_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 diff --git a/components/dfs/dfs_v2/include/dfs_fs.h b/components/dfs/dfs_v2/include/dfs_fs.h index 985017afe027bb779b6d8f5bde85a5a9b057b536..adfed8d787a1b0f0483dcf2bc3c49d2489234429 100644 --- a/components/dfs/dfs_v2/include/dfs_fs.h +++ b/components/dfs/dfs_v2/include/dfs_fs.h @@ -21,7 +21,7 @@ extern "C" { /* Pre-declaration */ struct dfs_filesystem; -struct dfs_fd; +struct dfs_file; /* File system operations */ struct dfs_filesystem_ops diff --git a/components/dfs/dfs_v2/src/dfs.c b/components/dfs/dfs_v2/src/dfs.c index e2928f5e1b97a8fcbb195b71c322240d9b16f494..cd68bf5828ffc3c09f4df2a2944e20ca6c0623de 100644 --- a/components/dfs/dfs_v2/src/dfs.c +++ b/components/dfs/dfs_v2/src/dfs.c @@ -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) { diff --git a/components/dfs/dfs_v2/src/dfs_file.c b/components/dfs/dfs_v2/src/dfs_file.c index 56a28f5331669c5df39b079ab280a2229c66b31f..30dc0ac8bf0b74fa8553a10a33898dcfedea26c7 100644 --- a/components/dfs/dfs_v2/src/dfs_file.c +++ b/components/dfs/dfs_v2/src/dfs_file.c @@ -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); diff --git a/components/dfs/dfs_v2/src/dfs_fs.c b/components/dfs/dfs_v2/src/dfs_fs.c index 7724afc7bc40d44018ed0a5d3a98230d9abc045c..e9be89106801c1fb8301ec93a84a62a06b850ba1 100644 --- a/components/dfs/dfs_v2/src/dfs_fs.c +++ b/components/dfs/dfs_v2/src/dfs_fs.c @@ -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) diff --git a/components/dfs/dfs_v2/src/dfs_posix.c b/components/dfs/dfs_v2/src/dfs_posix.c index ce1a3329d3855bd6eac2cb1fa26d0344a5bdf6b0..8c37c4afe1d7824c02836ff9f4154fad33ef8f3a 100644 --- a/components/dfs/dfs_v2/src/dfs_posix.c +++ b/components/dfs/dfs_v2/src/dfs_posix.c @@ -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) diff --git a/components/drivers/ipc/pipe.c b/components/drivers/ipc/pipe.c index ccb953bc2300c2090a2e1c2a5ce16ce44af91597..1d8a41f00d6040c9e8c61d48eb2e03b4bb230a47 100644 --- a/components/drivers/ipc/pipe.c +++ b/components/drivers/ipc/pipe.c @@ -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; diff --git a/components/drivers/misc/rt_dev_bus.c b/components/drivers/misc/rt_dev_bus.c index 5e858d17815e2000a52fb54ee4a31f71f5b7a0b4..d24b2b03b81606ae66ad630794d83c19579ae7d7 100644 --- a/components/drivers/misc/rt_dev_bus.c +++ b/components/drivers/misc/rt_dev_bus.c @@ -25,13 +25,13 @@ #include #include -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; diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index 582a6ed90a03e1af50570488581fcf30b044e9d0..1d78140015c479b9f57193bcf624e2439a908a8b 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -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; diff --git a/components/drivers/serial/serial_v2.c b/components/drivers/serial/serial_v2.c index c88df7aabe948978878667686265bdadeeeec47f..68f9068601cc9359d35c973a756060ec51217621 100644 --- a/components/drivers/serial/serial_v2.c +++ b/components/drivers/serial/serial_v2.c @@ -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; diff --git a/components/drivers/tty/include/tty_ldisc.h b/components/drivers/tty/include/tty_ldisc.h index 919805f64570dd88cdce6e1f887d86bb4a096108..619bca6dec37b3392d315d720e62cd18c8f09e5f 100644 --- a/components/drivers/tty/include/tty_ldisc.h +++ b/components/drivers/tty/include/tty_ldisc.h @@ -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 (*poll) (struct dfs_fd *fd, struct rt_pollreq *req); + 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_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); diff --git a/components/drivers/tty/n_tty.c b/components/drivers/tty/n_tty.c index ba27ae134b8ee0c069dbbc097a0f38b3e18ef40c..00448dd6369bdec0b07d9f04333e4f69c500a379 100644 --- a/components/drivers/tty/n_tty.c +++ b/components/drivers/tty/n_tty.c @@ -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; diff --git a/components/drivers/tty/pty.c b/components/drivers/tty/pty.c index 64e3a41df182be358ecfcf6c9477d5cf1f8cb908..0db50360bd7824e7f50f440485f0e77fe885e5ba 100644 --- a/components/drivers/tty/pty.c +++ b/components/drivers/tty/pty.c @@ -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; diff --git a/components/drivers/tty/tty.c b/components/drivers/tty/tty.c index 933d5f028bc35b4e49f033bf77540c07d1d3a82f..1573b13a7b54b66842b095ca05152515d6ec2b3f 100644 --- a/components/drivers/tty/tty.c +++ b/components/drivers/tty/tty.c @@ -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; diff --git a/components/fal/src/fal_rtt.c b/components/fal/src/fal_rtt.c index a40832f31c98164b3f4462a8c494b5123bc95be7..89dcdf47228b100bc924845f5b7032be756e5605 100644 --- a/components/fal/src/fal_rtt.c +++ b/components/fal/src/fal_rtt.c @@ -406,7 +406,7 @@ const static struct rt_device_ops char_dev_ops = #include /* 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; diff --git a/components/libc/posix/io/poll/poll.c b/components/libc/posix/io/poll/poll.c index 9fcf0f2063ffc3c23a4aaebced3adee69a8bec65..3a94ee9abd9a303c9009eb594e6bac1936864e7b 100644 --- a/components/libc/posix/io/poll/poll.c +++ b/components/libc/posix/io/poll/poll.c @@ -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) diff --git a/components/lwp/lwp.c b/components/lwp/lwp.c index 0af0399cc670e4e891fb7a663cf90fc785d48656..375ac9b317e76875a4f509a8b34e49ed8818d776 100644 --- a/components/lwp/lwp.c +++ b/components/lwp/lwp.c @@ -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; diff --git a/components/lwp/lwp_ipc.c b/components/lwp/lwp_ipc.c index f6219479b9bbd6924a19ff618ea6971866a99ea3..97d29ce98d3d08ea6abbf999b00eefd2a8a13498 100644 --- a/components/lwp/lwp_ipc.c +++ b/components/lwp/lwp_ipc.c @@ -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) diff --git a/components/lwp/lwp_pid.c b/components/lwp/lwp_pid.c index d22c3f3d68763a6cd11258c84078c52fa51490f9..d015c76cab90dd614d570d52f5197e6b57f53e2e 100644 --- a/components/lwp/lwp_pid.c +++ b/components/lwp/lwp_pid.c @@ -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) diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index 77eb77f556d17fcd2ad0dc38bdc3100f57b0b5b2..8d07a9388d4ecc10acd8cf0979f91c71adb08870 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -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; diff --git a/components/lwp/lwp_user_mm.c b/components/lwp/lwp_user_mm.c index 09cc47dd2bb7a6379efea9dfeeabfee57feca646..068073ec0b80cb506e40b62f6c3315ae43bd64f3 100644 --- a/components/lwp/lwp_user_mm.c +++ b/components/lwp/lwp_user_mm.c @@ -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) diff --git a/components/net/sal/dfs_net/dfs_net.c b/components/net/sal/dfs_net/dfs_net.c index 2aded9fcd80f60003dffdb54dea020965c4c4247..bb7176f4360b8471761000baacd0023b64f5ffe1 100644 --- a/components/net/sal/dfs_net/dfs_net.c +++ b/components/net/sal/dfs_net/dfs_net.c @@ -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); } diff --git a/components/net/sal/impl/af_inet_at.c b/components/net/sal/impl/af_inet_at.c index 30c5324447e51ebe5d733ca1f8151e7e27b4611c..4e94d1e96c40bd650e627bf8d47ec54a95750456 100644 --- a/components/net/sal/impl/af_inet_at.c +++ b/components/net/sal/impl/af_inet_at.c @@ -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; diff --git a/components/net/sal/impl/af_inet_lwip.c b/components/net/sal/impl/af_inet_lwip.c index 52c1c2cb7d5d798122e79182e851452ce80e3ad6..37da37b1379e5756dce05945d94a407b26444ecf 100644 --- a/components/net/sal/impl/af_inet_lwip.c +++ b/components/net/sal/impl/af_inet_lwip.c @@ -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; diff --git a/components/net/sal/include/sal_low_lvl.h b/components/net/sal/include/sal_low_lvl.h index 95f984cca8796e5d0f5481de1e27f13d77b3d027..1b1959a3e9e194f3d05cd28fd1b6c6aa6069e70b 100644 --- a/components/net/sal/include/sal_low_lvl.h +++ b/components/net/sal/include/sal_low_lvl.h @@ -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 }; diff --git a/components/net/sal/socket/net_sockets.c b/components/net/sal/socket/net_sockets.c index e10ffef9b0214f2915fa27509389d466e2c1690f..ed8a6c6b1d51f0f26121cb00585b4f9b7ae387bd 100644 --- a/components/net/sal/socket/net_sockets.c +++ b/components/net/sal/socket/net_sockets.c @@ -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) diff --git a/components/net/sal/src/sal_socket.c b/components/net/sal/src/sal_socket.c index d1f9f645e629fcd16867b7ff7b458aef91597278..136a8428dab7bdf4101a2d28a079364a4a93c140 100644 --- a/components/net/sal/src/sal_socket.c +++ b/components/net/sal/src/sal_socket.c @@ -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; diff --git a/components/utilities/rt-link/src/rtlink_dev.c b/components/utilities/rt-link/src/rtlink_dev.c index db94e93de34f4f1d8a6df203a1bc7c8ed00214a2..ab21004ef9de6ee569a63759b52bc7e894ccf8cb 100644 --- a/components/utilities/rt-link/src/rtlink_dev.c +++ b/components/utilities/rt-link/src/rtlink_dev.c @@ -25,7 +25,7 @@ #include #include -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; diff --git a/documentation/sal/sal.md b/documentation/sal/sal.md index e4a9a58e74a02ce162f3c258d02d47de920e92f9..8e768f4f063018c722a31ef51a5802691947a8cc 100644 --- a/documentation/sal/sal.md +++ b/documentation/sal/sal.md @@ -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;