Skip to content

Commit

Permalink
Merge branch 'bf_lfs_file_seek_readonly' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
geky committed Mar 21, 2022
2 parents 99f5813 + 03f088b commit c676bce
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2742,7 +2742,6 @@ static int lfs_file_outline(lfs_t *lfs, lfs_file_t *file) {
}
#endif

#ifndef LFS_READONLY
static int lfs_file_flush(lfs_t *lfs, lfs_file_t *file) {
if (file->flags & LFS_F_READING) {
if (!(file->flags & LFS_F_INLINE)) {
Expand All @@ -2751,6 +2750,7 @@ static int lfs_file_flush(lfs_t *lfs, lfs_file_t *file) {
file->flags &= ~LFS_F_READING;
}

#ifndef LFS_READONLY
if (file->flags & LFS_F_WRITING) {
lfs_off_t pos = file->pos;

Expand Down Expand Up @@ -2817,10 +2817,10 @@ static int lfs_file_flush(lfs_t *lfs, lfs_file_t *file) {

file->pos = pos;
}
#endif

return 0;
}
#endif

#ifndef LFS_READONLY
static int lfs_file_rawsync(lfs_t *lfs, lfs_file_t *file) {
Expand Down Expand Up @@ -3093,13 +3093,11 @@ static lfs_soff_t lfs_file_rawseek(lfs_t *lfs, lfs_file_t *file,
return npos;
}

#ifndef LFS_READONLY
// write out everything beforehand, may be noop if rdonly
int err = lfs_file_flush(lfs, file);
if (err) {
return err;
}
#endif

// update pos
file->pos = npos;
Expand Down

0 comments on commit c676bce

Please sign in to comment.