Skip to content

Instantly share code, notes, and snippets.

@enakai00
Last active December 29, 2015 14:59
Show Gist options
  • Save enakai00/7687176 to your computer and use it in GitHub Desktop.
Save enakai00/7687176 to your computer and use it in GitHub Desktop.
The simplest libgfapi example.
#include <glusterfs/api/glfs.h>
int main (int argc, char** argv) {
glfs_t *fs = NULL;
glfs_fd_t *fd = NULL;
int ret;
char *filename = "filename";
fs = glfs_new ("volume_name");
ret = glfs_set_volfile_server (fs, "tcp", "server_address", 24007);
ret = glfs_init (fs);
fd = glfs_creat (fs, filename, O_RDWR, 0644);
ret = glfs_write (fd, "hello gluster\n", 15, 0);
glfs_close (fd);
return 0;
}
/*
# rpm -qa | grep glusterfs-api
glusterfs-api-devel-3.4.1-3.el6.x86_64
glusterfs-api-3.4.1-3.el6.x86_64
# gcc hellogluster.c -lgfapi
*/
@maebashi
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment