Using volume application programming interfaces

The following pseudocode provides an example of using the volume APIs.

To shrink or grow a volume within a file system

  1. Use the vxresize command to grow the physical volume.
  2. To use the vxfs_vol_resize() call to shrink or grow the file system, create codes similar to the following:
    /* stat volume "vol-03" to get the size information */
    fd = open("/mnt");
    vxfs_vol_stat(fd, "vol-03", infop);
    /* resize (shrink/grow) accordingly. This example shrinks
           the volume by half */
    vxfs_vol_resize(fd, "vol-03", infop->dev_size / 2);

To encapsulate a raw volume as a file

  1. Add the volume to the volume set.
  2. To encapsulate a raw volume vol-03 as a file named encapsulate_name in the file system /mnt, create code similar to the following:
    /* Take the raw volume vol-03 and encapsulate it. The
        volume's contents will be accessible through the given
        path name. */
    vxfs_vol_encapsulate("/mnt/encapsulate_name", "vol-03",
    /* Access to the volume is through writes and reads of file
         "/mnt/encapsulate_name" */
    encap_fd = open("/mnt/encapsulate_name");
    write(encap_fd, buf, 1024);

To de-encapsulate a raw volume