FAT long file names are basically functional
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3790 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
42249bbbb2
commit
7a7446a401
@ -1385,7 +1385,31 @@ static int fat_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
|
||||
ret = fat_dirname2path(fs, dir);
|
||||
if (ret == OK)
|
||||
{
|
||||
/* The name was successfully extracted. Now save the file type */
|
||||
/* The name was successfully extracted. Re-read the
|
||||
* attributes: If this is long directory entry, then the
|
||||
* attributes that we need will be the the final, short file
|
||||
* name entry and not in the directory entry where we started
|
||||
* looking for the file name. We can be assured that, on
|
||||
* success, fat_dirname2path() will leave the short file name
|
||||
* entry in the cache regardless of the kind of directory
|
||||
* entry. We simply have to re-read it to cover the the long
|
||||
* file name case.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_FAT_LFN
|
||||
|
||||
/* Get a reference to the current, short file name directory
|
||||
* entry.
|
||||
*/
|
||||
|
||||
dirindex = (dir->u.fat.fd_index & DIRSEC_NDXMASK(fs)) * DIR_SIZE;
|
||||
direntry = &fs->fs_buffer[dirindex];
|
||||
|
||||
/* Then re-read the attributes from the short file name entry */
|
||||
|
||||
attribute = DIR_GETATTRIBUTES(direntry);
|
||||
#endif
|
||||
/* Now get the file type from the directory attributes. */
|
||||
|
||||
if ((attribute & FATATTR_DIRECTORY) == 0)
|
||||
{
|
||||
|
@ -926,7 +926,7 @@ static bool fat_cmplfname(const uint8_t *direntry, const uint8_t *substr)
|
||||
|
||||
/* How much of string do we have to compare? */
|
||||
|
||||
len = strlen(substr);
|
||||
len = strlen((char*)substr);
|
||||
|
||||
/* Check bytes 1-5 */
|
||||
|
||||
@ -1540,9 +1540,9 @@ static inline int fat_getlfname(struct fat_mountpt_s *fs, struct fs_dirent_s *di
|
||||
uint16_t diroffset;
|
||||
uint8_t *direntry;
|
||||
uint8_t seqno;
|
||||
uint8_t rawseq;
|
||||
uint8_t offset;
|
||||
uint8_t checksum;
|
||||
int tmp;
|
||||
int nsrc;
|
||||
int ret;
|
||||
int i;
|
||||
@ -1559,16 +1559,12 @@ static inline int fat_getlfname(struct fat_mountpt_s *fs, struct fs_dirent_s *di
|
||||
|
||||
/* Sanity check */
|
||||
|
||||
tmp = (seqno & LDIR0_SEQ_MASK);
|
||||
if (tmp < 1 || tmp > LDIR_MAXLFNS)
|
||||
rawseq = (seqno & LDIR0_SEQ_MASK);
|
||||
if (rawseq < 1 || rawseq > LDIR_MAXLFNS)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Get the string offset associated with the "last" entry. */
|
||||
|
||||
offset = (tmp - 1) * LDIR_MAXLFNCHARS;
|
||||
|
||||
/* Save the checksum value */
|
||||
|
||||
checksum = LDIR_GETCHECKSUM(direntry);
|
||||
@ -1577,6 +1573,10 @@ static inline int fat_getlfname(struct fat_mountpt_s *fs, struct fs_dirent_s *di
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* Get the string offset associated with the "last" entry. */
|
||||
|
||||
offset = (rawseq - 1) * LDIR_MAXLFNCHARS;
|
||||
|
||||
/* Will any of this file name fit into the destination buffer? */
|
||||
|
||||
if (offset < NAME_MAX)
|
||||
@ -1649,7 +1649,7 @@ static inline int fat_getlfname(struct fat_mountpt_s *fs, struct fs_dirent_s *di
|
||||
|
||||
/* Get the next expected sequence number. */
|
||||
|
||||
seqno = (seqno & LDIR0_SEQ_MASK) - 1;
|
||||
seqno = --rawseq;
|
||||
if (seqno < 1)
|
||||
{
|
||||
/* We just completed processing the "first" long file name entry
|
||||
@ -2293,9 +2293,9 @@ int fat_freedirentry(struct fat_mountpt_s *fs, struct fat_dirseq_s *seq)
|
||||
* first on the media).
|
||||
*/
|
||||
|
||||
dir.fd_startcluster = seq->ds_lfncluster;
|
||||
dir.fd_currcluster = seq->ds_lfnsector;
|
||||
dir.fd_index = seq->ds_lfnoffset / DIR_SIZE;
|
||||
dir.fd_currcluster = seq->ds_lfncluster;
|
||||
dir.fd_currsector = seq->ds_lfnsector;
|
||||
dir.fd_index = seq->ds_lfnoffset / DIR_SIZE;
|
||||
|
||||
/* Free all of the directory entries used for the sequence of long file name
|
||||
* and for the single short file name entry.
|
||||
@ -2333,7 +2333,7 @@ int fat_freedirentry(struct fat_mountpt_s *fs, struct fat_dirseq_s *seq)
|
||||
return fat_fscacheflush(fs);
|
||||
}
|
||||
|
||||
/* There are moe entries to go.. Try the next directory entry */
|
||||
/* There are more entries to go.. Try the next directory entry */
|
||||
|
||||
ret = fat_nextdirentry(fs, &dir);
|
||||
if (ret < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user