include/dmlite/c/inode.h File Reference

C wrapper for DMLite INode API. More...

#include "dmlite.h"
#include "any.h"
#include "utils.h"
#include <stdint.h>
Include dependency graph for inode.h:

Go to the source code of this file.

Classes

struct  dmlite_replica
struct  dmlite_xstat

Typedefs

typedef struct dmlite_idir dmlite_idir

Enumerations

enum  dmlite_replica_status { kAvailable = '-', kBeingPopulated = 'P', kToBeDeleted = 'D' }
enum  dmlite_replica_type { kVolatile = 'V', kPermanent = 'P' }
enum  dmlite_file_status { kOnline = '-', kMigrated = 'm' }

Functions

int dmlite_ibegin (dmlite_context *context)
 Starts a transaction.
int dmlite_icommit (dmlite_context *context)
 Commits the changes.
int dmlite_irollback (dmlite_context *context)
 Undo the changes.
int dmlite_icreate (dmlite_context *context, const dmlite_xstat *f)
 Creates a new file.
int dmlite_isymlink (dmlite_context *context, ino_t inode, const char *link)
 Associates a symlink with an existing file.
int dmlite_iunlink (dmlite_context *context, ino_t inode)
 Removes a file or directory from the database.
int dmlite_imove (dmlite_context *context, ino_t inode, ino_t dest)
 Moves a file to a different parent directory.
int dmlite_irename (dmlite_context *context, ino_t inode, const char *name)
 Changes the name of an entry.
int dmlite_istat (dmlite_context *context, ino_t inode, struct stat *buf)
 Does a stat of an entry using the inode instead of the path.
int dmlite_istatx (dmlite_context *context, ino_t inode, dmlite_xstat *buf)
 Does an extended stat of an entry using the inode instead of the path.
int dmlite_istatx_by_name (dmlite_context *context, ino_t parent, const char *name, dmlite_xstat *buf)
 Does an extended stat using the parent inode and the entry name.
int dmlite_ireadlink (dmlite_context *context, ino_t inode, char *path, size_t bufsize)
 Reads a symbolic link.
int dmlite_iaddreplica (dmlite_context *context, const dmlite_replica *replica)
 Adds a new replica.
int dmlite_ideletereplica (dmlite_context *context, const dmlite_replica *replica)
 Deletes a replica.
int dmlite_igetreplica (dmlite_context *context, int64_t rid, dmlite_replica *buf)
 Gets a specific replica using its replica id.
int dmlite_igetreplicas (dmlite_context *context, ino_t inode, unsigned *nreplicas, dmlite_replica **replicas)
 Gets all the replicas associated to a file.
int dmlite_iutime (dmlite_context *context, ino_t inode, const struct utimbuf *buf)
 Sets the access and modification time.
int dmlite_isetmode (dmlite_context *context, ino_t inode, uid_t uid, gid_t gid, mode_t mode, unsigned nentries, dmlite_aclentry *acl)
 Sets the mode and ACL of a file.
int dmlite_isetsize (dmlite_context *context, ino_t inode, size_t size)
 Sets the size of a file.
int dmlite_isetchecksum (dmlite_context *context, ino_t inode, const char *csumtype, const char *csumvalue)
 Sets the checksum of a file.
int dmlite_igetcomment (dmlite_context *context, ino_t inode, char *comment, size_t bufsize)
 Gets the comment associated with an entry.
int dmlite_isetcomment (dmlite_context *context, ino_t inode, const char *comment)
 Sets the comment associated with an entry.
int dmlite_ideletecomment (dmlite_context *context, ino_t inode)
 Deletes the comment associated with an entry.
int dmlite_isetguid (dmlite_context *context, ino_t inode, const char *guid)
 Sets the file Grid Unique Identifier.
int dmlite_iupdate_xattr (dmlite_context *context, ino_t inode, const dmlite_any_dict *xattr)
 Updates the file extended attributes.
dmlite_idirdmlite_iopendir (dmlite_context *context, ino_t inode)
 Opens a directory.
int dmlite_iclosedir (dmlite_context *context, dmlite_idir *dir)
 Closes a directory, freeing any internally allocated memory.
dmlite_xstatdmlite_ireaddirx (dmlite_context *context, dmlite_idir *dir)
 Reads a directory. Extended data.
struct dirent * dmlite_ireaddir (dmlite_context *context, dmlite_idir *dir)
 Reads a directory.

Detailed Description

C wrapper for DMLite INode API.

