Symantec logo

How to use extent attribute APIs

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.

 To use VX_SETEXT

  1. Call the VX_GETEXT ioctl to read the current settings, if any.
  2. Modify the current values to be changed.
  3. Call the VX_SETEXT ioctl to set the new values.
    Warning: 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:

#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 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);