9
0
Fork 0

More FAT long file name logic

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@3782 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2011-07-13 21:53:06 +00:00
parent 99c81ca8bb
commit 7da2d52f9b
4 changed files with 801 additions and 181 deletions

View File

@ -217,7 +217,7 @@
# define LDIR_MAXLFNCHARS 13 /* Max unicode characters in one LFN entry */ # define LDIR_MAXLFNCHARS 13 /* Max unicode characters in one LFN entry */
# define LDIR_MAXLFNS 20 /* Max number of LFN entries */ # define LDIR_MAXLFNS 20 /* Max number of LFN entries */
/* LFN directory enty offsets */ /* LFN directory entry offsets */
# define LDIR_SEQ 0 /* 1@ 0: Sequence number */ # define LDIR_SEQ 0 /* 1@ 0: Sequence number */
# define LDIR_WCHAR1_5 1 /* 10@ 1: File name characters 1-5 (5 Unicode characters) */ # define LDIR_WCHAR1_5 1 /* 10@ 1: File name characters 1-5 (5 Unicode characters) */
@ -235,6 +235,10 @@
# define LDIR0_E5 DIR0_E5 /* The actual value is 0xe5 */ # define LDIR0_E5 DIR0_E5 /* The actual value is 0xe5 */
# define LDIR0_LAST 0x40 /* Last LFN in file name (appears first) */ # define LDIR0_LAST 0x40 /* Last LFN in file name (appears first) */
# define LDIR0_SEQ_MASK 0x1f /* Mask for sequence number (1-20) */ # define LDIR0_SEQ_MASK 0x1f /* Mask for sequence number (1-20) */
/* The LFN entry attribute */
# define LDDIR_LFNATTR 0x0f
#endif #endif
/**************************************************************************** /****************************************************************************
@ -333,10 +337,10 @@
#define DIR_GETCRTTIMETENTH(p) UBYTE_VAL(p,DIR_CRTTIMETENTH) #define DIR_GETCRTTIMETENTH(p) UBYTE_VAL(p,DIR_CRTTIMETENTH)
#ifdef CONFIG_FAT_LFN #ifdef CONFIG_FAT_LFN
# define LDIR_GETSEQ(p) UBYTE_VAL(*p, LDIR_SEQ); # define LDIR_GETSEQ(p) UBYTE_VAL(*p,LDIR_SEQ);
# define LDIR_GETATTRIBUTES(p) UBYTE_VAL(*p, LDIR_ATTRIBUTES); # define LDIR_GETATTRIBUTES(p) UBYTE_VAL(*p,LDIR_ATTRIBUTES);
# define LDIR_GETNTRES(p) UBYTE_VAL(*p, LDIR_NTRES); # define LDIR_GETNTRES(p) UBYTE_VAL(*p,LDIR_NTRES);
# define LDIR_GETCHECKSUM(p) UBYTE_VAL(*p, LDIR_CHECKSUM); # define LDIR_GETCHECKSUM(p) UBYTE_VAL(*p,LDIR_CHECKSUM);
#endif #endif
#define MBR_PUTSECPERCLUS(p,v) UBYTE_PUT(p,BS_SECPERCLUS,v) #define MBR_PUTSECPERCLUS(p,v) UBYTE_PUT(p,BS_SECPERCLUS,v)
@ -717,11 +721,13 @@ struct fat_dirseq_s
uint16_t ds_lfnoffset; /* Sector offset to last long file name entry */ uint16_t ds_lfnoffset; /* Sector offset to last long file name entry */
#endif #endif
/* Sector numbers */ /* Sector and cluster numbers */
off_t ds_sector; /* Sector of the short file name entry */ off_t ds_sector; /* Sector of the short file name entry */
#ifdef CONFIG_FAT_LFN #ifdef CONFIG_FAT_LFN
off_t ds_cluster; /* Cluster containing the short file name entry */
off_t ds_lfnsector; /* Sector of the last long name entry */ off_t ds_lfnsector; /* Sector of the last long name entry */
off_t ds_lfncluster; /* Cluster containing the long file name entry */
#endif #endif
}; };

File diff suppressed because it is too large Load Diff

View File

@ -1181,7 +1181,9 @@ int32_t fat_extendchain(struct fat_mountpt_s *fs, uint32_t cluster)
* Name: fat_nextdirentry * Name: fat_nextdirentry
* *
* Desciption: Read the next directory entry from the sector in cache, * Desciption: Read the next directory entry from the sector in cache,
* reading the next sector(s) in the cluster as necessary. * reading the next sector(s) in the cluster as necessary. This function
* must return -ENOSPC if if fails because there are no further entries
* available in the directory.
* *
****************************************************************************/ ****************************************************************************/
@ -1221,7 +1223,7 @@ int fat_nextdirentry(struct fat_mountpt_s *fs, struct fs_fatdir_s *dir)
* the root directory. * the root directory.
*/ */
return ERROR; return -ENOSPC;
} }
} }
else else
@ -1250,7 +1252,8 @@ int fat_nextdirentry(struct fat_mountpt_s *fs, struct fs_fatdir_s *dir)
if (cluster < 2 || cluster >= fs->fs_nclusters) if (cluster < 2 || cluster >= fs->fs_nclusters)
{ {
/* No, we have probably reached the end of the cluster list */ /* No, we have probably reached the end of the cluster list */
return ERROR;
return -ENOSPC;
} }
/* Initialize for new cluster */ /* Initialize for new cluster */

View File

@ -78,9 +78,9 @@ struct fs_psuedodir_s
struct fs_fatdir_s struct fs_fatdir_s
{ {
uint32_t fd_startcluster; /* Start cluster number of the directory */ off_t fd_startcluster; /* Start cluster number of the directory */
uint32_t fd_currcluster; /* Current cluster number being read */ off_t fd_currcluster; /* Current cluster number being read */
size_t fd_currsector; /* Current sector being read */ off_t fd_currsector; /* Current sector being read */
unsigned int fd_index; /* Current index of the directory entry to read */ unsigned int fd_index; /* Current index of the directory entry to read */
}; };
#endif /* CONFIG_FS_FAT */ #endif /* CONFIG_FS_FAT */
@ -92,8 +92,8 @@ struct fs_fatdir_s
struct fs_romfsdir_s struct fs_romfsdir_s
{ {
uint32_t fr_firstoffset; /* Offset to the first entry in the directory */ off_t fr_firstoffset; /* Offset to the first entry in the directory */
uint32_t fr_curroffset; /* Current offset into the directory contents */ off_t fr_curroffset; /* Current offset into the directory contents */
}; };
#endif /* CONFIG_FS_ROMFS */ #endif /* CONFIG_FS_ROMFS */