dmlite  0.6
Classes | Typedefs | Enumerations | Functions
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:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  dmlite_replica
 
struct  dmlite_xstat
 

Typedefs

typedef struct dmlite_replica dmlite_replica
 
typedef struct dmlite_xstat dmlite_xstat
 
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_replica_ps { kPrimary = 'P', kSecondary = 'S' }
 
enum  dmlite_file_status { kOnline = '-', kMigrated = 'm', kDeleted = 'D' }
 

Functions

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

Detailed Description

C wrapper for DMLite INode API.

Author
Alejandro Álvarez Ayllon aalva.nosp@m.rez@.nosp@m.cern..nosp@m.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

A replica of a file

typedef struct dmlite_xstat dmlite_xstat

File metadata

Enumeration Type Documentation

Posible file statuses

Enumerator
kOnline 
kMigrated 
kDeleted 

Possible replica modes

Enumerator
kPrimary 
kSecondary 

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
contextThe DM context.
replicaThe 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
contextThe 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
contextThe DM context.
dirThe 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
contextThe DM context.
Returns
0 on success, error code otherwise.
int dmlite_icreate ( dmlite_context context,
const dmlite_xstat f 
)

Creates a new file.

Parameters
contextThe DM context.
fOnly 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
contextThe DM context.
inodeThe file id.
Returns
0 on success, error code otherwise.
int dmlite_ideletereplica ( dmlite_context context,
const dmlite_replica replica 
)

Deletes a replica.

Parameters
contextThe DM context.
replicaThe 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
contextThe DM context.
inodeThe file id.
commentWhere to put the comment.
bufsizeThe 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
contextThe DM context.
ridThe replica id.
bufWhere 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
contextThe DM context.
inodeThe file id.
nreplicasThe number of replicas will be put here.
replicasIt 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
contextThe DM context.
inodeThe file id.
destThe destination id.
Returns
0 on success, error code otherwise.
dmlite_idir* dmlite_iopendir ( dmlite_context context,
ino_t  inode 
)

Opens a directory.

Parameters
contextThe DM context.
inodeThe 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 
)

Reads a directory.

Parameters
contextThe DM context.
dirThe 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
contextThe DM context.
dirThe 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
contextThe DM context.
inodeThe file id.
pathThe link will be put here.
bufsizeThe 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
contextThe DM context.
inodeThe file id.
nameThe 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
contextThe 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
contextThe DM context.
inodeThe file id.
csumtypeThe new checksum type.
csumvalueThe 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
contextThe DM context.
inodeThe file id.
commentThe 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
contextThe DM context.
inodeThe entry id.
guidThe 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
contextThe DM context.
inodeThe file id.
uidThe new UID.
gidThe new GID.
modeThe new mode.
nentriesThe number of acl entries.
aclThe 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
contextThe DM context.
inodeThe file id.
sizeThe 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
contextThe DM context.
inodeThe entry inode.
bufWhere 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
contextThe DM context.
inodeThe entry inode.
bufWhere 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
contextThe DM context.
parentThe parent id.
nameThe entry name.
bufWhere 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
contextThe DM context.
inodeThe file that will be a symlink.
linkThe 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
contextThe DM context.
inodeThe 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
contextThe DM context.
inodeThe entry id.
xattrThe 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
contextThe DM context.
inodeThe file id.
bufThe timestamps.
Returns
0 on success, error code otherwise.