---
name: "atread"
section: "3"
platform: "linux"
package: "atfs-dev"
version: "1.4pl6-15+b1"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/atread"
---

# atread(3)

read version objects with attribute citations expanded atGetWriteName - get bound version name of a version object opened with atOpenExpand

## NAME

atOpenExpand, atReadExpand, atCloseExpand - read version objects with attribute citations expanded\
 atGetWriteName - get bound version name of a version object opened with atOpenExpand

## 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)](/open/2.md), [*read*(2)](/read/2.md), and [*close*(2)](/close/2.md) 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)](/open/2.md) or [*read*(2)](/read/2.md).

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.

## SEE ALSO

[intro(2)](/intro/2.md), [open(2)](/open/2.md), [read(2)](/read/2.md), [close(2)](/close/2.md), [errno(3)](/errno/3.md), [atattribute(3)](/atattribute/3.md), [atbind(3)](/atbind/3.md).
