catalog.h man page

catalog.h — C wrapper for DMLite Catalog API.

Synopsis

#include 'dmlite.h'
#include 'inode.h'
#include 'utils.h'

Typedefs

typedef struct dmlite_dir dmlite_dir

Functions

int dmlite_chdir (dmlite_context *context, const char *path)
Changes the working dir.
char * dmlite_getcwd (dmlite_context *context, char *buffer, size_t size)
Gets the current working directory.
mode_t dmlite_umask (dmlite_context *context, mode_t mask)
Sets the file mode creation mask.
int dmlite_stat (dmlite_context *context, const char *path, struct stat *buf)
Does a stat of a file or directory.
int dmlite_statl (dmlite_context *context, const char *path, struct stat *buf)
Does a stat of a file, directory, or symbolic link (does not follow).
int dmlite_statx (dmlite_context *context, const char *path, dmlite_xstat *buf)
Does an extended stat of a file, directory or symbolic link.
int dmlite_rstatx (dmlite_context *context, const char *rfn, dmlite_xstat *buf)
Does an extended stat of a logical file using an associated replica filename.
int dmlite_access (dmlite_context *context, const char *lfn, int mode)
Checks wether the process would be allowed to read, write, or check existence.
int dmlite_accessr (dmlite_context *context, const char *rfn, int mode)
Checks wether the process would be allowed to read, write, or check existence.
int dmlite_addreplica (dmlite_context *context, const dmlite_replica *replica)
Adds a new replica to an entry.
int dmlite_delreplica (dmlite_context *context, const dmlite_replica *replica)
Deletes a replica.
int dmlite_getreplicas (dmlite_context *context, const char *path, unsigned *nReplicas, dmlite_replica **fileReplicas)
Gets the replicas of a file.
int dmlite_replicas_free (unsigned nReplicas, dmlite_replica *fileReplicas)
Frees a replica list.
int dmlite_symlink (dmlite_context *context, const char *oldPath, const char *newPath)
Creates a symlink.
int dmlite_readlink (dmlite_context *context, const char *path, char *buf, size_t bufsize)
Reads a symlink.
int dmlite_unlink (dmlite_context *context, const char *path)
Removes a file.
int dmlite_create (dmlite_context *context, const char *path, mode_t mode)
Creates a file in the catalog (no replicas).
int dmlite_chmod (dmlite_context *context, const char *path, mode_t mode)
Changes the mode of a file or directory.
int dmlite_chown (dmlite_context *context, const char *path, uid_t newUid, gid_t newGid)
Changes the owner of a file or directory.
int dmlite_lchown (dmlite_context *context, const char *path, uid_t newUid, gid_t newGid)
Changes the owner of a file, directory or symlink (does not follow).
int dmlite_setfsize (dmlite_context *context, const char *path, uint64_t filesize)
Changes the size of a file in the catalog.
int dmlite_setfsizec (dmlite_context *context, const char *path, uint64_t filesize, const char *csumtype, const char *csumvalue)
Changes the size and checksum of a file in the catalog.
int dmlite_getchecksum (dmlite_context *context, const char *path, const char *csumtype, char *csumvalue, const int maxcksumlen, const char *pfn, const int forcerecalc, const int waitsecs)
Gets the checksum of a file in the catalog.
int dmlite_setacl (dmlite_context *context, const char *path, unsigned nEntries, dmlite_aclentry *acl)
Changes the ACL of a file.
int dmlite_utime (dmlite_context *context, const char *path, const struct utimbuf *buf)
Changes access and/or modification time.
int dmlite_getcomment (dmlite_context *context, const char *path, char *comment, size_t bufsize)
Gets the comment associated with a file.
int dmlite_setcomment (dmlite_context *context, const char *path, const char *comment)
Sets the comment associated with a file.
int dmlite_setguid (dmlite_context *context, const char *path, const char *guid)
Sets the file Grid Unique Identifier.
int dmlite_update_xattr (dmlite_context *context, const char *path, const dmlite_any_dict *xattr)
Updates the file extended attributes.
int dmlite_getgrpbynam (dmlite_context *context, const char *groupName, gid_t *gid)
Gets the id of a group.
int dmlite_getusrbynam (dmlite_context *context, const char *userName, uid_t *uid)
Get the user id.
dmlite_dir * dmlite_opendir (dmlite_context *context, const char *path)
Opens a directory to read it later.
int dmlite_closedir (dmlite_context *context, dmlite_dir *dir)
Closes a directory and free the internal structures.
struct dirent * dmlite_readdir (dmlite_context *context, dmlite_dir *dir)
Reads an entry from a directory.
dmlite_xstat * dmlite_readdirx (dmlite_context *context, dmlite_dir *dir)
Reads an entry from a directory (extended data).
int dmlite_mkdir (dmlite_context *context, const char *path, mode_t mode)
Creates a new directory.
int dmlite_rename (dmlite_context *context, const char *oldPath, const char *newPath)
Renames a file, directory or symlink.
int dmlite_rmdir (dmlite_context *context, const char *path)
Deletes a directory. It must be empty.
int dmlite_getreplica_by_rfn (dmlite_context *context, const char *rfn, dmlite_replica *replica)
Gets a specific replica.
int dmlite_updatereplica (dmlite_context *context, const dmlite_replica *replica)
Updates a replica.

