#include #include #include #include #include #include #include int main (int argc, char *argv[]) { /* ==== init ==== */ glusterfs_init_ctx_t ctx; memset (&ctx, 0, sizeof (ctx)); ctx.specfile = "/usr/local/etc/glusterfs/glusterfs.vol"; ctx.logfile = "/tmp/glfs_log"; ctx.loglevel = "debug"; ctx.lookup_timeout = ctx.stat_timeout = 600; libglusterfs_handle_t client_context; errno = 0; client_context = glusterfs_init(&ctx); printf("init errno %d\n", errno); /* ==== open ==== */ int ret = 0; unsigned long fd = 0; char *path = "/"; int flags = O_RDONLY; mode_t mode = 0; errno = 0; fd = glusterfs_open(client_context, path, flags, mode); printf("fd %lu\n", fd); printf("open errno %d\n", errno); struct stat statbuf; memset (&statbuf, 0, sizeof (statbuf)); ret = glusterfs_fstat(fd, &statbuf); printf("fstat ret %d\n", ret); printf("fstat errno %d\n", errno); printf("uid %u\n", statbuf.st_uid); printf("inod %lu\n", statbuf.st_ino); printf("size %ld\n", statbuf.st_size); errno = 0; ret = glusterfs_close(fd); printf("close ret %d\n", ret); printf("close errno %d\n", errno); /* ===== end ===== */ glusterfs_fini(client_context); client_context = 0; exit(EXIT_SUCCESS); }