diff options
Diffstat (limited to 'components/dfs')
| -rw-r--r-- | components/dfs/filesystems/lwip/lwip_netdb.c | 3 | ||||
| -rw-r--r-- | components/dfs/filesystems/lwip/lwip_select.c | 1 | ||||
| -rw-r--r-- | components/dfs/filesystems/lwip/lwip_sockets.c | 149 | ||||
| -rw-r--r-- | components/dfs/filesystems/lwip/sys/socket.h | 2 | ||||
| -rw-r--r-- | components/dfs/filesystems/romfs/dfs_romfs.c | 3 | ||||
| -rw-r--r-- | components/dfs/include/dfs_def.h | 4 |
6 files changed, 93 insertions, 69 deletions
diff --git a/components/dfs/filesystems/lwip/lwip_netdb.c b/components/dfs/filesystems/lwip/lwip_netdb.c index 6871474251..1e14dfb093 100644 --- a/components/dfs/filesystems/lwip/lwip_netdb.c +++ b/components/dfs/filesystems/lwip/lwip_netdb.c @@ -29,6 +29,7 @@ struct hostent *gethostbyname(const char *name) { return lwip_gethostbyname(name); } +RTM_EXPORT(gethostbyname); int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop) @@ -40,6 +41,7 @@ void freeaddrinfo(struct addrinfo *ai) { lwip_freeaddrinfo(ai); } +RTM_EXPORT(freeaddrinfo); int getaddrinfo(const char *nodename, const char *servname, @@ -48,3 +50,4 @@ int getaddrinfo(const char *nodename, { return lwip_getaddrinfo(nodename, servname, hints, res); } +RTM_EXPORT(getaddrinfo); diff --git a/components/dfs/filesystems/lwip/lwip_select.c b/components/dfs/filesystems/lwip/lwip_select.c index 3477b6f1d6..31d9190cfc 100644 --- a/components/dfs/filesystems/lwip/lwip_select.c +++ b/components/dfs/filesystems/lwip/lwip_select.c @@ -118,5 +118,6 @@ select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, return result; } +RTM_EXPORT(select); #endif diff --git a/components/dfs/filesystems/lwip/lwip_sockets.c b/components/dfs/filesystems/lwip/lwip_sockets.c index 346ef7b266..6b68378f7d 100644 --- a/components/dfs/filesystems/lwip/lwip_sockets.c +++ b/components/dfs/filesystems/lwip/lwip_sockets.c @@ -32,154 +32,167 @@ int accept(int s, struct sockaddr *addr, socklen_t *addrlen) { - int new_client = -1; + int new_client = -1; int sock = dfs_lwip_getsocket(s); new_client = lwip_accept(sock, addr, addrlen); - if (new_client != -1) - { - /* this is a new socket, create it in file system fd */ - int fd; - struct dfs_fd *d; - - /* allocate a fd */ - fd = fd_new(); - if (fd < 0) - { - rt_set_errno(-DFS_STATUS_ENOMEM); - lwip_close(sock); + if (new_client != -1) + { + /* this is a new socket, create it in file system fd */ + int fd; + struct dfs_fd *d; - printf("no fd yet!\n"); - return -1; - } - d = fd_get(fd); + /* allocate a fd */ + fd = fd_new(); + if (fd < 0) + { + rt_set_errno(-DFS_STATUS_ENOMEM); + lwip_close(sock); - /* this is a socket fd */ - d->type = FT_SOCKET; - d->path = RT_NULL; - - d->fs = dfs_lwip_get_fs(); - - d->flags = DFS_O_RDWR; /* set flags as read and write */ - d->size = 0; - d->pos = 0; + rt_kprintf("no fd yet!\n"); + return -1; + } + d = fd_get(fd); - /* set socket to the data of dfs_fd */ - d->data = (void*) new_client; + /* this is a socket fd */ + d->type = FT_SOCKET; + d->path = RT_NULL; + + d->fs = dfs_lwip_get_fs(); + + d->flags = DFS_O_RDWR; /* set flags as read and write */ + d->size = 0; + d->pos = 0; + + /* set socket to the data of dfs_fd */ + d->data = (void *) new_client; + + /* release the ref-count of fd */ + fd_put(d); - /* release the ref-count of fd */ - fd_put(d); - return fd; - } + } - return new_client; + return new_client; } +RTM_EXPORT(accept); int bind(int s, const struct sockaddr *name, socklen_t namelen) { int sock = dfs_lwip_getsocket(s); - + return lwip_bind(sock, name, namelen); } +RTM_EXPORT(bind); int shutdown(int s, int how) { int sock; - struct dfs_fd *d; + struct dfs_fd *d; - d = fd_get(s); - if (d == RT_NULL) - { - rt_set_errno(-DFS_STATUS_EBADF); - - return -1; - } + d = fd_get(s); + if (d == RT_NULL) + { + rt_set_errno(-DFS_STATUS_EBADF); - sock = dfs_lwip_getsocket(s); + return -1; + } + + sock = dfs_lwip_getsocket(s); if (lwip_shutdown(sock, how) == 0) { - /* socket has been closed, delete it from file system fd */ - fd_put(d); - fd_put(d); - - return 0; + /* socket has been closed, delete it from file system fd */ + fd_put(d); + fd_put(d); + + return 0; } - return -1; + return -1; } +RTM_EXPORT(shutdown); -int getpeername (int s, struct sockaddr *name, socklen_t *namelen) +int getpeername(int s, struct sockaddr *name, socklen_t *namelen) { int sock = dfs_lwip_getsocket(s); return lwip_getpeername(sock, name, namelen); } +RTM_EXPORT(getpeername); -int getsockname (int s, struct sockaddr *name, socklen_t *namelen) +int getsockname(int s, struct sockaddr *name, socklen_t *namelen) { int sock = dfs_lwip_getsocket(s); - + return lwip_getsockname(sock, name, namelen); } +RTM_EXPORT(getsockname); -int getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen) +int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) { int sock = dfs_lwip_getsocket(s); - + return lwip_getsockopt(sock, level, optname, optval, optlen); } +RTM_EXPORT(getsockopt); -int setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen) +int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen) { int sock = dfs_lwip_getsocket(s); - + return lwip_setsockopt(sock, level, optname, optval, optlen); } +RTM_EXPORT(setsockopt); int connect(int s, const struct sockaddr *name, socklen_t namelen) { int sock = dfs_lwip_getsocket(s); - + return lwip_connect(sock, name, namelen); } +RTM_EXPORT(connect); int listen(int s, int backlog) { int sock = dfs_lwip_getsocket(s); - + return lwip_listen(sock, backlog); } +RTM_EXPORT(listen); int recv(int s, void *mem, size_t len, int flags) { int sock = dfs_lwip_getsocket(s); - + return lwip_recv(sock, mem, len, flags); } +RTM_EXPORT(recv); int recvfrom(int s, void *mem, size_t len, int flags, - struct sockaddr *from, socklen_t *fromlen) + struct sockaddr *from, socklen_t *fromlen) { int sock = dfs_lwip_getsocket(s); - + return lwip_recvfrom(sock, mem, len, flags, from, fromlen); } +RTM_EXPORT(recvfrom); int send(int s, const void *dataptr, size_t size, int flags) { int sock = dfs_lwip_getsocket(s); - + return lwip_send(sock, dataptr, size, flags); } +RTM_EXPORT(send); int sendto(int s, const void *dataptr, size_t size, int flags, - const struct sockaddr *to, socklen_t tolen) + const struct sockaddr *to, socklen_t tolen) { int sock = dfs_lwip_getsocket(s); - + return lwip_sendto(sock, dataptr, size, flags, to, tolen); } +RTM_EXPORT(sendto); int socket(int domain, int type, int protocol) { @@ -207,13 +220,13 @@ int socket(int domain, int type, int protocol) d->path = RT_NULL; d->fs = dfs_lwip_get_fs(); - + d->flags = DFS_O_RDWR; /* set flags as read and write */ d->size = 0; d->pos = 0; - + /* set socket to the data of dfs_fd */ - d->data = (void*) sock; + d->data = (void *) sock; } /* release the ref-count of fd */ @@ -221,4 +234,4 @@ int socket(int domain, int type, int protocol) return fd; } - +RTM_EXPORT(socket); diff --git a/components/dfs/filesystems/lwip/sys/socket.h b/components/dfs/filesystems/lwip/sys/socket.h index 5317e05e4c..b9608d97ed 100644 --- a/components/dfs/filesystems/lwip/sys/socket.h +++ b/components/dfs/filesystems/lwip/sys/socket.h @@ -29,9 +29,11 @@ extern "C" { #endif +#include <inttypes.h> #include <lwip/sockets.h> typedef uint16_t sa_family_t; +typedef uint16_t in_port_t; struct sockaddr_storage { diff --git a/components/dfs/filesystems/romfs/dfs_romfs.c b/components/dfs/filesystems/romfs/dfs_romfs.c index 1dd41b41eb..6110d61227 100644 --- a/components/dfs/filesystems/romfs/dfs_romfs.c +++ b/components/dfs/filesystems/romfs/dfs_romfs.c @@ -96,7 +96,8 @@ struct romfs_dirent *dfs_romfs_lookup(struct romfs_dirent *root_dirent, const ch { if (check_dirent(&dirent[index]) != 0) return RT_NULL; - if (rt_strncmp(dirent[index].name, subpath, (subpath_end - subpath)) == 0) + if (rt_strlen(dirent[index].name) == (subpath_end - subpath) && + rt_strncmp(dirent[index].name, subpath, (subpath_end - subpath)) == 0) { dirent_size = dirent[index].size; diff --git a/components/dfs/include/dfs_def.h b/components/dfs/include/dfs_def.h index e509c4a3da..0f75a5162b 100644 --- a/components/dfs/include/dfs_def.h +++ b/components/dfs/include/dfs_def.h @@ -255,6 +255,9 @@ #define DFS_S_IWOTH 00002 #define DFS_S_IXOTH 00001 +#ifdef _MSC_VER +#include <wchar.h> +#else struct stat { rt_device_t st_dev; @@ -262,6 +265,7 @@ struct stat rt_uint32_t st_size; rt_time_t st_mtime; }; +#endif struct statfs { |