Detailed Description

C wrapper for DMLite Catalog API.

Author:

Alejandro Álvarez Ayllon aalvarez@cern.ch

Typedef Documentation

typedef struct dmlite_dir dmlite_dir

Function Documentation

int dmlite_access (dmlite_context * context, const char * lfn, int mode)

Checks wether the process would be allowed to read, write, or check existence.

Parameters:

context The DM context.
lfn Logical filename.
mode A mask consisting of one or more of R_OK, W_OK, X_OK and F_OK.

Returns:

0 on success, error code otherwise.

int dmlite_accessr (dmlite_context * context, const char * rfn, int mode)

Checks wether the process would be allowed to read, write, or check existence.

Parameters:

context The DM context.
rfn Replica filename.
mode A mask consisting of one or more of R_OK, W_OK, X_OK and F_OK.

Returns:

0 on success, error code otherwise.

int dmlite_addreplica (dmlite_context * context, const dmlite_replica * replica)

Adds a new replica to an entry.

Parameters:

context The DM context.
replica The replica to add.

Returns:

0 on success, error code otherwise.

int dmlite_chdir (dmlite_context * context, const char * path)

Changes the working dir.

Parameters:

context The DM context.
path The new working dir.

Returns:

0 on success, error code otherwise.

int dmlite_chmod (dmlite_context * context, const char * path, mode_t mode)

Changes the mode of a file or directory.

Parameters:

context The DM context.
path The logical path.
mode The new mode.

Returns:

0 on success, error code otherwise.

int dmlite_chown (dmlite_context * context, const char * path, uid_t newUid, gid_t newGid)

Changes the owner of a file or directory.

Parameters:

context The DM context.
path The logical path.
newUid The new owner.
newGid The new group.

Returns:

0 on success, error code otherwise.

int dmlite_closedir (dmlite_context * context, dmlite_dir * dir)

Closes a directory and free the internal structures.

Parameters:

context The DM context.
dir The pointer returned by dmlite_opendir.

Returns:

0 on success, error code otherwise.

int dmlite_create (dmlite_context * context, const char * path, mode_t mode)

Creates a file in the catalog (no replicas).

Parameters:

context The DM context.
path The logical file name.
mode The creation mode.

Returns:

0 on success, error code otherwise.

int dmlite_delreplica (dmlite_context * context, const dmlite_replica * replica)

Deletes a replica.

Parameters:

context The DM context.
replica The replica to delete.

Returns:

0 on success, error code otherwise.

int dmlite_getchecksum (dmlite_context * context, const char * path, const char * csumtype, char * csumvalue, const int maxcksumlen, const char * pfn, const int forcerecalc, const int waitsecs)

Gets the checksum of a file in the catalog.

Parameters:

