File system

File system ftruncate

ftruncate

// PROTOTYPE
int ftruncate(int fd, off_t length)

Truncate an open file to a given length.

  • fd: The file descriptor for the file, return from the open call.
  • length: length in bytes.

Returns 0 on success. On error, returns -1 and sets errno. Some possible errno values include:

  • ENOENT: File does not exist.
  • ENOSPC There is no space on the file system.