Skip to content
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

Rename the public ptrace_* functions. #692

Merged
merged 43 commits into from
Jul 25, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b4f1749
Rename the public ptrace_* functions.
marmistrz Jul 20, 2017
3192df4
Fix tests
marmistrz Jul 20, 2017
d5c4d0f
Tidy up imports in test_ptrace.rs
marmistrz Jul 20, 2017
18b2bc1
Get rid of the bulk imports
marmistrz Jul 21, 2017
8928a7d
Remove old workaround
Susurrus Jul 11, 2017
1b9a779
Re-add bad variant of ioctl!
Susurrus Jul 11, 2017
a5b01c0
Add a "bad none" variant to the ioctl macro
Susurrus Jul 11, 2017
2fe5c2b
Hide internal macros/types within ioctl
Susurrus Jul 11, 2017
233a678
Remove unnecessary path aliasing
Susurrus Jul 11, 2017
55a7d4b
Revise ioctl module documentation
Susurrus Jul 11, 2017
caaffb8
Remove ioc_* functions
Susurrus Jul 11, 2017
82e0139
Use the proper ioctl number type depending on target
Susurrus Jul 11, 2017
e4a1851
Remove c_int and c_void from root
Susurrus Jul 12, 2017
88dc19b
Remove unnecessary constants
Susurrus Jul 12, 2017
7b07847
Unify argument names to generated ioctl functions
Susurrus Jul 13, 2017
3cf4cc6
Split ioctl!(write ...) into write_ptr and write_int
Susurrus Jul 18, 2017
571386b
Add 'bad' prefixes for read, write_*, and readwrite ioctls
Susurrus Jul 13, 2017
d63c616
Refactor ioctl! for buffers
Susurrus Jul 13, 2017
93b2929
Update changelog
Susurrus Jul 17, 2017
085f47c
Fix thread safety issues in pty and termios tests
asomers Jul 20, 2017
1c9e0ca
fix some tests for Android
ndusart Jul 20, 2017
2a5b86d
Remove workaround for `pub extern crate`
jonas-schievink Jul 20, 2017
b6ad298
Remove `homepage` from Cargo.toml
jonas-schievink Jul 20, 2017
845453b
Add tests of actual ioctl usage
Susurrus Jul 20, 2017
903a52f
Add WaitStatus::PtraceSyscall for use with PTRACE_O_TRACESYSGOOD
geofft Mar 28, 2017
2288202
Document WaitStatus and its variants
geofft Jun 20, 2017
907bb98
use std::env::temp_dir() to retrieve the temp directory in test_mkstemp
ndusart Jul 20, 2017
a162ea2
Allow doc attributes in ioctl macro
roblabla Jul 8, 2017
745a4ab
Document invariants of fork and fix tests
jonas-schievink Jul 20, 2017
4cefd53
Remove unneeded local
jonas-schievink Jul 22, 2017
536787e
Replace remaining process::exit with libc::_exit
jonas-schievink Jul 22, 2017
283fb1c
Add CHANGELOG entry for PR #661
asomers Jul 24, 2017
f3167db
Release 0.9.0
asomers Jul 24, 2017
021e851
Bump version to 0.10.0-pre
asomers Jul 24, 2017
8beaea2
Move Tier 3s to Tier 2
Susurrus Jul 9, 2017
46191fd
Disable tests on s390x
Susurrus Jul 9, 2017
a717003
Disable failing tests on mips64
Susurrus Jul 9, 2017
ce60aa5
Disable testing because of musl #include issues
Susurrus Jul 9, 2017
1844378
Add a changelog entry
marmistrz Jul 25, 2017
6583fd1
Merge branch 'master' into ptrace-rename
marmistrz Jul 25, 2017
9cf8248
Fix the tests compiling
marmistrz Jul 25, 2017
6ce39a6
Merge branch 'ptrace-rename' of github.com:marmistrz/nix into ptrace-…
marmistrz Jul 25, 2017
bf93180
Remove the TODO comments, add unwrap() for ptrace.
marmistrz Jul 25, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/sys/ptrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ fn ptrace_other(request: ptrace::PtraceRequest, pid: Pid, addr: *mut c_void, dat
}

