diff options
Diffstat (limited to 'api/src/glfs.h')
| -rw-r--r-- | api/src/glfs.h | 221 |
1 files changed, 218 insertions, 3 deletions
diff --git a/api/src/glfs.h b/api/src/glfs.h index 14d41356a..18fda496e 100644 --- a/api/src/glfs.h +++ b/api/src/glfs.h @@ -39,6 +39,8 @@ #include <sys/uio.h> #include <unistd.h> #include <sys/cdefs.h> +#include <dirent.h> +#include <sys/statvfs.h> __BEGIN_DECLS @@ -134,9 +136,9 @@ int glfs_set_volfile (glfs_t *fs, const char *volfile); @transport: String specifying the transport used to connect to the management daemon. Specifying NULL will result in the usage - of the default (socket) transport type. Permitted values + of the default (tcp) transport type. Permitted values are those what you specify as transport-type in a volume - specification file (e.g "socket", "rdma", "unix".) + specification file (e.g "tcp", "rdma", "unix".) @host: String specifying the address of where to find the management daemon. Depending on the transport type this would either be @@ -174,7 +176,9 @@ int glfs_set_volfile_server (glfs_t *fs, const char *transport, @fs: The 'virtual mount' object to be configured with the logging parameters. @logfile: The logfile to be used for logging. Will be created if it does not - already exist (provided system permissions allow.) + already exist (provided system permissions allow). If NULL, a new + logfile will be created in default log directory associated with + the glusterfs installation. @loglevel: Numerical value specifying the degree of verbosity. Higher the value, more verbose the logging. @@ -216,6 +220,36 @@ int glfs_set_logging (glfs_t *fs, const char *logfile, int loglevel); int glfs_init (glfs_t *fs); +/* + SYNOPSIS + + glfs_fini: Cleanup and destroy the 'virtual mount' + + DESCRIPTION + + This function attempts to gracefully destroy glfs_t object. An attempt is + made to wait for all background processing to complete before returning. + + glfs_fini() must be called after all operations on glfs_t is finished. + + IMPORTANT + + IT IS NECESSARY TO CALL glfs_fini() ON ALL THE INITIALIZED glfs_t + OBJECTS BEFORE TERMINATING THE PROGRAM. THERE MAY BE CACHED AND + UNWRITTEN / INCOMPLETE OPERATIONS STILL IN PROGRESS EVEN THOUGH THE + API CALLS HAVE RETURNED. glfs_fini() WILL WAIT FOR BACKGROUND OPERATIONS + TO COMPLETE BEFORE RETURNING, THEREBY MAKING IT SAFE FOR THE PROGRAM TO + EXIT. + + PARAMETERS + + @fs: The 'virtual mount' object to be destroyed. + + RETURN VALUES + + 0 : Success. +*/ + int glfs_fini (glfs_t *fs); /* @@ -237,6 +271,32 @@ int glfs_fini (glfs_t *fs); struct glfs_fd; typedef struct glfs_fd glfs_fd_t; +/* + * PER THREAD IDENTITY MODIFIERS + * + * The following operations enable to set a per thread identity context + * for the glfs APIs to perform operations as. The calls here are kept as close + * to POSIX equivalents as possible. + * + * NOTES: + * + * - setgroups is a per thread setting, hence this is named as fsgroups to be + * close in naming to the fs(u/g)id APIs + * - Typical mode of operation is to set the IDs as required, with the + * supplementary groups being optionally set, make the glfs call and post the + * glfs operation set them back to eu/gid or uid/gid as appropriate to the + * caller + * - The groups once set, need to be unset by setting the size to 0 (in which + * case the list argument is a do not care) + * - Once a process for a thread of operation choses to set the IDs, all glfs + * calls made from that thread would default to the IDs set for the thread. + * As a result use these APIs with care and ensure that the set IDs are + * reverted to global process defaults as required. + * + */ +int glfs_setfsuid (uid_t fsuid); +int glfs_setfsgid (gid_t fsgid); +int glfs_setfsgroups (size_t size, const gid_t *list); /* SYNOPSIS @@ -299,6 +359,32 @@ int glfs_close (glfs_fd_t *fd); glfs_t *glfs_from_glfd (glfs_fd_t *fd); +int glfs_set_xlator_option (glfs_t *fs, const char *xlator, const char *key, + const char *value); + +/* + + glfs_io_cbk + + The following is the function type definition of the callback + function pointer which has to be provided by the caller to the + *_async() versions of the IO calls. + + The callback function is called on completion of the requested + IO, and the appropriate return value is returned in @ret. + + In case of an error in completing the IO, @ret will be -1 and + @errno will be set with the appropriate error. + + @ret will be same as the return value of the non _async() variant + of the particular call + + @data is the same context pointer provided by the caller at the + time of issuing the async IO call. This can be used by the + caller to differentiate different instances of the async requests + in a common callback function. +*/ + typedef void (*glfs_io_cbk) (glfs_fd_t *fd, ssize_t ret, void *data); // glfs_{read,write}[_async] @@ -353,6 +439,7 @@ int glfs_ftruncate_async (glfs_fd_t *fd, off_t length, glfs_io_cbk fn, void *data); int glfs_lstat (glfs_t *fs, const char *path, struct stat *buf); +int glfs_stat (glfs_t *fs, const char *path, struct stat *buf); int glfs_fstat (glfs_fd_t *fd, struct stat *buf); int glfs_fsync (glfs_fd_t *fd); @@ -361,6 +448,134 @@ int glfs_fsync_async (glfs_fd_t *fd, glfs_io_cbk fn, void *data); int glfs_fdatasync (glfs_fd_t *fd); int glfs_fdatasync_async (glfs_fd_t *fd, glfs_io_cbk fn, void *data); +int glfs_access (glfs_t *fs, const char *path, int mode); + +int glfs_symlink (glfs_t *fs, const char *oldpath, const char *newpath); + +int glfs_readlink (glfs_t *fs, const char *path, char *buf, size_t bufsiz); + +int glfs_mknod (glfs_t *fs, const char *path, mode_t mode, dev_t dev); + +int glfs_mkdir (glfs_t *fs, const char *path, mode_t mode); + +int glfs_unlink (glfs_t *fs, const char *path); + +int glfs_rmdir (glfs_t *fs, const char *path); + +int glfs_rename (glfs_t *fs, const char *oldpath, const char *newpath); + +int glfs_link (glfs_t *fs, const char *oldpath, const char *newpath); + +glfs_fd_t *glfs_opendir (glfs_t *fs, const char *path); + +/* + * @glfs_readdir_r and @glfs_readdirplus_r ARE thread safe AND re-entrant, + * but the interface has ambiguity about the size of @dirent to be allocated + * before calling the APIs. 512 byte buffer (for @dirent) is sufficient for + * all known systems which are tested againt glusterfs/gfapi, but may be + * insufficient in the future. + */ + +int glfs_readdir_r (glfs_fd_t *fd, struct dirent *dirent, + struct dirent **result); + +int glfs_readdirplus_r (glfs_fd_t *fd, struct stat *stat, struct dirent *dirent, + struct dirent **result); + +/* + * @glfs_readdir and @glfs_readdirplus are NEITHER thread safe NOR re-entrant + * when called on the same directory handle. However they ARE thread safe + * AND re-entrant when called on different directory handles (which may be + * referring to the same directory too.) + */ + +struct dirent *glfs_readdir (glfs_fd_t *fd); + +struct dirent *glfs_readdirplus (glfs_fd_t *fd, struct stat *stat); + +long glfs_telldir (glfs_fd_t *fd); + +void glfs_seekdir (glfs_fd_t *fd, long offset); + +int glfs_closedir (glfs_fd_t *fd); + +int glfs_statvfs (glfs_t *fs, const char *path, struct statvfs *buf); + +int glfs_chmod (glfs_t *fs, const char *path, mode_t mode); + +int glfs_fchmod (glfs_fd_t *fd, mode_t mode); + +int glfs_chown (glfs_t *fs, const char *path, uid_t uid, gid_t gid); + +int glfs_lchown (glfs_t *fs, const char *path, uid_t uid, gid_t gid); + +int glfs_fchown (glfs_fd_t *fd, uid_t uid, gid_t gid); + +int glfs_utimens (glfs_t *fs, const char *path, struct timespec times[2]); + +int glfs_lutimens (glfs_t *fs, const char *path, struct timespec times[2]); + +int glfs_futimens (glfs_fd_t *fd, struct timespec times[2]); + +ssize_t glfs_getxattr (glfs_t *fs, const char *path, const char *name, + void *value, size_t size); + +ssize_t glfs_lgetxattr (glfs_t *fs, const char *path, const char *name, + void *value, size_t size); + +ssize_t glfs_fgetxattr (glfs_fd_t *fd, const char *name, + void *value, size_t size); + +ssize_t glfs_listxattr (glfs_t *fs, const char *path, void *value, size_t size); + +ssize_t glfs_llistxattr (glfs_t *fs, const char *path, void *value, + size_t size); + +ssize_t glfs_flistxattr (glfs_fd_t *fd, void *value, size_t size); + +int glfs_setxattr (glfs_t *fs, const char *path, const char *name, + const void *value, size_t size, int flags); + +int glfs_lsetxattr (glfs_t *fs, const char *path, const char *name, + const void *value, size_t size, int flags); + +int glfs_fsetxattr (glfs_fd_t *fd, const char *name, + const void *value, size_t size, int flags); + +int glfs_removexattr (glfs_t *fs, const char *path, const char *name); + +int glfs_lremovexattr (glfs_t *fs, const char *path, const char *name); + +int glfs_fremovexattr (glfs_fd_t *fd, const char *name); + +int glfs_fallocate(glfs_fd_t *fd, int keep_size, off_t offset, size_t len); + +int glfs_discard(glfs_fd_t *fd, off_t offset, size_t len); + + +int glfs_discard_async (glfs_fd_t *fd, off_t length, size_t lent, + glfs_io_cbk fn, void *data); + +int glfs_zerofill(glfs_fd_t *fd, off_t offset, size_t len); + +int glfs_zerofill_async (glfs_fd_t *fd, off_t length, size_t len, + glfs_io_cbk fn, void *data); + +char *glfs_getcwd (glfs_t *fs, char *buf, size_t size); + +int glfs_chdir (glfs_t *fs, const char *path); + +int glfs_fchdir (glfs_fd_t *fd); + +char *glfs_realpath (glfs_t *fs, const char *path, char *resolved_path); + +/* + * @cmd and @flock are as specified in man fcntl(2). + */ +int glfs_posix_lock (glfs_fd_t *fd, int cmd, struct flock *flock); + +glfs_fd_t *glfs_dup (glfs_fd_t *fd); + __END_DECLS #endif /* !_GLFS_H */ |
