Revised FAT bugfix
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4104 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
90f114ee4f
commit
acf0e4160b
@ -46,13 +46,7 @@
|
|||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
/* Alternate Pin Functions */
|
/* Alternate Pin Functions: */
|
||||||
|
|
||||||
/* Additional effort is required to select specific GPIO options such as frequency,
|
|
||||||
* open-drain/push-pull, and pull-up/down!
|
|
||||||
*/
|
|
||||||
|
|
||||||
#warning "Missing logic"
|
|
||||||
|
|
||||||
/* TIMERS */
|
/* TIMERS */
|
||||||
|
|
||||||
|
@ -62,6 +62,12 @@
|
|||||||
* The driver will then automatically configre PA11 as the CAN1 RX pin.
|
* The driver will then automatically configre PA11 as the CAN1 RX pin.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Additional effort is required to select specific GPIO options such as frequency,
|
||||||
|
* open-drain/push-pull, and pull-up/down!
|
||||||
|
*/
|
||||||
|
|
||||||
|
#warning "Missing logic"
|
||||||
|
|
||||||
/* CAN */
|
/* CAN */
|
||||||
|
|
||||||
#define GPIO_CAN1_RX_1 (GPIO_ALT|GPIO_AF9|GPIO_PORTA|GPIO_PIN11)
|
#define GPIO_CAN1_RX_1 (GPIO_ALT|GPIO_AF9|GPIO_PORTA|GPIO_PIN11)
|
||||||
|
@ -1494,7 +1494,7 @@ static int fat_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check if this is the root directory. If it is the root directory, we
|
/* Check if this is the root directory. If it is the root directory, we
|
||||||
* reset the fd_index to 1, skipping over the initial, unused entry.
|
* reset the fd_index to 0, starting with the initial, entry.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (fs->fs_type != FSTYPE_FAT32 &&
|
if (fs->fs_type != FSTYPE_FAT32 &&
|
||||||
@ -1504,7 +1504,7 @@ static int fat_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir)
|
|||||||
|
|
||||||
dir->u.fat.fd_currcluster = 0;
|
dir->u.fat.fd_currcluster = 0;
|
||||||
dir->u.fat.fd_currsector = fs->fs_rootbase;
|
dir->u.fat.fd_currsector = fs->fs_rootbase;
|
||||||
dir->u.fat.fd_index = 1;
|
dir->u.fat.fd_index = 0;
|
||||||
}
|
}
|
||||||
else if (fs->fs_type == FSTYPE_FAT32 &&
|
else if (fs->fs_type == FSTYPE_FAT32 &&
|
||||||
dir->u.fat.fd_startcluster == fs->fs_rootbase)
|
dir->u.fat.fd_startcluster == fs->fs_rootbase)
|
||||||
@ -1513,7 +1513,7 @@ static int fat_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir)
|
|||||||
|
|
||||||
dir->u.fat.fd_currcluster = dir->u.fat.fd_startcluster;
|
dir->u.fat.fd_currcluster = dir->u.fat.fd_startcluster;
|
||||||
dir->u.fat.fd_currsector = fat_cluster2sector(fs, fs->fs_rootbase);
|
dir->u.fat.fd_currsector = fat_cluster2sector(fs, fs->fs_rootbase);
|
||||||
dir->u.fat.fd_index = 1;
|
dir->u.fat.fd_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is not the root directory. Here the fd_index is set to 2, skipping over
|
/* This is not the root directory. Here the fd_index is set to 2, skipping over
|
||||||
|
@ -144,8 +144,6 @@ static inline int fat_getsfname(uint8_t *direntry, char *buffer,
|
|||||||
static void fat_getlfnchunk(uint8_t *chunk, uint8_t *dest, int nchunk);
|
static void fat_getlfnchunk(uint8_t *chunk, uint8_t *dest, int nchunk);
|
||||||
static inline int fat_getlfname(struct fat_mountpt_s *fs, struct fs_dirent_s *dir);
|
static inline int fat_getlfname(struct fat_mountpt_s *fs, struct fs_dirent_s *dir);
|
||||||
#endif
|
#endif
|
||||||
static int fat_dirverify(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo,
|
|
||||||
uint16_t offset);
|
|
||||||
static int fat_putsfname(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo);
|
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);
|
||||||
@ -794,14 +792,13 @@ static inline int fat_findalias(struct fat_mountpt_s *fs,
|
|||||||
|
|
||||||
memcpy(&tmpinfo, dirinfo, sizeof(struct fat_dirinfo_s));
|
memcpy(&tmpinfo, dirinfo, sizeof(struct fat_dirinfo_s));
|
||||||
|
|
||||||
/* Then re-initialize to the beginning of the current directory, skipping
|
/* Then re-initialize to the beginning of the current directory, starting
|
||||||
* over the first entry (unused in the root directory and '.' entry in other
|
* with the first entry.
|
||||||
* directories).
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
tmpinfo.dir.fd_startcluster = tmpinfo.dir.fd_currcluster;
|
tmpinfo.dir.fd_startcluster = tmpinfo.dir.fd_currcluster;
|
||||||
tmpinfo.dir.fd_currsector = tmpinfo.fd_seq.ds_startsector;
|
tmpinfo.dir.fd_currsector = tmpinfo.fd_seq.ds_startsector;
|
||||||
tmpinfo.dir.fd_index = 1;
|
tmpinfo.dir.fd_index = 0;
|
||||||
|
|
||||||
/* Search for the single short file name directory entry in this directory */
|
/* Search for the single short file name directory entry in this directory */
|
||||||
|
|
||||||
@ -1911,56 +1908,6 @@ static inline int fat_getlfname(struct fat_mountpt_s *fs, struct fs_dirent_s *di
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: fat_dirverify
|
|
||||||
*
|
|
||||||
* Desciption:
|
|
||||||
* Verify that every entry preceding this one is marked with something
|
|
||||||
* other than DIR0_ALLEMPTY. This is necessary only in the root directory
|
|
||||||
* of freshly formatted volumes. In that case, all entries are set to
|
|
||||||
* zero.
|
|
||||||
*
|
|
||||||
* This function also assures that the sector containing the entry is in
|
|
||||||
* the sector cache.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static int fat_dirverify(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo,
|
|
||||||
uint16_t offset)
|
|
||||||
{
|
|
||||||
uint8_t *direntry;
|
|
||||||
uint16_t i;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* Make sure that the sector containing the directory entry is in the sector
|
|
||||||
* cache.
|
|
||||||
*/
|
|
||||||
|
|
||||||
ret = fat_fscacheread(fs, dirinfo->dir.fd_currsector);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check every entry preceding this one */
|
|
||||||
|
|
||||||
for (i = 0; i < offset; i += DIR_SIZE)
|
|
||||||
{
|
|
||||||
/* Is the rest of the directory marked empty? */
|
|
||||||
|
|
||||||
direntry = &fs->fs_buffer[i];
|
|
||||||
if (direntry[DIR_NAME] == DIR0_ALLEMPTY)
|
|
||||||
{
|
|
||||||
/* Then mark the just the entry as empty */
|
|
||||||
|
|
||||||
fs->fs_dirty = true;
|
|
||||||
direntry[DIR_NAME] = DIR0_EMPTY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: fat_putsfname
|
* Name: fat_putsfname
|
||||||
*
|
*
|
||||||
@ -2067,12 +2014,6 @@ static int fat_putlfname(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo
|
|||||||
int namelen;
|
int namelen;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Some special handling in case we are writing the first entry of the
|
|
||||||
* root directory in a freshly formatted volume.
|
|
||||||
*/
|
|
||||||
|
|
||||||
(void)fat_dirverify(fs, dirinfo, dirinfo->fd_seq.ds_lfnoffset);
|
|
||||||
|
|
||||||
/* Get the length of the long file name (size of the fd_lfname array is
|
/* Get the length of the long file name (size of the fd_lfname array is
|
||||||
* LDIR_MAXFNAME+1 we do not have to check the length of the string).
|
* LDIR_MAXFNAME+1 we do not have to check the length of the string).
|
||||||
* NOTE that remainder is conditionally incremented to include the NUL
|
* NOTE that remainder is conditionally incremented to include the NUL
|
||||||
@ -2126,10 +2067,17 @@ static int fat_putlfname(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo
|
|||||||
|
|
||||||
seqno = LDIR0_LAST | nentries;
|
seqno = LDIR0_LAST | nentries;
|
||||||
|
|
||||||
/* Now loop, writing each long file name entry. We know that the sector
|
/* Make sure that the sector containing the "last" long file name entry
|
||||||
* is in the sector cache because fat_dirverify() assures us that that is
|
* is in the sector cache (it probably is not).
|
||||||
* so.
|
*/
|
||||||
*/
|
|
||||||
|
ret = fat_fscacheread(fs, dirinfo->dir.fd_currsector);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now loop, writing each long file name entry */
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@ -2255,12 +2203,6 @@ static int fat_putsfdirentry(struct fat_mountpt_s *fs,
|
|||||||
{
|
{
|
||||||
uint8_t *direntry;
|
uint8_t *direntry;
|
||||||
|
|
||||||
/* Some special handling in case we are writing the first entry of the
|
|
||||||
* root directory in a freshly formatted volume.
|
|
||||||
*/
|
|
||||||
|
|
||||||
(void)fat_dirverify(fs, dirinfo, dirinfo->fd_seq.ds_offset);
|
|
||||||
|
|
||||||
/* Initialize the 32-byte directory entry */
|
/* Initialize the 32-byte directory entry */
|
||||||
|
|
||||||
direntry = &fs->fs_buffer[dirinfo->fd_seq.ds_offset];
|
direntry = &fs->fs_buffer[dirinfo->fd_seq.ds_offset];
|
||||||
@ -2336,11 +2278,11 @@ int fat_finddirentry(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo,
|
|||||||
dirinfo->dir.fd_currsector = cluster;
|
dirinfo->dir.fd_currsector = cluster;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fd_index is the index into the current directory table. It is set to one
|
/* fd_index is the index into the current directory table. It is set to the
|
||||||
* to skip over the first, unused entry in the root directory.
|
* the first, entry in the root directory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
dirinfo->dir.fd_index = 1;
|
dirinfo->dir.fd_index = 0;
|
||||||
|
|
||||||
/* If no path was provided, then the root directory must be exactly what
|
/* If no path was provided, then the root directory must be exactly what
|
||||||
* the caller is looking for.
|
* the caller is looking for.
|
||||||
@ -2489,9 +2431,9 @@ int fat_allocatedirentry(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo
|
|||||||
dirinfo->dir.fd_currsector = fs->fs_rootbase;
|
dirinfo->dir.fd_currsector = fs->fs_rootbase;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skip over the first, unused entry in the root directory. */
|
/* Start at the first entry in the root directory. */
|
||||||
|
|
||||||
dirinfo->dir.fd_index = 1;
|
dirinfo->dir.fd_index = 0;
|
||||||
|
|
||||||
/* Is this a path segment a long or a short file. Was a long file
|
/* Is this a path segment a long or a short file. Was a long file
|
||||||
* name parsed?
|
* name parsed?
|
||||||
|
Loading…
Reference in New Issue
Block a user