context The DM context.
path The logical path.
csumtype The wanted checksum type (CS, AD or MD. We can also pass a long checksum name (e.g. checksum.adler32))
csumvalue The wanted checksum value will be written into this string. Make sure it has enough space.
maxcksumlen Max allowed length for a checksum, to avoid buffer overflows.
pfn Optional: the corresponding replica for which to calculate a checksum
forcerecalc True if nonzero. Force recalculation of the checksum (may take long and return EAGAIN)
waitsecs Seconds to wait for a checksum to be calculated. Returns EAGAIN if timeouts. Set to 0 for blocking behavior.

Returns:

0 on success, error code otherwise.

int dmlite_getcomment (dmlite_context * context, const char * path, char * comment, size_t bufsize)

Gets the comment associated with a file.

Parameters:

context The DM context.
path The logical path.
comment Where to put the retrieved comment. It must be at least of size COMMENT_MAX.
bufsize Size of the memory zone pointed by comment.

Returns:

0 on success, error code otherwise.

char* dmlite_getcwd (dmlite_context * context, char * buffer, size_t size)

Gets the current working directory.

Parameters:

context The DM context.
buffer If not NULL, the path will be stored here. malloc will be used otherwise.
size The buffer size.

Returns:

A pointer to a string with the current working dir.

int dmlite_getgrpbynam (dmlite_context * context, const char * groupName, gid_t * gid)

Gets the id of a group.

Parameters:

context The DM context.
groupName The group name.
gid Where to put the group ID.

Returns:

0 on success, error code otherwise.

int dmlite_getreplica_by_rfn (dmlite_context * context, const char * rfn, dmlite_replica * replica)

Gets a specific replica.

Parameters:

context The DM context.
rfn The replica file name.
replica A buffer where the retrieved data will be put.

Returns:

0 on success, error code otherwise.

int dmlite_getreplicas (dmlite_context * context, const char * path, unsigned * nReplicas, dmlite_replica ** fileReplicas)

Gets the replicas of a file.

Parameters:

context The DM context.
path The logical file name.
nReplicas The number of entries will be put here.
fileReplicas An array with nEntries elements will be stored here. Use dmlite_replicas_free to free it.

Returns:

0 on success, error code otherwise.

int dmlite_getusrbynam (dmlite_context * context, const char * userName, uid_t * uid)

Get the user id.

Parameters:

context The DM context.
userName The user name.
uid Where to put the user ID.

Returns:

0 on success, error code otherwise.

int dmlite_lchown (dmlite_context * context, const char * path, uid_t newUid, gid_t newGid)

Changes the owner of a file, directory or symlink (does not follow).

Parameters:

context The DM context.
path The logical path.
newUid The new owner.
newGid The new group.

Returns:

0 on success, error code otherwise.

int dmlite_mkdir (dmlite_context * context, const char * path, mode_t mode)

Creates a new directory.

Parameters:

context The DM context.
path The directory for the new path. All the precedent folders must exist.
mode Permissions to use for the creation.

Returns:

0 on success, error code otherwise.

dmlite_dir* dmlite_opendir (dmlite_context * context, const char * path)

Opens a directory to read it later.

Parameters:

context The DM context.
path The directory to open.

Returns:

A pointer to an internal structure, or NULL on failure.

struct dirent* dmlite_readdir (dmlite_context * context, dmlite_dir * dir)

Reads an entry from a directory.

Parameters:

context The DM context.
dir The pointer returned by dmlite_opendir.

Returns:

A pointer to a struct with the recovered data. NULL on failure, or end of dir. If an error occurred, dm_errno(context) will be different than 0.

Note:

The pointer is internally allocated. Do not free it.

dmlite_xstat* dmlite_readdirx (dmlite_context * context, dmlite_dir * dir)

Reads an entry from a directory (extended data).

Parameters:

context The DM context.
dir The pointer returned by dmlite_opendir.

Returns:

A pointer to a struct with the recovered data. NULL on failure, or end of dir. If an error occurred, dm_errno(context) will be different than 0.

Note:

The pointer is internally allocated. Do not free it.

int dmlite_rename (dmlite_context * context, const char * oldPath, const char * newPath)

Renames a file, directory or symlink.

Parameters:

context The DM context.
oldPath The old name.
newPath The new name.

Returns:

0 on success, error code otherwise.

int dmlite_replicas_free (unsigned nReplicas, dmlite_replica * fileReplicas)

Frees a replica list.

Parameters:

nReplicas The number of replicas contained in the array.
fileReplicas The array to free.

Returns:

0 on success, error code otherwise.

int dmlite_rmdir (dmlite_context * context, const char * path)

Deletes a directory. It must be empty.

Parameters:

context The DM context.
path The directory to remove.

Returns:

0 on success, error code otherwise.

int dmlite_rstatx (dmlite_context * context, const char * rfn, dmlite_xstat * buf)

Does an extended stat of a logical file using an associated replica filename.

Parameters:

context The DM context.
rfn Replica filename.
buf Where to put the retrieved information.

Returns:

0 on success, error code otherwise.

int dmlite_setacl (dmlite_context * context, const char * path, unsigned nEntries, dmlite_aclentry * acl)

Changes the ACL of a file.

Parameters:

context The DM context.
path The logical path.
nEntries The number of entries in the acl array.
acl An ACL array.

Returns:

0 on success, error code otherwise.

int dmlite_setcomment (dmlite_context * context, const char * path, const char * comment)

Sets the comment associated with a file.

Parameters:

context The DM context.
path The logical path.
comment The comment to associate. '\0' terminated string.

Returns:

0 on success, error code otherwise.

int dmlite_setfsize (dmlite_context * context, const char * path, uint64_t filesize)

Changes the size of a file in the catalog.

Parameters:

context The DM context.
path The logical path.
filesize The new file size.

Returns:

0 on success, error code otherwise.

int dmlite_setfsizec (dmlite_context * context, const char * path, uint64_t filesize, const char * csumtype, const char * csumvalue)

Changes the size and checksum of a file in the catalog.

Parameters:

context The DM context.
path The logical path.
filesize The new file size.
csumtype The new checksum type (CS, AD or MD).
csumvalue The new checksum value.

Returns:

0 on success, error code otherwise.

int dmlite_setguid (dmlite_context * context, const char * path, const char * guid)

Sets the file Grid Unique Identifier.

Parameters:

context The DM context.
path The logical path.
guid The new GUID.

Returns:

0 on success, error code otherwise.

int dmlite_stat (dmlite_context * context, const char * path, struct stat * buf)

Does a stat of a file or directory.

Parameters:

context The DM context.
path The path.
buf Where to put the retrieved information.

Returns:

0 on success, error code otherwise.

int dmlite_statl (dmlite_context * context, const char * path, struct stat * buf)

Does a stat of a file, directory, or symbolic link (does not follow).

Parameters:

context The DM context.
path The path.
buf Where to put the retrieved information.

Returns:

0 on success, error code otherwise.

int dmlite_statx (dmlite_context * context, const char * path, dmlite_xstat * buf)

Does an extended stat of a file, directory or symbolic link.

Parameters:

context The DM context.
path The path.
buf Where to put the retrieved information.

Returns:

0 on success, error code otherwise.

mode_t dmlite_umask (dmlite_context * context, mode_t mask)

Sets the file mode creation mask.

Parameters:

context The DM context.
mask The new mask.

Returns:

The previous mask.

int dmlite_update_xattr (dmlite_context * context, const char * path, const dmlite_any_dict * xattr)

Updates the file extended attributes.

Parameters:

context The DM context.
path The logical path.
xattr The new set of extended attributes.

Returns:

0 on success, error code otherwise.

int dmlite_updatereplica (dmlite_context * context, const dmlite_replica * replica)

Updates a replica.

Parameters:

context The DM context.
replica The replica to modify.

Returns:

0 on success, error code otherwise.

int dmlite_utime (dmlite_context * context, const char * path, const struct utimbuf * buf)

Changes access and/or modification time.

Parameters:

context The DM context.
path The file path.
buf A struct holding the new times.

Returns:

0 on success, error code otherwise.

Author

Generated automatically by Doxygen for dmlite from the source code.

Info

Fri Sep 23 2016 Version 0.6 dmlite