Author:
Alejandro Álvarez Ayllon <aalvarez@cern.ch>
Note:
This is a low-level API, so security checks will NOT be done.

Typedef Documentation

typedef struct dmlite_idir dmlite_idir

Opaque directory handler


Enumeration Type Documentation

Posible file statuses

Enumerator:
kOnline 
kMigrated 

Possible replica statuses

Enumerator:
kAvailable 
kBeingPopulated 
kToBeDeleted 

Possible replica types

Enumerator:
kVolatile 
kPermanent 

Function Documentation

int dmlite_iaddreplica ( dmlite_context context,
const dmlite_replica replica 
)

Adds a new replica.

Parameters:
context The DM context.
replica The replica to add. replica->fileid must point to a valid file.
Returns:
0 on success, error code otherwise.
int dmlite_ibegin ( dmlite_context context  ) 

Starts a transaction.

Depending on the plugin stack, it can be possible to nest several calls.

Parameters:
context The DM context.
Returns:
0 on success, error code otherwise.
int dmlite_iclosedir ( dmlite_context context,
dmlite_idir dir 
)

Closes a directory, freeing any internally allocated memory.

Parameters:
context The DM context.
dir The directory to close, as returned by dmlite_opendir.
Returns:
0 on success, error code otherwise.
int dmlite_icommit ( dmlite_context context  ) 

Commits the changes.

Depending on the plugin stack, it can be possible to nest several calls, and there must be one icommit per ibegin for the changes to be permanent.

Parameters:
context The DM context.
Returns:
0 on success, error code otherwise.
int dmlite_icreate ( dmlite_context context,
const dmlite_xstat f 
)

Creates a new file.

Parameters:
context The DM context.
f Only some fields from this struct will be used. That would depend on the plugin, but usually it will be: parent, name, mode, uid, gid, size, status, checksum and ACL.
Returns:
0 on success, error code otherwise.
Note:
mode will probably be used raw (i.e. no cleanup or set of format bits)
int dmlite_ideletecomment ( dmlite_context context,
ino_t  inode 
)

Deletes the comment associated with an entry.

Parameters:
context The DM context.
inode The file id.
Returns:
0 on success, error code otherwise.
int dmlite_ideletereplica ( dmlite_context context,
const dmlite_replica replica 
)

Deletes a replica.

Parameters:
context The DM context.
replica The replica to remove.
Returns:
0 on success, error code otherwise.
int dmlite_igetcomment ( dmlite_context context,
ino_t  inode,
char *  comment,
size_t  bufsize 
)

Gets the comment associated with an entry.

Parameters:
context The DM context.
inode The file id.
comment Where to put the comment.
bufsize The size of the memory pointed by comment.
Returns:
0 on success, error code otherwise.
int dmlite_igetreplica ( dmlite_context context,
int64_t  rid,
dmlite_replica buf 
)

Gets a specific replica using its replica id.

Parameters:
context The DM context.
rid The replica id.
buf Where to put the retrieved data.
Returns:
0 on success, error code otherwise.
int dmlite_igetreplicas ( dmlite_context context,
ino_t  inode,
unsigned *  nreplicas,
dmlite_replica **  replicas 
)

Gets all the replicas associated to a file.

Parameters:
context The DM context.
inode The file id.
nreplicas The number of replicas will be put here.
replicas It will be initialized to an array of nreplicas replicas. Free it with dmlite_replicas_free.
Returns:
0 on success, error code otherwise.
int dmlite_imove ( dmlite_context context,
ino_t  inode,
ino_t  dest 
)

Moves a file to a different parent directory.

Parameters:
context The DM context.
inode The file id.
dest The destination id.
Returns:
0 on success, error code otherwise.
dmlite_idir* dmlite_iopendir ( dmlite_context context,
ino_t  inode 
)

Opens a directory.

Parameters:
context The DM context.
inode The directory ID.
Returns:
NULL on failure. A pointer to an internal struct to be used with dmlite_ireaddir*
struct dirent* dmlite_ireaddir ( dmlite_context context,
dmlite_idir dir 
) [read]

Reads a directory.

Parameters:
context The DM context.
dir The directory to read, as 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_ireaddirx ( dmlite_context context,
dmlite_idir dir 
)

Reads a directory. Extended data.

Parameters:
context The DM context.
dir The directory to read, as 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_ireadlink ( dmlite_context context,
ino_t  inode,
char *  path,
size_t  bufsize 
)

Reads a symbolic link.

