#include "dpssfs/dpssfs.h"
Create a DPSS descriptor for DPSS read/write calls.
dpssOpen() relies on the appropriate DPSS and (if necessary) DPSS server hosts to have been set. This happens automatically but the defaults can be overridden by either environmental variables or dpssSetHosts().
dpssOpen() returns a DPSSFS descriptor (0-63) on success or -1 on error. If the call fails, an error message should be available via dpssPerror().
Unlike the UNIX file system, it is an error to try to open a file for reading if the file does not already exist.
The underlying DPSS communications library is still quite verbose when errors occur. It will be muted in a future release.
WARNING: if the filename already exists on the DPSS, and you open a new file with mode (O_WRONLY | O_CREAT) using the same name, the previous file will be overwritten. Since the DPSS currently has a flat name space, you must be careful not to overwrite existing data.
Examples:
if (dpssInit() != DPSSFS_OK)
{
dpssPerror("dpssInit()")
exit(-1);
}
if ((dpssfd = dpssOpen(dpss_url, O_RDONLY, 0)) < 0)
{
dpssPerror("dpssOpen()");
exit(-1);
}
OR:
if ((dpssfd = dpssOpen(dpss_url, O_WRONLY, 0)) < 0)
{
dpssPerror("dpssOpen()");
exit(-1);
}
or, to overwrite existing files with the same name:
if ((dpssfd = dpssOpen(dpss_url, O_WRONLY | O_CREAT, 0)) < 0)
{
dpssPerror("dpssOpen()");
exit(-1);
}
Valid filename formats:
O_RDWR Coming soon. O_APPEND To be implemented in future revs. O_TRUNC To be implemented if demand warrants. O_NDELAY Not applicable to DPSSFS lib. O_NONBLOCK Not applicable to DPSSFS lib. O_SYNC Not applicable to DPSSFS lib. O_NOCTTY Not applicable to DPSSFS lib.mode - this arguement is ignored. It is present so the the API matches the UNIX open call.