-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to create xdr bindings for Glusterfs #6
Comments
Cool! How is it failing for you? Does it print an error or does it just hang or something? How are you invoking it? |
Looks like its upset by Hm, it also doesn't like |
A workaround is to remove " Also it would generate slightly better code with a |
Cool! Thanks for the quick response. I'll make those changes and let you
|
Ok I messed around with the file and used your suggestions to create this: https://gist.github.com/cholcombe973/96ced58add90320b740123b5c066740d That seems to have done the trick! It generated this code: https://gist.github.com/cholcombe973/4318ffa2aae17b8c5dde18a7f2b6a1d5. I think I might cat all these files together and then throw them up on crates.io as a Gluster xdr raw bindings crate. |
@jsgf Here's the everything.x https://gist.github.com/cholcombe973/d0785e1bd243c226646d42202b1804c4 The parser seems to not like the unsigned long struct members. |
Interesting. From the xdr rfc it doesn't look like long is a valid keyword. |
RFC4506 doesn't define "long" as a basic type in .x files; |
Also |
Yeah I'm going to open a bug with redhat and see what they say about this. This is probably the reason why no other language bindings for gluster exist. :-/ |
Also RFC4506 doesn't include the RPC definition syntax, so xdrgen doesn't either. I'm not sure if "struct foo" syntax is valid or not, or rather, if I should make it valid. The RFC does say that |
Another hiccup: So the complete set of changes to get something working with xdrgen:
I'm considering adding support for |
Interesting. I also had to typedef a bunch of things that gluster forgot to do for some reason. I deleted all the struct foo's in there and that seems to have gotten it to generate. On the cargo build side it looks like the major issue is |
A Vec of which type? |
oh sorry. It was a |
It shouldn't be relying on pack/unpack for |
Yeah. It looks like this is causing the issue: https://gist.github.com/cholcombe973/d0785e1bd243c226646d42202b1804c4#file-everything-x-L1654 |
I see. Hm. |
@jsgf Do you think it would be worthwhile to generate the Rust code with camelcase? I'm getting a ton of warnings. I can just turn them off but I was wondering |
Well, that opens the whole question of what transformations to apply to names from .x -> Rust. At the very least it should probably do something to avoid rust keywords in generated code. But what past that? How to make sure it doesn't create conflicting symbols? For now, I just add an |
I guess it depends on how much global knowledge the generator has. If it On Wed, May 18, 2016, 2:13 PM Jeremy Fitzhardinge [email protected]
|
BTW, I just pushed a change to fix the |
I also just pushed support for parsing rpcgen extensions: "unsigned" -> "unsigned int" and "struct foo" -> "foo" as a type name. I didn't support "unsigned long" because it's ambiguous ("long" isn't a keyword, so in principle it could be a field name), and also unclear what it means (I'd assumed it was a 64-bit value, but I think its actually 32 bits). |
Cool. I'll try and run xdrgen against some of the gluster files and see what it says :) |
Looks much better! I posted the code here: https://github.com/cholcombe973/gluster-xdr |
Now that I think about it. I think I have some tcp packet captures of gluster rpc that I can test this generated code against to see if it matches |
Yeah, that would be great. Interop testing is a big hole in the test suite. |
@jsgf have you considered writing an NFS server with this code? It should be possible and it would gain rust safety :) |
There's a lot more to NFS than XDR... |
Right but the foundation is there :-). It would be a huge undertaking. I On Sep 15, 2016 8:26 PM, "Jeremy Fitzhardinge" [email protected]
|
So I took a look at generating the xdr bindings again. It's really close! |
Check out the version in master - I added remapping for reserved words (adds a |
Ok I pointed it at master. It looks like it's really close:
|
Yeah, I got the same. I think you need to manually inline glusterfs-fops.x to get its definitions (xdrgen can't do anything useful with |
Yeah, there's several problems in the Gluster .x files:
The last one I can add support to xdr-codec for, though I'm a bit concerned it would result in people accidentally using it when they didn't mean to. Maybe I should put it behind a feature flag. |
Yeah it wouldn't hurt to have it behind a feature flag. I agree their .x
files are a little whacky. I suspect their Makefile either patches them up
or there's an import somewhere that I'm missing.
…On Wed, Mar 1, 2017 at 1:06 PM, Jeremy Fitzhardinge < ***@***.***> wrote:
Yeah, there's several problems in the Gluster .x files:
- using types like quad_t, u_quad_t, which need type aliases in Rust
- constants like LEASE_ID_SIZE which aren't defined in the .x file
- using char foo[SIZE] instead of opaque foo[SIZE]
The last one I can add support to xdr-codec for, though I'm a bit
concerned it would result in people accidentally using it when they didn't
mean to. Maybe I should put it behind a feature flag.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#6 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AC6qE-GbXQ7_kAuTWS8AMD20XqW_yeM_ks5rhd3WgaJpZM4Ifxta>
.
|
I think they work OK in C. It just defines things at the C level knowing that the generated code can access them and understand the types. |
OK, I just published xdrgen and xdr-codec 0.4.0. xdr-codec has a |
Sweet! Much appreciated. |
Looks like most of the errors are just rust complaining about Debug and Eq not being implemented for i8: https://gist.github.com/cholcombe973/c4b85e45884ea4bc795b02a7885bbd1b. Rust stops at 32 for Debug: impl Debug for [T; 32] where T: Debug |
So I enabled bytecodec and that got me further but I'm still running into a bunch of compile errors. I can get it to compile correctly by pulling in the generated code and editing it but I'd love to avoid doing that :). Here's a gist: https://gist.github.com/cholcombe973/d7a83647ae51cdcc1fcb2d390c27ee4c |
That's a rust limitation (you can only derive traits for arrays up to 32 elements) that I guess xdrgen could work around. Could you file a separate issue for it? |
Filed #18. |
I'm going to close this for now - file new issues if they come up. |
I really love this project! This is the first rust xdr based project that has been able to parse any gluster .x file and successfully produce an output file. I tried it on a second file and it EOF failed. Maybe you could take a quick peek and see what you think. The file is: https://github.com/gluster/glusterfs/blob/master/rpc/xdr/src/rpc-common-xdr.x I think the parser is expecting more to the file.
The text was updated successfully, but these errors were encountered: