DCMD_FSYS_PREGROW_FILE

Updated: April 19, 2023

Extend a file, optionally zero-filling it

Synopsis:

#include <sys/dcmd_blk.h>

#define DCMD_FSYS_PREGROW_FILE   __DIOT(_DCMD_FSYS,  14, off64_t)

Arguments to devctl():

Argument Value
filedes A file descriptor that you obtained by opening the device.
dcmd DCMD_FSYS_PREGROW_FILE
dev_data_ptr A pointer to a off64_t
n_bytes sizeof(off64_t)
dev_info_ptr NULL

Description:

This command extends a file, optionally zero-filling it. In contrast, the POSIX ftruncate() function extends a file and zero-fills the new data space.

In order to use this command, your process needs to have the vfs/pregrow (BLK_ABILITY_PREGROW) custom ability enabled. For more information, see procmgr_ability() and procmgr_ability_lookup() in the C Library Reference.

The pregrow-fill option to io-blk.so specifies whether or not this command zeroes the content when growing files. Zeroing the content is the default but increases the time for pregrowing files; not zeroing is very fast but insecure, as it allows access to the old content of the disk blocks.

Input:

The file size.

Output:

None.

Example:

int fd;
off64_t sz;

fd=open(...);
sz=...;

if (devctl(fd, DCMD_FSYS_PREGROW_FILE, &sz, sizeof(sz), NULL) != EOK)
{
   /* Error */
}

See also:

devctl(), ftruncate() in the QNX Neutrino C Library Reference

io-blk.so in the Utilities Reference