fishinabarrel / linux-kernel-module-rust

Framework for writing Linux kernel modules in safe Rust
GNU General Public License v2.0
1.34k stars 119 forks source link

build error: setfl binding missing #167

Closed aurabindo closed 5 years ago

aurabindo commented 5 years ago
error[E0560]: struct `bindings::bindings::file_operations` has no field named `setfl`
   --> /run/media/aj/Buffer/git-clones/linux-kernel-module-rust/src/chrdev.rs:228:13
    |
228 |             setfl: None,
    |             ^^^^^ `bindings::bindings::file_operations` does not have this field
    |
    = note: available fields are: `owner`, `llseek`, `read`, `write`, `read_iter` ... and 27 others

error: aborting due to previous error
alex commented 5 years ago

What kernel version are you on?

geofft commented 5 years ago

Ugh I think setfl might be a Debian-specific patch?? I can't find any mention of it in the upstream kernel, on my most convenient Debian box I see

#ifndef __GENKSYMS__
        /* bwh: For aufs only */
        int (*setfl)(struct file *, unsigned long);
#endif

and bwh is the Debian kernel maintainer, and aufs is out-of-tree.

geofft commented 5 years ago

Thanks for the report @aurabindo - we'll figure out a way to conditionally compile this.

aurabindo commented 5 years ago

You're welcome! I'm on 4.19.32, archlinux.

aurabindo commented 5 years ago

Would a lame check like https://paste.ubuntu.com/p/tFC7JsXxjt/ do the job ? I mean, is it okay to assume we need debian specific additions only when building on a debian machine ? Does it work on debian without setfl present at all ?

alex commented 5 years ago

We need to know about the kernel we're compiling for, not the one we're running on, so no this isn't sufficient.

On Mon, Sep 2, 2019 at 11:19 AM Aurabindo J notifications@github.com wrote:

Would a lame check like https://paste.ubuntu.com/p/tFC7JsXxjt/ do the job ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fishinabarrel/linux-kernel-module-rust/issues/167?email_source=notifications&email_token=AAAAGBAKDN3JU4VIO67IOXTQHUVINA5CNFSM4IS2JENKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5WCX3Y#issuecomment-527182831, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAAGBBYQKPVP6CFUFAWJOLQHUVINANCNFSM4IS2JENA .

-- All that is necessary for evil to succeed is for good people to do nothing.

alex commented 5 years ago

Is there a define or a config or anything like that for this?

I'm hitting this trying to do development on #139, and I'm very mad at computer :-)

geofft commented 5 years ago

@aurabindo, can you see if the latest commit on master works?

(Note that in the meantime we've switched from cargo xbuild to cargo build - take a look at the current README, and note you might need to rustup update nightly or something.)

aurabindo commented 5 years ago

@geofft My nightly update is failing, and I do not have -Z flag build-std. Could you tell me your specific nightly version ?

geofft commented 5 years ago

That flag was added a couple days ago, sorry :) Try rustup update nightly

aurabindo commented 5 years ago

rustup update nightly is failing for me. I explicitly asked cargo compile with latest nightly. Even then its failing.

diff --git a/hello-world/Kbuild b/hello-world/Kbuild
index d2114c4..78013af 100644
--- a/hello-world/Kbuild
+++ b/hello-world/Kbuild
@@ -4,7 +4,7 @@ helloworld-objs := hello_world.rust.o
 CARGO ?= cargo

 $(src)/target/x86_64-linux-kernel/debug/libhello_world.a: $(src)/Cargo.toml $(wildcard $(src)/src/*.rs)
-       cd $(src); env -u MAKE -u MAKEFLAGS $(CARGO) build -Z build-std=core,alloc --target=x86_64-linux-kernel
+       cd $(src); env -u MAKE -u MAKEFLAGS $(CARGO) +nightly-2019-09-16 build -Z build-std=core,alloc --target=x86_64-linux-kernel

 %.rust.o: target/x86_64-linux-kernel/debug/lib%.a
        $(LD) -r -o $@ --whole-archive $<
alex commented 5 years ago

2019-09-11 nightly should work

On Mon, Sep 16, 2019, 9:37 AM Aurabindo J notifications@github.com wrote:

rustup update nightly is failing for me. I explicitly asked cargo compile with latest nightly. Even then its failing.

diff --git a/hello-world/Kbuild b/hello-world/Kbuild index d2114c4..78013af 100644 --- a/hello-world/Kbuild +++ b/hello-world/Kbuild @@ -4,7 +4,7 @@ helloworld-objs := hello_world.rust.o CARGO ?= cargo

$(src)/target/x86_64-linux-kernel/debug/libhello_world.a: $(src)/Cargo.toml $(wildcard $(src)/src/*.rs)

  • cd $(src); env -u MAKE -u MAKEFLAGS $(CARGO) build -Z build-std=core,alloc --target=x86_64-linux-kernel
  • cd $(src); env -u MAKE -u MAKEFLAGS $(CARGO) +nightly-2019-09-16 build -Z build-std=core,alloc --target=x86_64-linux-kernel

    %.rust.o: target/x86_64-linux-kernel/debug/lib%.a $(LD) -r -o $@ --whole-archive $<

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fishinabarrel/linux-kernel-module-rust/issues/167?email_source=notifications&email_token=AAAAGBGA3T5274YJOHV2N3TQJ6D2ZA5CNFSM4IS2JENKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6ZFD6A#issuecomment-531780088, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAAGBH4PUQ6JBA5K546Y23QJ6D2ZANCNFSM4IS2JENA .