summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-03-15 12:22:12 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-03-15 12:22:12 -0600
commit88fb59990a4cf35744eec66840a5894c0c3d2f93 (patch)
tree473895b860bf709b42f2d7b858c0d2a280d2bcb7
parentd8f9c391d0ab40f0d83e5263ea868cbf84a2ed6f (diff)
downloadpx4-nuttx-88fb59990a4cf35744eec66840a5894c0c3d2f93.tar.gz
px4-nuttx-88fb59990a4cf35744eec66840a5894c0c3d2f93.tar.bz2
px4-nuttx-88fb59990a4cf35744eec66840a5894c0c3d2f93.zip
Costmetic changes name while debugging a filename issue
-rw-r--r--apps/nshlib/nsh_fscmds.c7
-rw-r--r--nuttx/TODO31
-rw-r--r--nuttx/fs/fat/fs_fat32.c1
-rw-r--r--nuttx/fs/fat/fs_fat32dirent.c26
4 files changed, 50 insertions, 15 deletions
diff --git a/apps/nshlib/nsh_fscmds.c b/apps/nshlib/nsh_fscmds.c
index afde1e1c1..570ffa776 100644
--- a/apps/nshlib/nsh_fscmds.c
+++ b/apps/nshlib/nsh_fscmds.c
@@ -168,7 +168,8 @@ static char *nsh_getdirpath(const char *path, const char *file)
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
-static int foreach_direntry(FAR struct nsh_vtbl_s *vtbl, const char *cmd, const char *dirpath,
+static int foreach_direntry(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
+ FAR const char *dirpath,
direntry_handler_t handler, void *pvarg)
{
DIR *dirp;
@@ -196,7 +197,7 @@ static int foreach_direntry(FAR struct nsh_vtbl_s *vtbl, const char *cmd, const
for (;;)
{
- struct dirent *entryp = readdir(dirp);
+ FAR struct dirent *entryp = readdir(dirp);
if (!entryp)
{
/* Finished with this directory */
@@ -244,7 +245,7 @@ static int ls_handler(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath,
/* Check if any options will require that we stat the file */
- if ((lsflags & (LSFLAGS_SIZE|LSFLAGS_LONG)) != 0)
+ if ((lsflags & (LSFLAGS_SIZE | LSFLAGS_LONG)) != 0)
{
struct stat buf;
diff --git a/nuttx/TODO b/nuttx/TODO
index 66e1be827..5ec04619a 100644
--- a/nuttx/TODO
+++ b/nuttx/TODO
@@ -17,7 +17,7 @@ nuttx/
(6) Binary loaders (binfmt/)
(12) Network (net/, drivers/net)
(4) USB (drivers/usbdev, drivers/usbhost)
- (11) Libraries (libc/, libm/)
+ (12) Libraries (libc/, libm/)
(11) File system/Generic drivers (fs/, drivers/)
(9) Graphics subystem (graphics/)
(1) Pascal add-on (pcode/)
@@ -1303,6 +1303,35 @@ o File system / Generic drivers (fs/, drivers/)
Status: Open
Priority: Medium
+ Title: MISSING FILES IN NSH 'LS' OF A DIRECTORY
+ Description: I have seen cases where (1) long file names are enabled,
+ but (2) a short file name is created like:
+
+ nsh> echo "This is another thest" >/mnt/sdcard/another.txt
+
+ But then on subsequent 'ls' operations, the file does not appear:
+
+ nsh> ls -l /mnt/sdcard
+
+ I have determined that the problem is because, for some as-
+ of-yet-unkown reason the short file name is treated as a long
+ file name. The name then fails the long filename checksum
+ test and is skipped.
+
+ readdir() (and fat_readdir()) is the logic underlying the
+ failure and the problem appears to be something unique to the
+ fat_readdir() implementation. Why? Because the file is
+ visible when you put the SD card on a PC and because this
+ works fine:
+
+ nsh> ls -l /mnt/sdcard/another.txt
+
+ The failure does not happen on all short file names. I do
+ not understand the pattern. But I have not had the opportunity
+ to dig into this deeply.
+ Status: Open
+ Priority: Medium-High
+
o Graphics subsystem (graphics/)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/nuttx/fs/fat/fs_fat32.c b/nuttx/fs/fat/fs_fat32.c
index 305cb0aa4..fafa2b59d 100644
--- a/nuttx/fs/fat/fs_fat32.c
+++ b/nuttx/fs/fat/fs_fat32.c
@@ -1694,7 +1694,6 @@ static int fat_readdir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir)
*/
#ifdef CONFIG_FAT_LFN
-
/* Get a reference to the current, short file name directory
* entry.
*/
diff --git a/nuttx/fs/fat/fs_fat32dirent.c b/nuttx/fs/fat/fs_fat32dirent.c
index b79c5110f..cfe0bd0f2 100644
--- a/nuttx/fs/fat/fs_fat32dirent.c
+++ b/nuttx/fs/fat/fs_fat32dirent.c
@@ -148,7 +148,8 @@ static int fat_putsfname(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo
#ifdef CONFIG_FAT_LFN
static void fat_initlfname(uint8_t *chunk, int nchunk);
static void fat_putlfnchunk(uint8_t *chunk, const uint8_t *src, int nchunk);
-static int fat_putlfname(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo);
+static int fat_putlfname(struct fat_mountpt_s *fs,
+ struct fat_dirinfo_s *dirinfo);
#endif
static int fat_putsfdirentry(struct fat_mountpt_s *fs,
struct fat_dirinfo_s *dirinfo,
@@ -169,7 +170,9 @@ static int fat_putsfdirentry(struct fat_mountpt_s *fs,
/****************************************************************************
* Name: fat_lfnchecksum
*
- * Desciption: Caculate the checksum of .
+ * Description:
+ * Verify that the checksum of the short file name matches the checksum
+ * that we found in the long file name entries.
*
****************************************************************************/
@@ -182,7 +185,7 @@ static uint8_t fat_lfnchecksum(const uint8_t *sfname)
for (i = DIR_MAXFNAME; i; i--)
{
sum = ((sum & 1) << 7) + (sum >> 1) + *sfname++;
- }
+ }
return sum;
}
@@ -604,7 +607,7 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo)
tmp = ext - (char*)dirinfo->fd_lfname;
namechars = tmp;
- /* And the rest, exluding the '.' is the extension. */
+ /* And the rest, excluding the '.' is the extension. */
extchars = len - namechars - 1;
ext++;
@@ -617,9 +620,9 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo)
extchars = 0;
}
+#ifdef CONFIG_FAT_LCNAMES
/* Alias are always all upper case */
-#ifdef CONFIG_FAT_LCNAMES
dirinfo->fd_ntflags = 0;
#endif
@@ -628,7 +631,7 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo)
memset(dirinfo->fd_name, ' ', DIR_MAXFNAME);
/* Handle a special case where there is no name. Windows seems to use
- * the extension plus random stuff then ~1 to pat to 8 bytes. Some
+ * the extension plus random stuff then ~1 to pad to 8 bytes. Some
* examples:
*
* a.b -> a.b No long name
@@ -673,7 +676,7 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo)
if (ch == '\0')
{
/* This is the end of the source string. Do we need to add ~1. We
- * will do that if we were parsing the name part when the endo of
+ * will do that if we were parsing the name part when the end of
* string was encountered.
*/
@@ -2001,7 +2004,8 @@ static void fat_putlfnchunk(uint8_t *chunk, const uint8_t *src, int nchunk)
****************************************************************************/
#ifdef CONFIG_FAT_LFN
-static int fat_putlfname(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo)
+static int fat_putlfname(struct fat_mountpt_s *fs,
+ struct fat_dirinfo_s *dirinfo)
{
uint16_t diroffset;
uint8_t *direntry;
@@ -2036,6 +2040,7 @@ static int fat_putlfname(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo
nentries++;
remainder++;
}
+
DEBUGASSERT(nentries > 0 && nentries <= LDIR_MAXLFNS);
/* Create the short file name alias */
@@ -2059,7 +2064,7 @@ static int fat_putlfname(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo
startsector = fat_cluster2sector(fs, dirinfo->dir.fd_currcluster);
dirinfo->dir.fd_index += (dirinfo->dir.fd_currsector - startsector) * DIRSEC_NDIRS(fs);
- /* Make sure that the alias is unique in this directory*/
+ /* Make sure that the alias is unique in this directory */
ret = fat_uniquealias(fs, dirinfo);
if (ret < 0)
@@ -2418,7 +2423,8 @@ int fat_finddirentry(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo,
*
****************************************************************************/
-int fat_allocatedirentry(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo)
+int fat_allocatedirentry(struct fat_mountpt_s *fs,
+ struct fat_dirinfo_s *dirinfo)
{
int32_t cluster;
int32_t prevcluster;