af_crkey(3) AtFS file system operations

Other Alias

af_open, af_close, af_rm, af_establish, af_restore

SYNOPSIS

#include <stdio.h>
#include <atfs.h>

int af_crkey (char *syspath, char *name, char *type, Af_key *aso)

FILE *af_open (Af_key *aso, char *mode)

int af_close (FILE *stream)

int af_rm (Af_key *aso)

int af_establish (Af_key *aso, char *filename)

int af_restore (Af_key *aso, Af_key *restoredAso)

DESCRIPTION

af_crkey creates an object key for a regular UNIX file identified by name, type and system path. syspath is an either absolute or relative directory name. An empty syspath refers to the current directory. By convention, AtFS interprets the filename suffix of a UNIX file as type and the filename without suffix as name attribute. To give an example, the path name

/usr/andy/foo.c is split up in /usr/andy (syspath) foo (name) c (type)

A period as first character in the filename is always considered as part of the name. Hence .cshrc has a name but no type. "." and ".." are recognized as names too. If the named UNIX file does not exist, af_crkey creates an empty file. The created key remains accessible until it is explicitly given up by af_dropkey (manual page af_retrieve(3)).

af_open opens the contents of the ASO pointed to by aso and associates a stream with it. A pointer to the FILE structure associated with the stream is returned. Mode is a character string that is either "r[+]", "w[+]" or "a[+]". See fopen(3) for further details. Upon error, af_open returns a NULL pointer. Non-busy ASOs can only be opened with mode "r". If a non-busy ASO is opened, it's contents will be placed in a temporary UNIX file due to storage of versions as deltas.

af_close closes a stream previously opened by af_open (see fclose(3)). Temporary files created by af_open, holding the contents of a saved versions are unlinked right after being opened so that they will automatically disappear on closing.

af_rm removes the specified ASO. The application has to have a lock (see af_lock(3)) set on the ASO that shall be deleted by af_rm. ASOs with the state attribute set to accessed or frozen cannot be removed. If you keep multiple keys of one object (perhaps in different sets) af_rm invalidates all keys of the removed object. As AtFS does not support multiple links to saved ASOs, af_rm on a saved version always does a physical removal.

af_establish establishes the contents of the saved version, pointed to by aso in a file named filename. The resulting file gets the version's modification and access date.

af_restore is used to restore formerly saved derived ASOs into their old file location. It also restores the file modification and access date. This function cannot be applied to source objects. af_restore returns the key of the restored version in the buffer restoredAso.

DIAGNOSTICS

Upon error, -1 or a nil pointer (depending on the return type) is returned and af_errno is set to the corresponding error number.