summaryrefslogtreecommitdiffstats
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
parent1b42c864d64b0b9af06d251797fba70334d84f67 (diff)
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>
-rw-r--r--api/examples/glfsxmp.c36
-rw-r--r--api/src/glfs.c1
2 files changed, 32 insertions, 5 deletions
diff --git a/api/examples/glfsxmp.c b/api/examples/glfsxmp.c
index 1883b54bc92..9497128af91 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;
}
diff --git a/api/src/glfs.c b/api/src/glfs.c
index 017a55b1be8..01b3bc83674 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -25,6 +25,7 @@
- implement glfs_fini()
- modify syncop_fsync() to accept 'dataonly' flag
- 0-copy for readv/writev
+ - reconcile the open/creat mess
*/
#include <unistd.h>