summaryrefslogtreecommitdiff
path: root/components/dfs
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2015-10-23 22:10:13 +0800
committerBernard Xiong <[email protected]>2015-10-23 22:10:13 +0800
commit3677f4de9ffbd1211112d3a8791cf0091432c60c (patch)
treee47ef2d988cb6ae3e95351ba33e1fda01665e089 /components/dfs
parent20b8293a8413ae22038ff64257541ee07b72bf35 (diff)
parent78193f3c40efd9bb7cffe515bf5ffcc68da08573 (diff)
Merge branch 'master' of https://github.com/RT-Thread/rt-thread
Diffstat (limited to 'components/dfs')
-rw-r--r--components/dfs/filesystems/devfs/devfs.c6
-rw-r--r--components/dfs/filesystems/elmfat/dfs_elm.c1
-rw-r--r--components/dfs/filesystems/jffs2/dfs_jffs2.c3
-rw-r--r--components/dfs/filesystems/lwip/lwip_netdb.c3
-rw-r--r--components/dfs/filesystems/lwip/lwip_select.c1
-rw-r--r--components/dfs/filesystems/lwip/lwip_sockets.c149
-rw-r--r--components/dfs/filesystems/lwip/sys/socket.h2
-rw-r--r--components/dfs/filesystems/nfs/dfs_nfs.c1
-rw-r--r--components/dfs/filesystems/ramfs/dfs_ramfs.c1
-rw-r--r--components/dfs/filesystems/romfs/dfs_romfs.c4
-rw-r--r--components/dfs/filesystems/uffs/dfs_uffs.c3
-rw-r--r--components/dfs/include/dfs_def.h5
-rw-r--r--components/dfs/src/dfs_file.c1
-rw-r--r--components/dfs/src/dfs_posix.c1
14 files changed, 97 insertions, 84 deletions
diff --git a/components/dfs/filesystems/devfs/devfs.c b/components/dfs/filesystems/devfs/devfs.c
index 1f4569558f..fcbb738572 100644
--- a/components/dfs/filesystems/devfs/devfs.c
+++ b/components/dfs/filesystems/devfs/devfs.c
@@ -213,8 +213,7 @@ int dfs_device_fs_stat(struct dfs_filesystem *fs, const char *path, struct stat
st->st_size = 0;
st->st_mtime = 0;
- st->st_blksize = 512;
-
+
return DFS_STATUS_OK;
}
else
@@ -238,8 +237,7 @@ int dfs_device_fs_stat(struct dfs_filesystem *fs, const char *path, struct stat
st->st_size = 0;
st->st_mtime = 0;
- st->st_blksize = 512;
-
+
return DFS_STATUS_OK;
}
}
diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c
index 3658a5dc80..ca2c082972 100644
--- a/components/dfs/filesystems/elmfat/dfs_elm.c
+++ b/components/dfs/filesystems/elmfat/dfs_elm.c
@@ -738,7 +738,6 @@ int dfs_elm_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
st->st_mode &= ~(DFS_S_IWUSR | DFS_S_IWGRP | DFS_S_IWOTH);
st->st_size = file_info.fsize;
- st->st_blksize = 512;
/* get st_mtime. */
{
diff --git a/components/dfs/filesystems/jffs2/dfs_jffs2.c b/components/dfs/filesystems/jffs2/dfs_jffs2.c
index 6516797544..78c7730136 100644
--- a/components/dfs/filesystems/jffs2/dfs_jffs2.c
+++ b/components/dfs/filesystems/jffs2/dfs_jffs2.c
@@ -331,7 +331,7 @@ static int dfs_jffs2_open(struct dfs_fd* file)
return jffs2_result_to_dfs(result);
}
- /* save this pointer, it will be used when calling read()��write(),
+ /* save this pointer, it will be used when calling read()��write(),
flush(), lessk(), and will be rt_free when calling close()*/
file->data = jffs2_file;
file->pos = jffs2_file->f_offset;
@@ -686,7 +686,6 @@ static int dfs_jffs2_stat(struct dfs_filesystem* fs, const char *path, struct st
st->st_dev = 0;
st->st_size = s.st_size;
st->st_mtime = s.st_mtime;
- st->st_blksize = 1;//fixme: what's this field?
return 0;
}
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/nfs/dfs_nfs.c b/components/dfs/filesystems/nfs/dfs_nfs.c
index 7ff5fef5f7..4bf96c2aeb 100644
--- a/components/dfs/filesystems/nfs/dfs_nfs.c
+++ b/components/dfs/filesystems/nfs/dfs_nfs.c
@@ -850,7 +850,6 @@ int nfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
st->st_size = info->size;
st->st_mtime = info->mtime.seconds;
- st->st_blksize = 512;
xdr_free((xdrproc_t)xdr_GETATTR3res, (char *)&res);
xdr_free((xdrproc_t)xdr_nfs_fh3, (char *)handle);
diff --git a/components/dfs/filesystems/ramfs/dfs_ramfs.c b/components/dfs/filesystems/ramfs/dfs_ramfs.c
index fecebe4688..7533b6f192 100644
--- a/components/dfs/filesystems/ramfs/dfs_ramfs.c
+++ b/components/dfs/filesystems/ramfs/dfs_ramfs.c
@@ -292,7 +292,6 @@ int dfs_ramfs_stat(struct dfs_filesystem *fs,
st->st_size = dirent->size;
st->st_mtime = 0;
- st->st_blksize = 512;
return DFS_STATUS_OK;
}
diff --git a/components/dfs/filesystems/romfs/dfs_romfs.c b/components/dfs/filesystems/romfs/dfs_romfs.c
index 65fc331466..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;
@@ -245,7 +246,6 @@ int dfs_romfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
st->st_size = dirent->size;
st->st_mtime = 0;
- st->st_blksize = 512;
return DFS_STATUS_OK;
}
diff --git a/components/dfs/filesystems/uffs/dfs_uffs.c b/components/dfs/filesystems/uffs/dfs_uffs.c
index faaee0990e..87517aaaf5 100644
--- a/components/dfs/filesystems/uffs/dfs_uffs.c
+++ b/components/dfs/filesystems/uffs/dfs_uffs.c
@@ -347,7 +347,7 @@ static int dfs_uffs_open(struct dfs_fd* file)
return uffs_result_to_dfs(uffs_get_error());
}
- /* save this pointer, it will be used when calling read()��write(),
+ /* save this pointer, it will be used when calling read()��write(),
* flush(), seek(), and will be free when calling close()*/
file->data = (void *)fd;
@@ -619,7 +619,6 @@ static int dfs_uffs_stat(struct dfs_filesystem* fs, const char *path, struct sta
st->st_mtime = s.st_mtime;
mtd = RT_MTD_NAND_DEVICE(fs->dev_id);
- st->st_blksize = mtd->page_size;
return 0;
}
diff --git a/components/dfs/include/dfs_def.h b/components/dfs/include/dfs_def.h
index a73ff4ec8b..0f75a5162b 100644
--- a/components/dfs/include/dfs_def.h
+++ b/components/dfs/include/dfs_def.h
@@ -255,14 +255,17 @@
#define DFS_S_IWOTH 00002
#define DFS_S_IXOTH 00001
+#ifdef _MSC_VER
+#include <wchar.h>
+#else
struct stat
{
rt_device_t st_dev;
rt_uint16_t st_mode;
rt_uint32_t st_size;
rt_time_t st_mtime;
- rt_uint32_t st_blksize;
};
+#endif
struct statfs
{
diff --git a/components/dfs/src/dfs_file.c b/components/dfs/src/dfs_file.c
index aebe2996c6..752933b66f 100644
--- a/components/dfs/src/dfs_file.c
+++ b/components/dfs/src/dfs_file.c
@@ -392,7 +392,6 @@ int dfs_file_stat(const char *path, struct stat *buf)
buf->st_size = 0;
buf->st_mtime = 0;
- buf->st_blksize = 512;
/* release full path */
rt_free(fullpath);
diff --git a/components/dfs/src/dfs_posix.c b/components/dfs/src/dfs_posix.c
index c379d5c969..52a9139d80 100644
--- a/components/dfs/src/dfs_posix.c
+++ b/components/dfs/src/dfs_posix.c
@@ -368,7 +368,6 @@ int fstat(int fildes, struct stat *buf)
buf->st_size = d->size;
buf->st_mtime = 0;
- buf->st_blksize = 512;
fd_put(d);