[Gluster-devel] Question on dht_filter_loc_subvol_key() function (in dht-helper.c)

Nithya Balachandran nbalacha at redhat.com
Mon Oct 21 09:07:16 UTC 2019


loc->name will be something like "file-1 at vol1-dht:vol1-client-0"
key will be something like "@vol1-dht:vol1-client-0"
name_len will be strlen of file-1   (strlen("file-1 at vol1-dht:vol1-client-0")
- strlen(@vol1-dht:vol1-client-0))

We are therefore writing the filename part of the loc->name into new_name
because that is the actual filename that we want created. The rest of the
loc->name holds the key value which refers to the dht subvol on which we
want the file created.

Hope this helps.

Regards,
Nithya

On Fri, 4 Oct 2019 at 13:23, Yaniv Kaul <ykaul at redhat.com> wrote:

> I'm reading the function, and unsure what's going on there, perhaps I'm
> missing something:
> name_len = strlen(loc->name) - keylen;
> new_name = GF_MALLOC(name_len + 1, gf_common_mt_char);
> snprintf(new_name, name_len + 1, "%s", loc->name);
>
> How exactly is there enough space to snprintf loc->name into new_name?
> Y.
>
> _______________________________________________
>
> Community Meeting Calendar:
>
> APAC Schedule -
> Every 2nd and 4th Tuesday at 11:30 AM IST
> Bridge: https://bluejeans.com/118564314
>
> NA/EMEA Schedule -
> Every 1st and 3rd Tuesday at 01:00 PM EDT
> Bridge: https://bluejeans.com/118564314
>
> Gluster-devel mailing list
> Gluster-devel at gluster.org
> https://lists.gluster.org/mailman/listinfo/gluster-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gluster.org/pipermail/gluster-devel/attachments/20191021/cbff8bc6/attachment.html>


More information about the Gluster-devel mailing list