AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
trunc.c File Reference

Truncating a vnode: changing a file's length. More...

#include <core/system.h>
#include <fs/vfs.h>
#include <dev/dev.h>
#include <mm/vm.h>

Go to the source code of this file.

Functions

int vfs_trunc (struct vnode *vnode, off_t len)
 Changes a file's length, through its filesystem.

Detailed Description

Truncating a vnode: changing a file's length.

Definition in file trunc.c.

Function Documentation

◆ vfs_trunc()

int vfs_trunc ( struct vnode * vnode,
off_t len )

Changes a file's length, through its filesystem.

The file's pages in the page cache between the old end and the new one are refreshed.

Parameters
vnodethe file
lenthe new length, in bytes
Returns
0, -EINVAL for a device or an invalid vnode, -ENOSYS if the filesystem can't truncate, or its error

Definition at line 19 of file trunc.c.

References vnode::fs, ISDEV, LOG_DEBUG, MAX, MIN, vnode::size, vops::trunc, vfs_trunc(), vnode_pages_update(), and fs::vops.

Referenced by posix_file_trunc(), and vfs_trunc().