Fix some lseek to zero problems
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1251 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
f2b7c5e6b4
commit
3a02c111ca
@ -304,7 +304,6 @@ static int fat_open(FAR struct file *filep, const char *relpath,
|
||||
|
||||
ff->ff_open = TRUE;
|
||||
ff->ff_oflags = oflags;
|
||||
ff->ff_sectorsincluster = 1;
|
||||
|
||||
/* Save information that can be used later to recover the directory entry */
|
||||
|
||||
@ -925,22 +924,23 @@ static off_t fat_seek(FAR struct file *filep, off_t offset, int whence)
|
||||
position = ff->ff_size;
|
||||
}
|
||||
|
||||
/* Set file position to the beginning of the file */
|
||||
/* Set file position to the beginning of the file (first cluster,
|
||||
* first sector in cluster)
|
||||
*/
|
||||
|
||||
filep->f_pos = 0;
|
||||
ff->ff_sectorsincluster = 1;
|
||||
ff->ff_sectorsincluster = fs->fs_fatsecperclus;
|
||||
|
||||
/* Move file position if necessary */
|
||||
|
||||
if (position)
|
||||
{
|
||||
/* Get the start cluster of the file */
|
||||
|
||||
cluster = ff->ff_startcluster;
|
||||
if (!cluster)
|
||||
{
|
||||
/* Create a new cluster chain if the file does not have one */
|
||||
|
||||
/* Create a new cluster chain if the file does not have one (and
|
||||
* if we are seeking beyond zero
|
||||
*/
|
||||
|
||||
if (!cluster && position > 0)
|
||||
{
|
||||
cluster = fat_createchain(fs);
|
||||
if (cluster < 0)
|
||||
{
|
||||
@ -950,6 +950,8 @@ static off_t fat_seek(FAR struct file *filep, off_t offset, int whence)
|
||||
ff->ff_startcluster = cluster;
|
||||
}
|
||||
|
||||
/* Move file position if necessary */
|
||||
|
||||
if (cluster)
|
||||
{
|
||||
/* If the file has a cluster chain, follow it to the
|
||||
@ -1054,7 +1056,6 @@ static off_t fat_seek(FAR struct file *filep, off_t offset, int whence)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If we extended the size of the file, then mark the file as modified. */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user