dmlite  0.6
Typedefs | Functions
catalog.h File Reference

C wrapper for DMLite Catalog API. More...

#include "dmlite.h"
#include "inode.h"
#include "utils.h"
Include dependency graph for catalog.h:

Go to the source code of this file.

Typedefs

typedef struct dmlite_dir dmlite_dir
 

Functions

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

Detailed Description

C wrapper for DMLite Catalog API.

Author
Alejandro Álvarez Ayllon aalva.nosp@m.rez@.nosp@m.cern..nosp@m.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
contextThe DM context.
lfnLogical filename.
modeA 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
contextThe DM context.
rfnReplica filename.
modeA 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
contextThe DM context.
replicaThe replica to add.
Returns
0 on success, error code otherwise.
int dmlite_chdir ( dmlite_context context,
const char *  path 
)

Changes the working dir.

Parameters
contextThe DM context.
pathThe 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
contextThe DM context.
pathThe logical path.
modeThe 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
contextThe DM context.
pathThe logical path.
newUidThe new owner.
newGidThe 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
contextThe DM context.
dirThe 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
contextThe DM context.
pathThe logical file name.
modeThe creation mode.
Returns
0 on success, error code otherwise.
int dmlite_delreplica ( dmlite_context context,
const dmlite_replica replica 
)

Deletes a replica.

Parameters
contextThe DM context.
replicaThe replica to delete.
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
contextThe DM context.
pathThe logical path.
commentWhere to put the retrieved comment. It must be at least of size COMMENT_MAX.
bufsizeSize 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
contextThe DM context.
bufferIf not NULL, the path will be stored here. malloc will be used otherwise.
sizeThe 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
contextThe DM context.
groupNameThe group name.
gidWhere 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
contextThe DM context.
rfnThe replica file name.
replicaA 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
contextThe DM context.
pathThe logical file name.
nReplicasThe number of entries will be put here.
fileReplicasAn 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
contextThe DM context.
userNameThe user name.
uidWhere 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
contextThe DM context.
pathThe logical path.
newUidThe new owner.
newGidThe 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
contextThe DM context.
pathThe directory for the new path. All the precedent folders must exist.
modePermissions 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
contextThe DM context.
pathThe 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
contextThe DM context.
dirThe 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
contextThe DM context.
dirThe 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_readlink ( dmlite_context context,
const char *  path,
char *  buf,
size_t  bufsize 
)

Reads a symlink.

Parameters
contextThe DM context.
pathThe symlink file.
bufWhere to put the symlink target.
bufsizeThe size of the memory pointed by buf.
Returns
0 on success, error code otherwise.
int dmlite_rename ( dmlite_context context,
const char *  oldPath,
const char *  newPath 
)

Renames a file, directory or symlink.

Parameters
contextThe DM context.
oldPathThe old name.
newPathThe new name.
Returns
0 on success, error code otherwise.
int dmlite_replicas_free ( unsigned  nReplicas,
dmlite_replica fileReplicas 
)

Frees a replica list.

Parameters
nReplicasThe number of replicas contained in the array.
fileReplicasThe 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
contextThe DM context.
pathThe 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
contextThe DM context.
rfnReplica filename.
bufWhere 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
contextThe DM context.
pathThe logical path.
nEntriesThe number of entries in the acl array.
aclAn 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
contextThe DM context.
pathThe logical path.
commentThe 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
contextThe DM context.
pathThe logical path.
filesizeThe 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
contextThe DM context.
pathThe logical path.
filesizeThe new file size.
csumtypeThe new checksum type (CS, AD or MD).
csumvalueThe 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
contextThe DM context.
pathThe logical path.
guidThe 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
contextThe DM context.
pathThe path.
bufWhere 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
contextThe DM context.
pathThe path.
bufWhere 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
contextThe DM context.
pathThe path.
bufWhere to put the retrieved information.
Returns
0 on success, error code otherwise.
int dmlite_symlink ( dmlite_context context,
const char *  oldPath,
const char *  newPath 
)

Creates a symlink.

Parameters
contextThe DM context.
oldPathThe old path.
newPathThe new path.
Returns
0 on success, error code otherwise.
mode_t dmlite_umask ( dmlite_context context,
mode_t  mask 
)

Sets the file mode creation mask.

Parameters
contextThe DM context.
maskThe new mask.
Returns
The previous mask.
int dmlite_unlink ( dmlite_context context,
const char *  path 
)

Removes a file.

Parameters
contextThe DM context.
pathThe logical file name.
Returns
0 on success, error code otherwise.
int dmlite_update_xattr ( dmlite_context context,
const char *  path,
const dmlite_any_dict xattr 
)

Updates the file extended attributes.

Parameters
contextThe DM context.
pathThe logical path.
xattrThe 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
contextThe DM context.
replicaThe 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
contextThe DM context.
pathThe file path.
bufA struct holding the new times.
Returns
0 on success, error code otherwise.