/// Set options, as with `ptrace(PTRACE_SETOPTIONS,...)`.
pub fn ptrace_setoptions(pid: Pid, options: ptrace::PtraceOptions) -> Result<()> {
pub fn setoptions(pid: Pid, options: ptrace::PtraceOptions) -> Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no module-level documentation for the ptrace module, but it'd be good to add one showing an example usage that demonstrates the namespacing we recomment. We don't need it per-say, but it'd help users use this crate very easily. It'll also help us see where the imports aren't very ergonomic so we can improve them later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add the documentation when I'm done with all the ptrace changes, ok?

Besides, I really think about splitting up #666 into a couple smaller PRs because I'm starting to lose control of the tests.

use self::ptrace::*;
use std::ptr;

Expand All @@ -117,19 +117,19 @@ pub fn ptrace_setoptions(pid: Pid, options: ptrace::PtraceOptions) -> Result<()>
}

/// Gets a ptrace event as described by `ptrace(PTRACE_GETEVENTMSG,...)`
pub fn ptrace_getevent(pid: Pid) -> Result<c_long> {
pub fn getevent(pid: Pid) -> Result<c_long> {
use self::ptrace::*;
ptrace_get_data::<c_long>(PTRACE_GETEVENTMSG, pid)
}

/// Get siginfo as with `ptrace(PTRACE_GETSIGINFO,...)`
pub fn ptrace_getsiginfo(pid: Pid) -> Result<siginfo_t> {
pub fn getsiginfo(pid: Pid) -> Result<siginfo_t> {
use self::ptrace::*;
ptrace_get_data::<siginfo_t>(PTRACE_GETSIGINFO, pid)
}

/// Set siginfo as with `ptrace(PTRACE_SETSIGINFO,...)`
pub fn ptrace_setsiginfo(pid: Pid, sig: &siginfo_t) -> Result<()> {
pub fn setsiginfo(pid: Pid, sig: &siginfo_t) -> Result<()> {
use self::ptrace::*;
let ret = unsafe{
Errno::clear();
Expand Down
9 changes: 5 additions & 4 deletions test/sys/test_ptrace.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use nix::Error;
use nix::errno::*;
use nix::unistd::*;
use nix::sys::ptrace;
use nix::sys::ptrace::*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't seem so useful if you still need to glob import a ton of things. Can we get rid of those here or does that make things really cluttered?

use nix::sys::ptrace::ptrace::*;

Expand All @@ -17,21 +18,21 @@ fn test_ptrace() {
// Just make sure ptrace_setoptions can be called at all, for now.
#[test]
fn test_ptrace_setoptions() {
let err = ptrace_setoptions(getpid(), PTRACE_O_TRACESYSGOOD).unwrap_err();
let err = ptrace::setoptions(getpid(), PTRACE_O_TRACESYSGOOD).unwrap_err();
assert!(err != Error::UnsupportedOperation);
}

// Just make sure ptrace_getevent can be called at all, for now.
#[test]
fn test_ptrace_getevent() {
let err = ptrace_getevent(getpid()).unwrap_err();
let err = ptrace::getevent(getpid()).unwrap_err();
assert!(err != Error::UnsupportedOperation);
}

// Just make sure ptrace_getsiginfo can be called at all, for now.
#[test]
fn test_ptrace_getsiginfo() {
match ptrace_getsiginfo(getpid()) {
match ptrace::getsiginfo(getpid()) {
Err(Error::UnsupportedOperation) => panic!("ptrace_getsiginfo returns Error::UnsupportedOperation!"),
_ => (),
}
Expand All @@ -41,7 +42,7 @@ fn test_ptrace_getsiginfo() {
#[test]
fn test_ptrace_setsiginfo() {
let siginfo = unsafe { mem::uninitialized() };
match ptrace_setsiginfo(getpid(), &siginfo) {
match ptrace::setsiginfo(getpid(), &siginfo) {
Err(Error::UnsupportedOperation) => panic!("ptrace_setsiginfo returns Error::UnsupportedOperation!"),
_ => (),
}
Expand Down