From 983847569a63f63bc131af7e66f18f6cee4a3b22 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 15 Feb 2012 22:41:17 +0000 Subject: Minor FTPD updates git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4397 42af7a65-404d-4744-a932-0658087f49c3 --- apps/netutils/ftpd/ftpd.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'apps/netutils/ftpd') diff --git a/apps/netutils/ftpd/ftpd.c b/apps/netutils/ftpd/ftpd.c index ff27d794a..949f0410e 100755 --- a/apps/netutils/ftpd/ftpd.c +++ b/apps/netutils/ftpd/ftpd.c @@ -1758,6 +1758,9 @@ static int ftpd_stream(FAR struct ftpd_session_s *session, int cmdtype) #if defined(O_BINARY) oflags |= O_BINARY; #endif + + /* Are we creating the file? */ + if ((oflags & O_CREAT) != 0) { int mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH; @@ -1777,6 +1780,8 @@ static int ftpd_stream(FAR struct ftpd_session_s *session, int cmdtype) } else { + /* No.. we are opening an existing file */ + isnew = false; session->fd = open(path, oflags); } @@ -1828,7 +1833,7 @@ static int ftpd_stream(FAR struct ftpd_session_s *session, int cmdtype) { int errval = errno; ndbg("lseek failed: %d\n", errval); - ret = -errno; + ret = -errval; } } @@ -1869,8 +1874,7 @@ static int ftpd_stream(FAR struct ftpd_session_s *session, int cmdtype) if (cmdtype == 0) { - rdbytes = (ssize_t)read(session->fd, session->data.buffer, - wantsize); + rdbytes = read(session->fd, session->data.buffer, wantsize); } else { @@ -1880,7 +1884,7 @@ static int ftpd_stream(FAR struct ftpd_session_s *session, int cmdtype) if (rdbytes < 0) { - ndbg("ftp_recv failed: %d\n", rdbytes); + ndbg("Read failed: rdbytes=%d errno=%d\n", rdbytes, errno); (void)ftpd_response(session->cmd.sd, session->txtimeout, g_respfmt1, 550, ' ', "Data read error !"); ret = rdbytes; @@ -1940,6 +1944,7 @@ static int ftpd_stream(FAR struct ftpd_session_s *session, int cmdtype) if (wrbytes != ((ssize_t)buflen)) { + ndbg("Write failed: wrbytes=%d errno=%d\n", wrbytes, errno); (void)ftpd_response(session->cmd.sd, session->txtimeout, g_respfmt1, 550, ' ', "Data send error !"); break; -- cgit v1.2.3