MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / dfs_file_lseek

Function dfs_file_lseek

components/dfs/dfs_v2/src/dfs_file.c:1214–1235  ·  view source on GitHub ↗

* @brief Change the file position indicator * * This function sets the file position indicator for the file referenced by the file descriptor * based on the offset and whence parameters. * * @param[in,out] file Pointer to the file structure (position will be modified) * @param[in] offset Number of bytes to offset from position * @param[in] whence Reference position (SEEK_SET/SEEK_CUR/SEEK_E

Source from the content-addressed store, hash-verified

1212 * -EINVAL if invalid parameters or not mounted
1213 */
1214off_t dfs_file_lseek(struct dfs_file *file, off_t offset, int wherece)
1215{
1216 off_t retval = -EINVAL;
1217
1218 if (file && file->fops->lseek)
1219 {
1220 if (dfs_is_mounted(file->vnode->mnt) == 0)
1221 {
1222 /* fpos lock */
1223 off_t pos = dfs_file_get_fpos(file);
1224 retval = file->fops->lseek(file, offset, wherece);
1225 if (retval >= 0)
1226 {
1227 pos = retval;
1228 }
1229 /* fpos unlock */
1230 dfs_file_set_fpos(file, pos);
1231 }
1232 }
1233
1234 return retval;
1235}
1236
1237/**
1238 * @brief Get file status information

Callers 3

lseekFunction · 0.70
seekdirFunction · 0.70
rewinddirFunction · 0.70

Calls 3

dfs_is_mountedFunction · 0.85
dfs_file_get_fposFunction · 0.85
dfs_file_set_fposFunction · 0.85

Tested by

no test coverage detected