Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs_fat32.c fat_seek maybe return a error that shoud ok #29

Open
elmagnificogi opened this issue Aug 18, 2018 · 3 comments
Open

fs_fat32.c fat_seek maybe return a error that shoud ok #29

elmagnificogi opened this issue Aug 18, 2018 · 3 comments
Assignees
Labels

Comments

@elmagnificogi
Copy link

elmagnificogi commented Aug 18, 2018

Use case:
open a file with readonly,then lseek to the end with offset 0
there will return a error( ENOSPC 28 "No space left on device")
so i can't get the file size with this.

TestFile:13,107,200 Byte

Code:

static off_t fat_seek(FAR struct file filep, off_t offset, int whence)
---------1164
if ((ff->ff_oflags & O_WROK) != 0)
{
/ Extend the cluster chain (fat_extendchain
* will follow the existing chain or add new
* clusters as needed.
*/

cluster = fat_extendchain(fs, cluster);
}
else
{
/* Otherwise we can only follow the existing chain */

cluster = fat_getcluster(fs, cluster);
}

---------1178

when i debug i found that fat_getcluster(fs, cluster) will retrun the "0x0fffffff" that means FAT cluster end.
but in fat_seek ,there is no end deal,so there will be a error.

The break way is less than clustersize,in the loop, position Just coincidentally equal to clustersize,so it continue find next cluster chan.

---------1142

if (position < clustersize)
{
break;
}

---------1145

Solution:

add FAT end deal or make break condition wiht "position <= clustersize"

@bkueng
Copy link
Member

bkueng commented Aug 20, 2018

@davids5 can you take a look?

@davids5 davids5 self-assigned this Aug 20, 2018
@dagar dagar added the bug label Jan 2, 2019
@dagar
Copy link
Member

dagar commented Jan 2, 2019

Is this still an issue?

@elmagnificogi
Copy link
Author

Is this still an issue?

no one reply,i have no idea

PX4BuildBot pushed a commit that referenced this issue Jan 5, 2020
    Run all .c and .h files in last PR through tools/nxstyle and fix all complaints.

Author: macman88 <jjlange91@gmail.com>

    LPC17xx serial updates (#29)

    * Save CONFIG_ARCH_BOARD_CUSTOM when running 'make savedefconfig'
    * Don't compile up_earlyserialinit if USE_EARLYSERIALINIT is not defined
    * Added support for RS485 direction control on LPC17xx UART1
    * First pass at fractional baud rate divider on LPC17xx/40xx
    * Added support for fractional divider to console UART
PX4BuildBot pushed a commit that referenced this issue Jan 5, 2020
    Run all .c and .h files in last PR through tools/nxstyle and fix all complaints.

Author: macman88 <jjlange91@gmail.com>

    LPC17xx serial updates (#29)

    * Save CONFIG_ARCH_BOARD_CUSTOM when running 'make savedefconfig'
    * Don't compile up_earlyserialinit if USE_EARLYSERIALINIT is not defined
    * Added support for RS485 direction control on LPC17xx UART1
    * First pass at fractional baud rate divider on LPC17xx/40xx
    * Added support for fractional divider to console UART
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants