Costmetic changes name while debugging a filename issue
This commit is contained in:
parent
28ead380ea
commit
b637a0cc3e
3 changed files with 46 additions and 12 deletions
31
TODO
31
TODO
|
@ -17,7 +17,7 @@ nuttx/
|
||||||
(6) Binary loaders (binfmt/)
|
(6) Binary loaders (binfmt/)
|
||||||
(12) Network (net/, drivers/net)
|
(12) Network (net/, drivers/net)
|
||||||
(4) USB (drivers/usbdev, drivers/usbhost)
|
(4) USB (drivers/usbdev, drivers/usbhost)
|
||||||
(11) Libraries (libc/, libm/)
|
(12) Libraries (libc/, libm/)
|
||||||
(11) File system/Generic drivers (fs/, drivers/)
|
(11) File system/Generic drivers (fs/, drivers/)
|
||||||
(9) Graphics subystem (graphics/)
|
(9) Graphics subystem (graphics/)
|
||||||
(1) Pascal add-on (pcode/)
|
(1) Pascal add-on (pcode/)
|
||||||
|
@ -1303,6 +1303,35 @@ o File system / Generic drivers (fs/, drivers/)
|
||||||
Status: Open
|
Status: Open
|
||||||
Priority: Medium
|
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/)
|
o Graphics subsystem (graphics/)
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
|
|
@ -1694,7 +1694,6 @@ static int fat_readdir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_FAT_LFN
|
#ifdef CONFIG_FAT_LFN
|
||||||
|
|
||||||
/* Get a reference to the current, short file name directory
|
/* Get a reference to the current, short file name directory
|
||||||
* entry.
|
* entry.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -148,7 +148,8 @@ static int fat_putsfname(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo
|
||||||
#ifdef CONFIG_FAT_LFN
|
#ifdef CONFIG_FAT_LFN
|
||||||
static void fat_initlfname(uint8_t *chunk, int nchunk);
|
static void fat_initlfname(uint8_t *chunk, int nchunk);
|
||||||
static void fat_putlfnchunk(uint8_t *chunk, const uint8_t *src, 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
|
#endif
|
||||||
static int fat_putsfdirentry(struct fat_mountpt_s *fs,
|
static int fat_putsfdirentry(struct fat_mountpt_s *fs,
|
||||||
struct fat_dirinfo_s *dirinfo,
|
struct fat_dirinfo_s *dirinfo,
|
||||||
|
@ -169,7 +170,9 @@ static int fat_putsfdirentry(struct fat_mountpt_s *fs,
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: fat_lfnchecksum
|
* 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--)
|
for (i = DIR_MAXFNAME; i; i--)
|
||||||
{
|
{
|
||||||
sum = ((sum & 1) << 7) + (sum >> 1) + *sfname++;
|
sum = ((sum & 1) << 7) + (sum >> 1) + *sfname++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
@ -604,7 +607,7 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo)
|
||||||
tmp = ext - (char*)dirinfo->fd_lfname;
|
tmp = ext - (char*)dirinfo->fd_lfname;
|
||||||
namechars = tmp;
|
namechars = tmp;
|
||||||
|
|
||||||
/* And the rest, exluding the '.' is the extension. */
|
/* And the rest, excluding the '.' is the extension. */
|
||||||
|
|
||||||
extchars = len - namechars - 1;
|
extchars = len - namechars - 1;
|
||||||
ext++;
|
ext++;
|
||||||
|
@ -617,9 +620,9 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo)
|
||||||
extchars = 0;
|
extchars = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_FAT_LCNAMES
|
||||||
/* Alias are always all upper case */
|
/* Alias are always all upper case */
|
||||||
|
|
||||||
#ifdef CONFIG_FAT_LCNAMES
|
|
||||||
dirinfo->fd_ntflags = 0;
|
dirinfo->fd_ntflags = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -628,7 +631,7 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo)
|
||||||
memset(dirinfo->fd_name, ' ', DIR_MAXFNAME);
|
memset(dirinfo->fd_name, ' ', DIR_MAXFNAME);
|
||||||
|
|
||||||
/* Handle a special case where there is no name. Windows seems to use
|
/* 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:
|
* examples:
|
||||||
*
|
*
|
||||||
* a.b -> a.b No long name
|
* a.b -> a.b No long name
|
||||||
|
@ -673,7 +676,7 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo)
|
||||||
if (ch == '\0')
|
if (ch == '\0')
|
||||||
{
|
{
|
||||||
/* This is the end of the source string. Do we need to add ~1. We
|
/* 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.
|
* string was encountered.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -2001,7 +2004,8 @@ static void fat_putlfnchunk(uint8_t *chunk, const uint8_t *src, int nchunk)
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_FAT_LFN
|
#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;
|
uint16_t diroffset;
|
||||||
uint8_t *direntry;
|
uint8_t *direntry;
|
||||||
|
@ -2036,6 +2040,7 @@ static int fat_putlfname(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo
|
||||||
nentries++;
|
nentries++;
|
||||||
remainder++;
|
remainder++;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGASSERT(nentries > 0 && nentries <= LDIR_MAXLFNS);
|
DEBUGASSERT(nentries > 0 && nentries <= LDIR_MAXLFNS);
|
||||||
|
|
||||||
/* Create the short file name alias */
|
/* 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);
|
startsector = fat_cluster2sector(fs, dirinfo->dir.fd_currcluster);
|
||||||
dirinfo->dir.fd_index += (dirinfo->dir.fd_currsector - startsector) * DIRSEC_NDIRS(fs);
|
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);
|
ret = fat_uniquealias(fs, dirinfo);
|
||||||
if (ret < 0)
|
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 cluster;
|
||||||
int32_t prevcluster;
|
int32_t prevcluster;
|
||||||
|
|
Loading…
Reference in a new issue