<div dir="ltr"><div><div><div><div>Hi everyone,<br></div><br></div>I try to write a new xlator by using glupy xlator<br></div>I try to translate gf_dirent_t structure to python class<br>it looks like<br><br>------------------------------------------------------------<br>
c code structure:<br>struct _gf_dirent_t {<br>    union {<br>        struct list_head             list;<br>        struct {<br>            struct _gf_dirent_t *next;<br>            struct _gf_dirent_t *prev;<br>        };<br>
    };<br>    uint64_t                             d_ino;<br>    uint64_t                             d_off;<br>    uint32_t                             d_len;<br>    uint32_t                             d_type;<br>        struct iatt                          d_stat;<br>
        dict_t                              *dict;<br>        inode_t                             *inode;<br>    char                                 d_name[];<br>};<br><br>-------------------------------------------------------------------<br>
</div>python code class:<br>class gf_dirent_t (Structure):<br>    pass<br><br>class dirent_struct (Structure):<br>    _fields_ = [<br>            (&quot;next&quot;, POINTER(gf_dirent_t)),<br>            (&quot;prev&quot;, POINTER(gf_dirent_t))<br>
                ]<br><br>class dirent_union (Union):<br>    _fields_ = [<br>        (&quot;list&quot;, list_head),<br>        (&quot;dirents&quot;, dirent_struct)<br>        ]<br><br>gf_dirent_t._fields_ = [<br>    (&quot;dirent_list&quot;, dirent_union),<br>
    (&quot;d_ino&quot;,c_uint64),<br>    (&quot;d_off&quot;,c_uint64),<br>    (&quot;d_len&quot;,c_uint32),<br>    (&quot;d_type&quot;, c_uint32),<br>    (&quot;d_stat&quot;, iatt_t),<br>    (&quot;dict&quot;, POINTER(dict_t)),<br>
    (&quot;inode&quot;, POINTER(inode_t)),<br>    (&quot;d_name&quot;, c_char_p)<br>    ]<br>-----------------------------------------------------------------------<br><div>then I print the d_len variable of gf_dirent_t class (in python)<br>
</div><div>but it is different with the d_len variable of _gf_dirent_t (in c code)<br></div><div>the value in python is 3386792520<br></div><div>the value in c is 1<br></div><div><br></div><div>anyone can tell me the python class I write is correct or not?<br>
</div><div>what&#39;s the problem?<br></div><div>thanks your help!<br>thanks a lot<br></div><div><br><br><br><br></div></div>