atOpenExpand(3) read version objects with

Other Alias

atReadExpand, atCloseExpand

SYNOPSIS

#include <atfs.h>
#include <atfstk.h>

int atOpenExpand(char *version, int expand_busy) ;

int atReadExpand(int desc, char *bufp, int nbytes) ;

void atCloseExpand(int desc) ;

char *atGetWriteName(int desc) ;

extern int atBindError ;
extern char atBindErrorMsg[] ;

DESCRIPTION

atOpenExpand, atReadExpand, and atCloseExpand are designed as a nearly plug-compatible replacement for the system calls open(2), read(2), and close(2) for reading of AtFS version objects with attribute citations expanded.

atOpenExpand opens the file or AtFS version object version for reading with atReadExpand. Version points to the pathname of a file or AtFS version object. If the flag expand_busy is non-zero, attribute citations are expanded in busy versions also. atOpenExpand returns a descriptor that is valid as argument to successive calls to atReadExpand and atCloseExpand.

atReadExpand attempts to read nbytes of data from the object referenced by the descriptor desc into the buffer pointed to by bufp. If desc is zero, atReadExpand reads from the standard input. atReadExpand returns the number of bytes actually read.

atCloseExpand frees the resources associated with the descriptor desc.

atGetWriteName returns a pointer to the bound version name of the version object for which atOpenExpand returned the descriptor desc.

DIAGNOSTICS

On error atOpenExpand and atReadExpand return -1 and set errno appropriately. If one of these returns an error and errno is set to ENOMEM, the application may retry the operation, possibly after freeing some memory.

If atOpenExpand returns an error and atBindError has a non-zero value, the string version did not select a version object or not a unique version object. In this case atBindErrorMsg contains an appropriate error message.

Possible Values of errno after a call to atOpenExpand:

ENOMEM
Not enough memory could be allocated.
EMFILE
All available descriptors are in use.

All errno values returned by open(2) or read(2).

Possible Values of errno after a call to atReadExpand:

ENOMEM
Not enough memory could be allocated.
EBADF
Invalid descriptor.

BUGS

Since atOpenExpand reads the complete contents of version into memory, it fails on very large version objects.