summaryrefslogtreecommitdiffstats
path: root/api/examples
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2012-07-25 22:39:13 -0700
committerAnand Avati <avati@redhat.com>2012-08-02 13:25:02 -0700
commitc8ed0096d53de3e39feee5b857b6b657118bc0a1 (patch)
treefac1ad308decec3e1f86a10ca7e9389b1f421afb /api/examples
parent1b42c864d64b0b9af06d251797fba70334d84f67 (diff)
downloadglusterfs-c8ed0096d53de3e39feee5b857b6b657118bc0a1.tar.gz
glusterfs-c8ed0096d53de3e39feee5b857b6b657118bc0a1.tar.xz
glusterfs-c8ed0096d53de3e39feee5b857b6b657118bc0a1.zip
glfsxmp extension
Change-Id: I3859621637025e464bc83d748bae7dff9808643f BUG: 839950 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.com/3735 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'api/examples')
-rw-r--r--api/examples/glfsxmp.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/api/examples/glfsxmp.c b/api/examples/glfsxmp.c
index 1883b54bc9..9497128af9 100644
--- a/api/examples/glfsxmp.c
+++ b/api/examples/glfsxmp.c
@@ -8,22 +8,23 @@ int
main (int argc, char *argv[])
{
glfs_t *fs = NULL;
+ glfs_t *fs2 = NULL;
int ret = 0;
glfs_fd_t *fd = NULL;
+ glfs_fd_t *fd2 = NULL;
struct stat sb = {0, };
char readbuf[32];
char writebuf[32];
- char *volname = "iops";
char *filename = "/filename2";
- fs = glfs_new (volname);
+ fs = glfs_new ("iops");
if (!fs) {
fprintf (stderr, "glfs_new: returned NULL\n");
return 1;
}
-// ret = glfs_set_volfile (fs, "/tmp/filename.vol");
+// ret = glfs_set_volfile (fs, "/tmp/posix.vol");
ret = glfs_set_volfile_server (fs, "socket", "localhost", 24007);
@@ -35,6 +36,24 @@ main (int argc, char *argv[])
fprintf (stderr, "glfs_init: returned %d\n", ret);
+ sleep (2);
+
+ fs2 = glfs_new ("iops");
+ if (!fs2) {
+ fprintf (stderr, "glfs_new: returned NULL\n");
+ return 1;
+ }
+
+
+// ret = glfs_set_volfile (fs2, "/tmp/posix.vol");
+
+ ret = glfs_set_volfile_server (fs2, "socket", "localhost", 24007);
+
+ ret = glfs_set_logging (fs2, "/dev/stderr", 7);
+
+ ret = glfs_init (fs2);
+
+ fprintf (stderr, "glfs_init: returned %d\n", ret);
ret = glfs_lstat (fs, filename, &sb);
fprintf (stderr, "%s: (%d) %s\n", filename, ret, strerror (errno));
@@ -42,16 +61,23 @@ main (int argc, char *argv[])
fd = glfs_creat (fs, filename, O_RDWR, 0644);
fprintf (stderr, "%s: (%p) %s\n", filename, fd, strerror (errno));
+ fd2 = glfs_open (fs2, filename, O_RDWR);
+ fprintf (stderr, "%s: (%p) %s\n", filename, fd, strerror (errno));
+
sprintf (writebuf, "hi there\n");
ret = glfs_write (fd, writebuf, 32, 0);
- glfs_lseek (fd, 0, SEEK_SET);
+ glfs_lseek (fd2, 0, SEEK_SET);
- ret = glfs_read (fd, readbuf, 32, 0);
+ ret = glfs_read (fd2, readbuf, 32, 0);
printf ("read %d, %s", ret, readbuf);
glfs_close (fd);
+ glfs_close (fd2);
+
+ glfs_fini (fs);
+ glfs_fini (fs2);
return ret;
}