From befef8fd6f4355da5d448378294a3a8014837a41 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 7 Feb 2012 00:29:06 +0000 Subject: [PATCH] Fix a bug in the FAT statfs() implementation git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4375 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- apps/netutils/ftpd/ftpd.c | 2 +- apps/netutils/ftpd/ftpd.h | 22 +++++++++------------- nuttx/ChangeLog | 3 +++ nuttx/fs/fat/fs_fat32.c | 18 +++++++++--------- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/apps/netutils/ftpd/ftpd.c b/apps/netutils/ftpd/ftpd.c index 36d385e03..af11b3960 100755 --- a/apps/netutils/ftpd/ftpd.c +++ b/apps/netutils/ftpd/ftpd.c @@ -2356,7 +2356,7 @@ static int ftpd_command_user(FAR struct ftpd_session_s *session) { int ret; - /* Clear session status (USER, REST, RNFR) */ + /* Clear session status */ session->flags = 0; session->restartpos = 0; diff --git a/apps/netutils/ftpd/ftpd.h b/apps/netutils/ftpd/ftpd.h index 4397e96e3..6c10d35ad 100755 --- a/apps/netutils/ftpd/ftpd.h +++ b/apps/netutils/ftpd/ftpd.h @@ -50,23 +50,19 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -/* Networking definitions ***************************************************/ - -#define FTPD_PROTOCOL_TCP (6) /* TCP protocol number */ - /* FPTD Definitions *********************************************************/ -#define FTPD_SESSIONFLAG_USER (1 << 0) -#define FTPD_SESSIONFLAG_RESTARTPOS (1 << 1) -#define FTPD_SESSIONFLAG_RENAMEFROM (1 << 2) +#define FTPD_SESSIONFLAG_USER (1 << 0) /* Session has a user */ +#define FTPD_SESSIONFLAG_RESTARTPOS (1 << 1) /* Session has a restart position */ +#define FTPD_SESSIONFLAG_RENAMEFROM (1 << 2) /* Session has a rename from string */ -#define FTPD_LISTOPTION_A (1 << 0) -#define FTPD_LISTOPTION_L (1 << 1) -#define FTPD_LISTOPTION_F (1 << 2) -#define FTPD_LISTOPTION_R (1 << 3) -#define FTPD_LISTOPTION_UNKNOWN (1 << 7) +#define FTPD_LISTOPTION_A (1 << 0) /* List option 'A' */ +#define FTPD_LISTOPTION_L (1 << 1) /* List option 'L' */ +#define FTPD_LISTOPTION_F (1 << 2) /* List option 'F' */ +#define FTPD_LISTOPTION_R (1 << 3) /* List option 'R' */ +#define FTPD_LISTOPTION_UNKNOWN (1 << 7) /* Unknown list option */ -#define FTPD_CMDFLAG_LOGIN (1 << 0) +#define FTPD_CMDFLAG_LOGIN (1 << 0) /* Command requires login */ /**************************************************************************** * Public Types diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index f60b7b9b6..444119973 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -2447,3 +2447,6 @@ * lib/net/lib_inetntop.c: Add inet_ntop(). * lib/net/lib_inetpton.c: Add inet_pton(). * include/pthread.h: Correct PTHREAD_MUTEX_INITIALIZER. + * fs/fat/fs_fatfs.c: Fix and error in the FAT statfs() implementation that + was causing some block counts to be reported incorrectly (reported by + david_s5y). \ No newline at end of file diff --git a/nuttx/fs/fat/fs_fat32.c b/nuttx/fs/fat/fs_fat32.c index 0ec1d78cf..909d5a2dc 100644 --- a/nuttx/fs/fat/fs_fat32.c +++ b/nuttx/fs/fat/fs_fat32.c @@ -1,8 +1,8 @@ /**************************************************************************** * fs/fat/fs_fat32.c * - * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * References: * Microsoft FAT documentation @@ -1706,13 +1706,13 @@ static int fat_statfs(struct inode *mountpt, struct statfs *buf) /* Everything else follows in units of clusters */ - buf->f_blocks = fs->fs_nclusters; /* Total data blocks in the file system */ - buf->f_bfree = fat_nfreeclusters(fs, &buf->f_bfree); /* Free blocks in the file system */ - buf->f_bavail = buf->f_bfree; /* Free blocks avail to non-superuser */ - buf->f_namelen = (8+1+3); /* Maximum length of filenames */ - - fat_semgive(fs); - return OK; + ret = fat_nfreeclusters(fs, &buf->f_bfree); /* Free blocks in the file system */ + if (ret >= 0) + { + buf->f_blocks = fs->fs_nclusters; /* Total data blocks in the file system */ + buf->f_bavail = buf->f_bfree; /* Free blocks avail to non-superuser */ + buf->f_namelen = (8+1+3); /* Maximum length of filenames */ + } errout_with_semaphore: fat_semgive(fs);