|
@ -2016,23 +2016,25 @@ Finish: |
|
|
return r; |
|
|
return r; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int ext4_fseek(ext4_file *file, uint64_t offset, uint32_t origin) |
|
|
int ext4_fseek(ext4_file *file, int64_t offset, uint32_t origin) |
|
|
{ |
|
|
{ |
|
|
switch (origin) { |
|
|
switch (origin) { |
|
|
case SEEK_SET: |
|
|
case SEEK_SET: |
|
|
if (offset > file->fsize) |
|
|
if (offset < 0 || (uint64_t)offset > file->fsize) |
|
|
return EINVAL; |
|
|
return EINVAL; |
|
|
|
|
|
|
|
|
file->fpos = offset; |
|
|
file->fpos = offset; |
|
|
return EOK; |
|
|
return EOK; |
|
|
case SEEK_CUR: |
|
|
case SEEK_CUR: |
|
|
if ((offset + file->fpos) > file->fsize) |
|
|
if ((offset < 0 && (uint64_t)(-offset) > file->fpos) || |
|
|
|
|
|
(offset > 0 && |
|
|
|
|
|
(uint64_t)offset > (file->fsize - file->fpos))) |
|
|
return EINVAL; |
|
|
return EINVAL; |
|
|
|
|
|
|
|
|
file->fpos += offset; |
|
|
file->fpos += offset; |
|
|
return EOK; |
|
|
return EOK; |
|
|
case SEEK_END: |
|
|
case SEEK_END: |
|
|
if (offset > file->fsize) |
|
|
if (offset < 0 || (uint64_t)offset > file->fsize) |
|
|
return EINVAL; |
|
|
return EINVAL; |
|
|
|
|
|
|
|
|
file->fpos = file->fsize - offset; |
|
|
file->fpos = file->fsize - offset; |
|
|