Veritas™ File System 5.0.1 Programmer's Reference Guide

fd = open("/mnt", O_RDONLY);
dir_fd = open("/mnt/dir1", O_RDONLY);
vxfs_ap_define(fd, &ap, 0);
/* Create the mirror policy */
strcpy((char *) ap.ap_name, "Mirror_Policy");
ap.ap_flags = FSAP_CREATE | FSAP_INHERIT;
ap.ap_order = FSAP_ORDER_ASGIVEN;
ap.ap_ndevs = 1;
strcpy(ap.ap_devs[0], "vol-01");
vxfs_ap_define(fd, &ap, 0);
/* Assign policies to the directory */
vxfs_ap_assign_file(dir_fd, "RAID5_Policy", “Mirror_Policy”,
0);
/* Create file under directory dir1 */
/* Meta and data blocks for file1 will be allocated on
vol-01 and vol-02 respectively. */
file_fd = open("/mnt/dir1/file1");
write(file_fd, buf, 1024);
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);
Multi-volume support
Using policies and application programming interfaces
60