From bf8bb9db6adfadc8102952b7b30565c54f6b0b4d Mon Sep 17 00:00:00 2001 From: qiuyiuestc Date: Sun, 13 Dec 2009 16:07:36 +0000 Subject: [PATCH] Fix lm3s ftp upload problem git-svn-id: https://rt-thread.googlecode.com/svn/trunk@199 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- bsp/lm3s/rtconfig.h | 7 +++++-- filesystem/dfs/filesystems/efsl/src/base/efs.c | 5 +++-- net/apps/ftpd.c | 9 +++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/bsp/lm3s/rtconfig.h b/bsp/lm3s/rtconfig.h index ace5102928..38675c208e 100644 --- a/bsp/lm3s/rtconfig.h +++ b/bsp/lm3s/rtconfig.h @@ -84,9 +84,9 @@ #define RT_USING_DFS /* SECTION: DFS options */ /* the max number of mounted filesystem */ -#define DFS_FILESYSTEMS_MAX 1 +#define DFS_FILESYSTEMS_MAX 1 /* the max number of opened files */ -#define DFS_FD_MAX 2 +#define DFS_FD_MAX 4 /* the max number of cached sector */ #define DFS_CACHE_MAX_NUM 4 @@ -112,6 +112,9 @@ /* the number of simulatenously active TCP connections*/ #define RT_LWIP_TCP_PCB_NUM 5 +/* Ethernet padding size */ +#define RT_LWIP_ETH_PAD_SIZE 2 + /* TCP sender buffer space*/ #define RT_LWIP_TCP_SND_BUF 1500 /* Enable SNMP protocol*/ diff --git a/filesystem/dfs/filesystems/efsl/src/base/efs.c b/filesystem/dfs/filesystems/efsl/src/base/efs.c index edb414b22c..49fec4e806 100644 --- a/filesystem/dfs/filesystems/efsl/src/base/efs.c +++ b/filesystem/dfs/filesystems/efsl/src/base/efs.c @@ -165,7 +165,8 @@ int efs_open(struct dfs_fd* file) efsdir = (DirList*)rt_malloc(sizeof(DirList)); if(efsdir == RT_NULL) { - dfs_log(DFS_DEBUG_INFO, ("memory alloc failed")); + dfs_log(DFS_DEBUG_ERROR, ("memory alloc failed")); + rt_free(efsdir); return -DFS_STATUS_ENOMEM; } @@ -186,7 +187,7 @@ int efs_open(struct dfs_fd* file) efsfile = (File *)rt_malloc(sizeof(File)); if (efsfile == RT_NULL) { - dfs_log(DFS_DEBUG_INFO, ("memory alloc failed")); + dfs_log(DFS_DEBUG_ERROR, ("memory alloc failed")); return -DFS_STATUS_ENOMEM; } diff --git a/net/apps/ftpd.c b/net/apps/ftpd.c index e0c6597c31..e879b9da03 100644 --- a/net/apps/ftpd.c +++ b/net/apps/ftpd.c @@ -246,7 +246,7 @@ int do_list(char* directory, int sockfd) entry = readdir(dirp); if (entry == NULL) break; - rt_sprintf(line_buffer, "%s/%s", directory, entry->d_name); + rt_sprintf(line_buffer, "%s/%s", directory, entry->d_name); #ifdef _WIN32 if (_stat(line_buffer, &s) ==0) #else @@ -262,6 +262,7 @@ int do_list(char* directory, int sockfd) } } + closedir(dirp); return 0; } @@ -288,6 +289,7 @@ int do_simple_list(char* directory, int sockfd) send(sockfd, line_buffer, line_length, 0); } + closedir(dirp); return 0; } @@ -351,6 +353,7 @@ int ftp_process_request(struct ftp_session* session, char *buf) } else if (strcmp(parameter_ptr, FTP_USER) == 0) { + session->is_anonymous = RT_FALSE; rt_sprintf(sbuf, "331 Password required for %s\r\n", parameter_ptr); send(session->sockfd, sbuf, strlen(sbuf), 0); } @@ -552,10 +555,12 @@ err1: FD_ZERO(&readfds); FD_SET(session->pasv_sockfd, &readfds); rt_kprintf("Waiting %d seconds for data...\n", tv.tv_sec); - while(select(0, &readfds, 0, 0, &tv)>0 ) + while(select(session->pasv_sockfd+1, &readfds, 0, 0, &tv)>0 ) { if((numbytes=recv(session->pasv_sockfd, sbuf, FTP_BUFFER_SIZE, 0))>0) + { write(fd, sbuf, numbytes); + } else if(numbytes==0) { close(fd);