---
name: "gfs_pio_truncate"
section: "3"
platform: "linux"
package: "libgfarm-dev"
version: "2.4.1-1.1"
release: "Debian 7 (Wheezy)"
platforms: ["linux"]
url: "https://new.carta.tech/gfs_pio_truncate"
---

# gfs\_pio\_truncate(3)

truncate a file to a specified length

## NAME

gfs\_pio\_truncate - truncate a file to a specified length

## SYNOPSIS

**#include \<gfarm/gfarm.h\>**

**char \*gfs\_pio\_truncate (GFS\_File** *gf***, file\_offset\_t** *length***);**

## DESCRIPTION

The **gfs\_pio\_truncate()** function truncates the regular file *gf* to the *length* bytes.

If the file was previously shorter than the length, it is extended, and the extended part is filled by zero bytes.

The file pointer is not changed.

You must specify GFS\_FILE\_MODE\_WRITE in opening the file, because it must be open for writing.

## RETURN VALUES

- **NULL**

  The function terminated successfully.

- **GFARM\_ERR\_NO\_MEMORY**

  Insufficient memory was available.

- **Others**

  An error except the above occurred.  The reason is shown by its pointed strings.

## SEE ALSO

[**gfs\_pio\_create**(3)](/gfs_pio_create/3.md), [**gfs\_pio\_open**(3)](/gfs_pio_open/3.md)
