<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> ("next", POINTER(gf_dirent_t)),<br> ("prev", POINTER(gf_dirent_t))<br>
]<br><br>class dirent_union (Union):<br> _fields_ = [<br> ("list", list_head),<br> ("dirents", dirent_struct)<br> ]<br><br>gf_dirent_t._fields_ = [<br> ("dirent_list", dirent_union),<br>
("d_ino",c_uint64),<br> ("d_off",c_uint64),<br> ("d_len",c_uint32),<br> ("d_type", c_uint32),<br> ("d_stat", iatt_t),<br> ("dict", POINTER(dict_t)),<br>
("inode", POINTER(inode_t)),<br> ("d_name", 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's the problem?<br></div><div>thanks your help!<br>thanks a lot<br></div><div><br><br><br><br></div></div>