More NXFFS bugfixes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3560 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
d33237215d
commit
8a462bbfdc
@ -223,6 +223,7 @@ static inline int nxffs_wrfile(FAR struct nxffs_filedesc_s *file)
|
||||
{
|
||||
size_t offset;
|
||||
int fd;
|
||||
int ret;
|
||||
|
||||
/* Create a random file */
|
||||
|
||||
@ -259,8 +260,21 @@ static inline int nxffs_wrfile(FAR struct nxffs_filedesc_s *file)
|
||||
fprintf(stderr, " File size: %d\n", file->len);
|
||||
fprintf(stderr, " Write offset: %d\n", offset);
|
||||
fprintf(stderr, " Write size: %d\n", nbytestowrite);
|
||||
nxffs_freefile(file);
|
||||
close(fd);
|
||||
|
||||
/* Remove any garbage file that might have been left behind */
|
||||
|
||||
ret = unlink(file->name);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, " Failed to remove corrupted file\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " Successfully removed corrupted file\n");
|
||||
}
|
||||
|
||||
nxffs_freefile(file);
|
||||
return ERROR;
|
||||
}
|
||||
else if (nbyteswritten != nbytestowrite)
|
||||
@ -510,13 +524,8 @@ static int nxffs_delfiles(void)
|
||||
|
||||
/* And delete the next undeleted file after that random index */
|
||||
|
||||
for (j = ndx + 1; j != ndx; j++)
|
||||
for (j = ndx + 1; j != ndx;)
|
||||
{
|
||||
if (j >= CONFIG_EXAMPLES_NXFFS_MAXOPEN)
|
||||
{
|
||||
j = 0;
|
||||
}
|
||||
|
||||
file = &g_files[j];
|
||||
if (file->name && !file->deleted)
|
||||
{
|
||||
@ -535,6 +544,14 @@ static int nxffs_delfiles(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Increment the index and test for wrap-around */
|
||||
|
||||
if (++j >= CONFIG_EXAMPLES_NXFFS_MAXOPEN)
|
||||
{
|
||||
j = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user