First, verify that the target file system is VxFS, and then determine the file system block size using the statfs
() call. The type for VxFS is MNT_VXFS
on most platforms, and the file system block size is returned in statfs.f_bsize. The block size must be known for setting or interpreting the extent attribute information through VxFS extent attribute APIs.
Each invocation of the VX_SETEXT
ioctl affects all the elements in the vx_ext
structure.
VX_GETEXT
ioctl to read the current settings, if any.
VX_SETEXT
ioctl to set the new values.
Caution
Follow this procedure carefully. A fixed extent size may be inadvertently cleared when the reservation is changed. When copying files between VxFS and non-VxFS file systems, the extent attributes cannot be preserved. Note that the attribute values returned for a file in a vx_ext
structure will have a different effect on another VxFS file system with a different file system block size from the source file system. Translation of attribute values for different block sizes may be necessary when copying files with attributes between two file systems of a different block size.
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:
fd = open(MY_FILE, O_CREAT, 0644);
myext.ext_size = MY_PREFERRED_EXTSIZE;
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 the target file system block size is THIS_FS_BLOCKSIZE
:
fd = open(MY_FILE, O_CREAT, 0644);
myext.reserve = (MY_FILESIZE_IN_BYTES + THIS_FS_BLOCKSIZE) /