darfink / region-rs

A cross-platform virtual memory API written in Rust
https://darfink.github.io/region-rs/
MIT License
119 stars 23 forks source link

feat: add support for illumos #12

Closed jclulow closed 4 years ago

jclulow commented 4 years ago

This commit adds support for the illumos operating system. We have a proc file system that is somewhat similar to Linux, except that it generally contains binary structures rather than human readable text.

The most relevant illumos manual page is proc(4). You can see the prmap_t and associated constants in the sys/procfs.h header file.

I ran the tests, which all pass:

$ pfexec cargo test
    Finished test [unoptimized + debuginfo] target(s) in 0.01s
     Running target/debug/deps/region-6c57251c0f124716

running 20 tests
test lock::tests::unlock_mapped_pages_succeeds ... ok
test os::unix::tests::protection_flags_are_mapped_to_native ... ok
test lock::tests::lock_mapped_pages_succeeds ... ok
test page::tests::page_rounding_works ... ok
test page::tests::page_size_is_reasonable ... ok
test protect::tests::protect_can_alter_text_segments ... ok
test protect::tests::protect_null_fails ... ok
test query::tests::query_range_has_inclusive_lower_and_exclusive_upper_bound ... ok
test query::tests::query_range_returns_both_regions_for_straddling_range ... ok
test query::tests::query_returns_correct_region_for_text_segment ... ok
test query::tests::query_returns_one_region_for_identical_adjacent_pages ... ok
test query::tests::query_returns_unmapped_for_oob_address ... ok
test tests::round_to_page_boundaries_works ... ok
test protect::tests::protect_with_handle_resets_protection ... ok
test query::tests::query_range_does_not_return_unmapped_regions ... ok
test query::tests::query_range_can_iterate_over_entire_process ... ok
test protect::tests::protect_has_inclusive_lower_and_exclusive_upper_bound ... ok
test query::tests::query_is_not_off_by_one ... ok
test protect::tests::protect_updates_both_pages_for_straddling_range ... ok
test protect::tests::protect_with_handle_only_resets_protection_of_affected_pages ... ok

test result: ok. 20 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

   Doc-tests region

running 11 tests
test src/lib.rs - (line 33) ... ok
test src/protect.rs - protect::protect_with_handle (line 66) ... ignored
test /ws/cache/rustup/registry/src/github.com-1ecc6299db9ec823/bitflags-1.2.1/src/lib.rs - protect::Protection (line 413) ... ok
test src/lib.rs - (line 42) ... ok
test src/page.rs - page::size (line 13) ... ok
test src/page.rs - page::floor (line 32) ... ok
test src/lock.rs - lock::lock (line 19) ... ok
test src/protect.rs - protect::protect (line 27) ... ok
test src/page.rs - page::ceil (line 47) ... ok
test src/query.rs - query::query (line 22) ... ok
test src/query.rs - query::query_range (line 66) ... ok

test result: ok. 10 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out

I ran cargo fmt and used the style it suggested -- hopefully that is OK! Please let me know if you want any changes.

darfink commented 4 years ago

This is great, thanks a ton for your pull request :)

My only input would be to remove the leftover println!.

Do you happen to know whether there are any CI services that support illumos?

jclulow commented 4 years ago

Hey, sorry, got busy after I pushed this. I'll definitely clean up the println this week -- totally missed that!

With respect to CI services, it's something we're working on definitely but not something I have a good answer for right at this moment.

jclulow commented 4 years ago

I have removed the errant println!() and confirmed that the tests still pass on an illumos machine! Thanks again.

darfink commented 4 years ago

Thanks a ton!