fs/fat: In fs_stat(), when stat'ing the root directory, avoid calculating the address of the root directory entry. The calculation is bogus (but not harmful) because the root directory does not have a directory entry. Noted by Boris Astardzhiev.

This commit is contained in:
Gregory Nutt 2018-05-23 08:14:22 -06:00
parent 618d264e1d
commit b3f20f8c5b

View File

@ -115,7 +115,7 @@ static int fat_stat_common(FAR struct fat_mountpt_s *fs,
static int fat_stat_file(FAR struct fat_mountpt_s *fs,
FAR uint8_t *direntry, FAR struct stat *buf);
static int fat_stat_root(FAR struct fat_mountpt_s *fs,
FAR uint8_t *direntry, FAR struct stat *buf);
FAR struct stat *buf);
static int fat_stat(struct inode *mountpt, const char *relpath,
FAR struct stat *buf);
@ -2807,8 +2807,7 @@ static int fat_stat_file(FAR struct fat_mountpt_s *fs,
*
****************************************************************************/
static int fat_stat_root(FAR struct fat_mountpt_s *fs,
FAR uint8_t *direntry, FAR struct stat *buf)
static int fat_stat_root(FAR struct fat_mountpt_s *fs, FAR struct stat *buf)
{
/* Clear the "struct stat" */
@ -2865,18 +2864,18 @@ static int fat_stat(FAR struct inode *mountpt, FAR const char *relpath,
goto errout_with_semaphore;
}
/* Get a pointer to the directory entry */
direntry = &fs->fs_buffer[dirinfo.fd_seq.ds_offset];
/* Get the FAT attribute and map it so some meaningful mode_t values */
if (dirinfo.fd_root)
{
ret = fat_stat_root(fs, direntry, buf);
ret = fat_stat_root(fs, buf);
}
else
{
/* Get a pointer to the directory entry */
direntry = &fs->fs_buffer[dirinfo.fd_seq.ds_offset];
/* Call fat_stat_file() to create the buf and to save information to
* the stat buffer.
*/