The following pseudocode provides an example of using the volume APIs.
To shrink or grow a volume within a file system
/* 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
/* 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", infop->dev_size); /* 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
To de-encapsulate the raw volume vol-03 named encapsulate_name in the file system /mnt, create code similar to the following:
/* Use de-ecapsulate to remove raw volume. After de-encapsulation, vol-03 is still part of volset, but is not an active part of the file system. */ vxfs_vol_deencapsulate("/mnt/encapsulate_name");