Application programming interface

The named data streams API uses a combination of standard system calls and VxFS API calls to utilize its functionality.

The following is an example of pseudo code to query named data streams:

/* Create and open a file */
if ((fd = open("named_stream_file", O_RDWR | O_CREAT | O_TRUNC,
    mode)) < 0) {
    sprintf(error_buf, "%s, Error Opening File %s ", argv[0],
            filename);
    perror(error_buf);
    exit(-1);
}
/* Write to the regular file as usual */
write(fd, buf, 1024);
/* Create several named data streams for file
   named_stream_file */
for (i = 0; i < 20; i++) {
   sprintf(attrname, "%s%d", "stream", i);
   nfd = vxfs_nattr_open(fd, attrname, O_WRONLY | O_CREAT,
       mode);
   if (nfd < 0) {
      sprintf(error_buf,
         "%s, Error Opening Attribute file %s/./%s ",
         argv[0], filename, attrname);
      perror(error_buf);
      exit(-1);
   }
   /* Write some data to the stream file */
   memset(buf, 0x41 + i, 1024);
   write(nfd, buf, 1024);
   close(nfd);
}