[Gluster-devel] Writing new Xlator and manipulate data

David Spisla david.spisla at iternity.com
Wed Mar 1 16:00:21 UTC 2017


Hello Gluster-Devels,

actually I am writing my first xlator according to this tutorial:
https://github.com/gluster/glusterfs/blob/master/doc/developer-guide/translator-development.md

So I put the rot-13 Xlator and wrote my own stuff. My idea is to change the iovec-content and put a new content in it.
My readv_cbk look like this:

int32_t
stub_iovec (xlator_t *this, struct iovec *vector, struct iobref *iobref, struct iatt *stbuf, int count)
{
               int i;
               for (i = 0; i < count; i++) {
               struct iobuf *iobuf = NULL;
               iobuf = iobuf_get(this->ctx->iobuf_pool);
                iobuf_unref(iobref->iobrefs[i]);
                iobref = iobref_new();
                iobref_add(iobref, iobuf);
                char temp[] = "I am the manipulated content!!!\n";
                char *buf0 = "I am the manipulated content!!!\n";
                vector[i].iov_base = buf0;
                vector[i].iov_len = sizeof(temp);
                stbuf->ia_size = sizeof(temp);

                return stbuf->ia_size;
               }
}

int32_t
stub_readv_cbk (call_frame_t *frame,
                 void *cookie,
                 xlator_t *this,
                 int32_t op_ret,
                 int32_t op_errno,
                 struct iovec *vector,
                 int32_t count,
                              struct iatt *stbuf,
                 struct iobref *iobref, dict_t *xdata)
{
        gf_log (this->name, GF_LOG_DEBUG, "Führe stub_readv_cbk aus!!!");

        int32_t new_op_ret = stub_iovec(this, vector, iobref, stbuf, count);

               STACK_UNWIND_STRICT (readv, frame, new_op_ret, op_errno, vector, count,
                             stbuf, iobref, xdata);
               return 0;
}

Ist not really working at all. If I have an original content like a simple "orig" in a test.txt and change it to "manipulate",
the command "cat /mnt/gluster/test.txt" show me an "mani". The size if the content did not changed.
Any idea about hat?

Regards
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gluster.org/pipermail/gluster-devel/attachments/20170301/479d3448/attachment-0001.html>


More information about the Gluster-devel mailing list