Parameters:
context The DM context.
inode The file id.
path The link will be put here.
bufsize The size of the memory area pointed by path.
Returns:
0 on success, error code otherwise.
int dmlite_irename ( dmlite_context context,
ino_t  inode,
const char *  name 
)

Changes the name of an entry.

Parameters:
context The DM context.
inode The file id.
name The new name.
Returns:
0 on success, error code otherwise.
int dmlite_irollback ( dmlite_context context  ) 

Undo the changes.

If several ibegin were nested, all the transactions will be probable be undone, regardless on the nesting level.

Parameters:
context The DM context.
Returns:
0 on success, error code otherwise.
int dmlite_isetchecksum ( dmlite_context context,
ino_t  inode,
const char *  csumtype,
const char *  csumvalue 
)

Sets the checksum of a file.

Parameters:
context The DM context.
inode The file id.
csumtype The new checksum type.
csumvalue The new checksum value.
Returns:
0 on success, error code otherwise.
int dmlite_isetcomment ( dmlite_context context,
ino_t  inode,
const char *  comment 
)

Sets the comment associated with an entry.

Parameters:
context The DM context.
inode The file id.
comment The new comment.
Returns:
0 on success, error code otherwise.
int dmlite_isetguid ( dmlite_context context,
ino_t  inode,
const char *  guid 
)

Sets the file Grid Unique Identifier.

Parameters:
context The DM context.
inode The entry id.
guid The new GUID.
Returns:
0 on success, error code otherwise.
int dmlite_isetmode ( dmlite_context context,
ino_t  inode,
uid_t  uid,
gid_t  gid,
mode_t  mode,
unsigned  nentries,
dmlite_aclentry acl 
)

Sets the mode and ACL of a file.

Parameters:
context The DM context.
inode The file id.
uid The new UID.
gid The new GID.
mode The new mode.
nentries The number of acl entries.
acl The new ACL.
Returns:
0 on success, error code otherwise.
Note:
This call may not validate that uid, gid, mode and acl are coherent.
int dmlite_isetsize ( dmlite_context context,
ino_t  inode,
size_t  size 
)

Sets the size of a file.

Parameters:
context The DM context.
inode The file id.
size The new size.
Returns:
0 on success, error code otherwise.
int dmlite_istat ( dmlite_context context,
ino_t  inode,
struct stat *  buf 
)

Does a stat of an entry using the inode instead of the path.

Parameters:
context The DM context.
inode The entry inode.
buf Where to put the retrieved information.
Returns:
0 on success, error code otherwise.
Note:
Security checks won't be done if you use this function, so keep in mind doing it yourself.
int dmlite_istatx ( dmlite_context context,
ino_t  inode,
dmlite_xstat buf 
)

Does an extended stat of an entry using the inode instead of the path.

Parameters:
context The DM context.
inode The entry inode.
buf Where to put the retrieved information.
Returns:
0 on success, error code otherwise.
Note:
Security checks won't be done if you use this function, so keep in mind doing it yourself.
int dmlite_istatx_by_name ( dmlite_context context,
ino_t  parent,
const char *  name,
dmlite_xstat buf 
)

Does an extended stat using the parent inode and the entry name.

Parameters:
context The DM context.
parent The parent id.
name The entry name.
buf Where to put the retrieved information.
Returns:
0 on success, error code otherwise.
int dmlite_isymlink ( dmlite_context context,
ino_t  inode,
const char *  link 
)

Associates a symlink with an existing file.

Parameters:
context The DM context.
inode The file that will be a symlink.
link The destination link.
Returns:
0 on success, error code otherwise.
int dmlite_iunlink ( dmlite_context context,
ino_t  inode 
)

Removes a file or directory from the database.

Parameters:
context The DM context.
inode The id of the entry to remove.
Returns:
0 on success, error code otherwise.
Note:
Not empty directories, or files will replicas may fail.
int dmlite_iupdate_xattr ( dmlite_context context,
ino_t  inode,
const dmlite_any_dict xattr 
)

Updates the file extended attributes.

Parameters:
context The DM context.
inode The entry id.
xattr The new set of extended attributes.
Returns:
0 on success, error code otherwise.
int dmlite_iutime ( dmlite_context context,
ino_t  inode,
const struct utimbuf *  buf 
)

Sets the access and modification time.

Parameters:
context The DM context.
inode The file id.
buf The timestamps.
Returns:
0 on success, error code otherwise.

Generated on 18 Nov 2014 for dmlite by  doxygen 1.6.1