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

Function dfs_file_ftruncate

components/dfs/dfs_v1/src/dfs_file.c:736–754  ·  view source on GitHub ↗

* this function is will cause the regular file referenced by fd * to be truncated to a size of precisely length bytes. * * @param fd the file descriptor. * @param length the length to be truncated. * * @return the status of truncated. */

Source from the content-addressed store, hash-verified

734 * @return the status of truncated.
735 */
736int dfs_file_ftruncate(struct dfs_file *fd, off_t length)
737{
738 int result;
739
740 /* fd is null or not a regular file system fd, or length is invalid */
741 if (fd == NULL || fd->vnode->type != FT_REGULAR || length < 0)
742 return -EINVAL;
743
744 if (fd->vnode->fops->ioctl == NULL)
745 return -ENOSYS;
746
747 result = fd->vnode->fops->ioctl(fd, RT_FIOFTRUNCATE, (void*)&length);
748
749 /* update current size */
750 if (result == 0)
751 fd->vnode->size = length;
752
753 return result;
754}
755
756#ifdef RT_USING_SMART
757int dfs_file_mmap2(struct dfs_file *fd, struct dfs_mmap2_args *mmap2)

Callers 1

ftruncateFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected