The following is an example code snippet for setting the fixed extent size of the MY_PREFERRED_EXTSIZE attribute on a new file, MY_FILE
, assuming MY_PREFFERED_EXTSIZE is multiple of the file system block size:
#include <sys/fs/vx_ioctl.h> struct vx_ext myext; fd = open(MY_FILE, O_CREAT, 0644); myext.ext_size = MY_PREFERRED_EXTSIZE; myext.reserve = 0; myext.flags = 0; error = ioctl(fd, VX_SETEXT, &myext);
The following is an example code snippet for preallocating MY_FILESIZE_IN_BYTES bytes of space on the new file, MY_FILE
, assuming that the target file system block size is THIS_FS_BLOCKSIZE:
#include <sys/fs/vx_ioctl.h> struct vx_ext myext; fd = open(MY_FILE, O_CREAT, 0644); myext.ext_size =0; myext.reserve = (MY_FILESIZE_IN_BYTES + THIS_FS_BLOCKSIZE) /THIS_FS_BLOCKSIZE; myext.flags = VX_CHGSIZE; error = ioctl(fd, VX_SETEXT, &myext);