Skip to content
This repository was archived by the owner on Mar 7, 2021. It is now read-only.

Commit ddab825

Browse files
authored
Merge branch 'master' into master
2 parents c504668 + e3e4dc6 commit ddab825

File tree

7 files changed

+27
-20
lines changed

7 files changed

+27
-20
lines changed

.travis.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
sudo: required
1+
matrix:
2+
include:
3+
- dist: trusty
4+
- dist: xenial
25

36
language: rust
47
rust:
@@ -21,8 +24,7 @@ install:
2124
else
2225
cargo install --force cargo-xbuild
2326
fi
24-
- rustup component add rust-src
25-
- rustup component add rustfmt
27+
- rustup component add rust-src rustfmt
2628

2729
script:
2830
- ./tests/run_tests.py

build.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ const INCLUDED_VARS: &[&str] = &[
3434
"KERN_INFO",
3535
"VERIFY_WRITE",
3636
];
37-
/// These structs must be opaque because they're both packed
38-
/// and aligned, which is not yet supported by rust. See
39-
/// https://github.com/rust-lang/rust/issues/59154 and
40-
/// https://github.com/rust-lang/rust-bindgen/issues/1538
4137
const OPAQUE_TYPES: &[&str] = &[
42-
"^xregs_state$",
43-
"^desc_struct$",
38+
// This needs to be opaque because it's both packed and aligned, which rustc
39+
// doesn't support yet. See https://github.com/rust-lang/rust/issues/59154
40+
// and https://github.com/rust-lang/rust-bindgen/issues/1538
41+
"desc_struct",
42+
"xregs_state",
4443
];
4544

4645
fn main() {
@@ -58,7 +57,8 @@ fn main() {
5857
.output()
5958
.unwrap()
6059
.stdout,
61-
).unwrap();
60+
)
61+
.unwrap();
6262

6363
builder = builder.clang_arg("--target=x86_64-linux-kernel-module");
6464
for arg in shlex::split(&output).unwrap() {

example-sysctl/Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
obj-m := examplesysctl.o
22
examplesysctl-objs := target/x86_64-linux-kernel-module/debug/libexample_sysctl.a
33
EXTRA_LDFLAGS += --entry=init_module
4+
KDIR ?= /lib/modules/$(shell uname -r)/build
45

56
all:
6-
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(CURDIR)
7+
$(MAKE) -C $(KDIR) M=$(CURDIR)
78

89
clean:
9-
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(CURDIR) clean
10+
$(MAKE) -C $(KDIR) M=$(CURDIR) clean

hello-world/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ ifneq ($(KERNELRELEASE),)
22
obj-m := helloworld.o
33
helloworld-objs := libhello_world.o
44
EXTRA_LDFLAGS += --entry=init_module
5+
KDIR ?= /lib/modules/$(shell uname -r)/build
56

67
$(M)/libhello_world.o: target/x86_64-linux-kernel-module/debug/libhello_world.a
78
$(LD) -r -o $@ --whole-archive $^
89
else
910
all:
10-
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(CURDIR)
11+
$(MAKE) -C $(KDIR) M=$(CURDIR)
1112

1213
clean:
13-
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(CURDIR) clean
14+
$(MAKE) -C $(KDIR) M=$(CURDIR) clean
1415
endif
15-

src/sysctl.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ impl SysctlStorage for atomic::AtomicBool {
5656

5757
pub struct Sysctl<T: SysctlStorage> {
5858
inner: Box<T>,
59+
// Responsible for keeping the ctl_table alive.
5960
_table: Box<[bindings::ctl_table]>,
6061
header: *mut bindings::ctl_table_header,
6162
}
@@ -127,7 +128,8 @@ impl<T: SysctlStorage> Sysctl<T> {
127128
extra2: ptr::null_mut(),
128129
},
129130
unsafe { mem::zeroed() },
130-
].into_boxed_slice();
131+
]
132+
.into_boxed_slice();
131133

132134
let result =
133135
unsafe { bindings::register_sysctl(path.as_ptr() as *const i8, table.as_mut_ptr()) };

static-filesystem/Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
obj-m := staticfilesystem.o
22
staticfilesystem-objs := target/x86_64-linux-kernel-module/debug/libstatic_filesystem.a
33
EXTRA_LDFLAGS += --entry=init_module
4+
KDIR ?= /lib/modules/$(shell uname -r)/build
45

56
all:
6-
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(CURDIR)
7+
$(MAKE) -C $(KDIR) M=$(CURDIR)
78

89
clean:
9-
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(CURDIR) clean
10+
$(MAKE) -C $(KDIR) M=$(CURDIR) clean

tests/Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ ifneq ($(KERNELRELEASE),)
22
obj-m := testmodule.o
33
testmodule-objs := $(TEST_LIBRARY_OBJECT)
44
EXTRA_LDFLAGS += --entry=init_module
5+
KDIR ?= /lib/modules/$(shell uname -r)/build
56

67
$(M)/$(TEST_LIBRARY_OBJECT): target/x86_64-linux-kernel-module/debug/$(TEST_LIBRARY_ARCHIVE)
78
$(LD) -r -o $@ --whole-archive $^
89
else
910
all:
10-
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(CURDIR)
11+
$(MAKE) -C $(KDIR) M=$(CURDIR)
1112

1213
clean:
13-
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(CURDIR) clean
14+
$(MAKE) -C $(KDIR) M=$(CURDIR) clean
1415
endif

0 commit comments

Comments
 (0)