Veritas™ File System 5.0.1 Programmer's Reference Guide

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);
}
Command reference
When you use the cp, tar, ls or similar commands to copy or list a file with
named data streams, the file is copied or listed, but the attached named data
streams are not copied or listed.
69Named data streams
Application programming interface