/* this function is will cause the regular file referenced by fd to be truncated to a size of precisely length bytes. */
int dfs_file_ftruncate(struct dfs_fd *fd, off_t length)
/* this function is will cause the regular file referenced by fd to be truncated to a size of precisely length bytes. */
int dfs_file_ftruncate(struct dfs_fd *fd, off_t length)
{
    int result;
    if (fd == NULL || fd->type != FT_REGULAR || length < 0)
        return -EINVAL;
    if (fd->fops->ioctl == NULL)
        return -ENOSYS;
    result = fd->fops->ioctl(fd, RT_FIOFTRUNCATE, (void*)&length);
    if (result == 0)
        fd->size = length;
    return result;
}