Commit Graph

97 Commits

Author SHA1 Message Date
Philipp Matthias Schaefer
45d8beea46 Make signal argument to kill optional 2016-11-14 21:22:05 +01:00
Alan Somers
ea140702a5 Avoid TempDir::into_path(), because it doesn't cleanup on Drop 2016-11-13 20:42:41 -07:00
Kamal Marhubi
0fa7250b95 mount: Run test_mount_bind in CI
Looks like Travis allows bind mounts in their container infra now.
2016-10-24 22:52:05 -04:00
Alan Somers
40351db00d use tempfile in test_pwrite. 2016-10-23 20:43:38 -06:00
Philipp Keller
b47120d5dc Apparently not all mkstemp implementation require the X at the end (despite its documentation\!), checking the failure of a directory now 2016-09-28 07:03:52 +02:00
Philipp Keller
700627eae2 test also that mkstemp fails when there's no X at the end 2016-09-27 21:45:54 +02:00
Philipp Keller
631a27a545 made it running with rust 1.2, added documentation to mkstemp 2016-09-16 07:14:29 +02:00
Homu
3612b35753 Auto merge of #416 - philippkeller:master, r=posborne
add unistd::getcwd and unistd::mkdir

As a (late) followup of [this withdrawn PR](https://github.com/rust-lang/libc/pull/326) I have added getcwd (wrapper around `libc::getcwd`) and mkdir (wrapper around `libc::mkdir`) and added testing.

A few notes:

 - I'm new to rust so I would appreciate some pair of eyes testing the code, plus I'm open for revision of code or general remarks about my coding style
 - I have run the tests both on OSX as on Linux (Ubuntu)
 - I've run `clippy` to see if my code is well formatted, however clippy issues many warnings about the project. I think I didn't add any more warnings
 - the methods in unistd are not documented so I also left out the documentation of `getcwd` and `mkdir`, although I think it'd probably be good to add some documentation, especially some example code how to use the methods
 - the base idea of `getcwd` is [taken from std](https://github.com/rust-lang/rust/blob/1.9.0/src/libstd/sys/unix/os.rs#L95-L119), should I mention that somewhere?
2016-09-08 01:26:43 +09:00
Philipp Keller
7dd12c6b87 fixed indentation 2016-09-07 08:21:56 +02:00
Philipp Keller
50693c11b0 added documentation for getcwd and mkdir, changed test so that it compares against std::env::current_dir 2016-09-06 22:18:19 +02:00
Philipp Keller
8fbd8e91ff made it running with rust 1.2.0: the code for getcwd is now an exact copy of the implementation in std 2016-09-06 17:17:21 +02:00
Philipp Keller
8b1828a5cd implemented mkdir, extended getcwd test to include long path names 2016-09-05 21:50:06 +02:00
Philipp Keller
b03d4e5ff2 added test for getcwd, still not complete (needs to check also longer directory names, need to be created with mkdir first which doesn't exist yet) 2016-09-03 22:57:58 +02:00
Philipp Keller
ac64273796 implemented getcwd (returning Result<PathBuf>, reconciling all calls to expect into proper try handling), needs testing still 2016-09-02 22:57:39 +02:00
Homu
45e317099e Auto merge of #392 - fiveop:less_ffi, r=@fiveop
Replace ffi module by libc functions in mqueue.rs

This is almost finished. I still need to check if I introduced any breaking changes by changing signatures. I would want to record this in the change log, however, for that we still need to merge #391.

- [x] update change log
- [x] run rustfmt on `src/mqueue.rs`
2016-09-01 17:54:33 +09:00
Philipp Matthias Schaefer
b0e69e6e72 Replace ffi module by libc functions in mqueue.rs 2016-08-31 20:18:48 +02:00
Philipp Matthias Schaefer
93dc2387bd Use libc in poll.rs 2016-08-31 20:17:55 +02:00
Philipp Matthias Schaefer
51be2c9852 Get rid of a few warnings during compilation of tests 2016-08-15 21:13:26 +02:00
Andrei Oprisan
0eb8b4b365 Added lseek to unistd
llseek and lseek64

impl Whence

fixed formatting

awful typo when refactoring

no llseek

wrong test name

using off64_t

got rid of offset

Added SeekHole/Data; formatted test; SeekCur/Set/End use libc constants
2016-06-13 10:49:34 +03:00
Andreas Fuchs
23a7ea6493 Return both the fd and the created path 2016-05-01 17:20:12 -07:00
Andreas Fuchs
e42183fcbe Remove dependency on Result::expect 2016-05-01 15:06:59 -07:00
Andreas Fuchs
a821f9630c Add mkstemp(3) 2016-05-01 12:52:20 -07:00
Homu
4ca407db6b Auto merge of #332 - kamalmarhubi:fork-enum, r=fiveop
unistd: Redesign the enum returned by fork()

This changes the name of the enum returned by `fork()` to `ForkResult`,
and changes the `Parent` variant to be struct-like.

The result can be matched like

    use nix::unistd::ForkResult::*;
    match fork().unwrap() {
        Parent { child } => { ... }
        Child => { ... }
    }

using the shorthand matching syntax for struct-like enum variants.

This is a breaking change.
2016-03-31 15:41:38 +09:00
Kamal Marhubi
c2acb9ec6e unistd: Redesign the enum returned by fork()
This commit changes the name of the enum returned by `fork()` to
`ForkResult`, and changes the `Parent` variant to be struct-like.

The result can be matched like

    use nix::unistd::ForkResult::*;
    match fork().unwrap() {
        Parent { child } => { ... }
        Child => { ... }
    }

using the shorthand matching syntax for struct-like enum variants.

This is a breaking change.
2016-03-30 14:47:32 -04:00
Kamal Marhubi
6d01a26510 socket: Respect IPv6 flowinfo and scope_id in InetAddr::from_std
Fixes #329
2016-03-30 14:20:02 -04:00
Kamal Marhubi
507dfaf297 Use pause(2) in test_wait_signal
Replace a busy loop with a call to `pause(2)`.
2016-03-30 00:56:36 -04:00
Kamal Marhubi
bae5db9fdf Use getuid(2) from nix instead of libc in test_mount 2016-03-21 18:46:54 -04:00
Kamal Marhubi
d98e5ac2ab mount: Do not treat unshare(2) failure as test failure
The mount test runner uses unprivileged user namespaces. Previously,
failure from `unshare(2)` to create the user namespace would fail the
test. This changes that to simply print an error and exit successfully.

Refs https://github.com/nix-rust/nix/pull/326
2016-03-21 16:38:07 -04:00
Alex Gulyás
19ad8ca053 update signalfd to use libc types 2016-03-10 20:53:53 +01:00
Dave Hylands
ca752127ed Add gettid 2016-03-07 20:41:38 -08:00
Homu
6cad03a401 Auto merge of #271 - abbradar:mqueue-fixes, r=kamalmarhubi
mqueue: change types to allow more cases

Part of https://github.com/nix-rust/nix/pull/270, fixed according to @kamalmarhubi's comments.
2016-02-20 10:03:19 +09:00
Nikolay Amiantov
8ca6d821e4 mqueue: change types to allow more cases 2016-02-20 02:48:44 +03:00
Nikolay Amiantov
db22a823f4 select: allow infinite timeout 2016-02-20 00:19:13 +03:00
Kamal Marhubi
c381997c0a linux: Add splice(2), tee(2), vmsplice(2) 2016-02-14 23:41:57 -05:00
Kamal Marhubi
4680d50a8a linux: Add sendfile(2) 2016-02-12 21:12:14 -05:00
Philipp Matthias Schaefer
98352705b3 Convert MSG_ flags to bitflags! type. 2016-01-29 22:51:44 -05:00
Frank Denis
e04842ec51 Add tests for sockopt (SndBuf, RcvBuf, SndBufForce, RcvBufForce) 2016-01-29 16:48:08 -05:00
Kamal Marhubi
d0881f63ec Bring back mount
Fixes https://github.com/carllerche/nix-rust/issues/85
2016-01-27 21:37:25 -05:00
Kamal Marhubi
beec2f4443 Add test for if_nametoindex 2016-01-27 17:18:58 -05:00
Utkarsh Kukreti
cec5c6157b Add everything from poll.h. 2016-01-25 17:50:39 -05:00
Mattis Marjak
73dd2e05b8 update libc to 0.2.2 2016-01-18 21:29:38 -08:00
Kamal Marhubi
4450b96399 Use tempdir for temporary files in tests 2016-01-13 09:56:14 -08:00
Kamal Marhubi
b40046e985 Fix compiler warnings in tests 2016-01-13 09:31:54 -08:00
Geoffrey Thomas
ad87c3bdc9 Fix handling of sockaddr_un lengths
The returned length of AF_UNIX sockaddrs is significant, and generally
does not match the length of the entire structure. For filesystem
sockets, this is ignorable because the path is also NUL-terminated, but
for unbound sockets (e.g., a socketpair) or abstract-namespace
sockets (a Linux extension where the address is an arbitrary
bytestring), we need to keep track of the length.

Fixes #177. Also add a UnixAddr::new_abstract function and some better
handling of abstract-namespace socket addresses to fix #169.
2015-10-28 09:34:43 -07:00
Carl Lerche
ac07506288 Only run signalfd tests when feature is set 2015-10-20 14:53:46 -07:00
Carl Lerche
2851a3549b Scope test by signalfd 2015-10-20 11:31:48 -07:00
Utkarsh Kukreti
2cc0603942 Add sys::select::FdSet::clear. 2015-10-07 19:50:36 -07:00
Geoffrey Thomas
b5c1346374 Add support for sendmsg(2), recvmsg(2), and cmsg(3)
The best specification for control message layout appears to be
[RFC 2292, section 4](https://tools.ietf.org/html/rfc2292#section-4),
despite this not being a wire protocol. These definitions have also been
checked against glibc 2.19 <bits/socket.h> and Linux 4.0
<linux/socket.h>, and tested on Debian 8.1 and FreeBSD 10.2 x86_64.

The API differs a bit from the cmsg(3) API for type-safety reasons (and
also because the cmsg(3) API is terrible). See test/sys/test_socket.rs
for an example.

Only supports SCM_RIGHTS at the moment.

Fixes #88.
2015-10-06 19:30:26 -04:00
Markus Jais
5ef1f7acd3 added convenience functions for setting O_NONBLOCK on message queues 2015-09-28 13:08:16 -07:00
Carl Lerche
5948204460 Revert "Add support for sendmsg(2), recvmsg(2), and cmsg(4)"
This reverts commit 046af7d1ba.
2015-09-28 12:37:01 -07:00