Commit Graph

43 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
40351db00d use tempfile in test_pwrite. 2016-10-23 20:43:38 -06: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
Nikolay Amiantov
db22a823f4 select: allow infinite timeout 2016-02-20 00:19:13 +03: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
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
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
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
Utkarsh Kukreti
ee9affe12f Add sys::select::FdSet and sys::select::select. 2015-09-28 10:58:05 -07:00
Geoffrey Thomas
046af7d1ba Add support for sendmsg(2), recvmsg(2), and cmsg(4)
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(4) API for type-safety reasons (and
also because the cmsg(4) API is terrible). See test/sys/test_socket.rs
for an example.

Only supports SCM_RIGHTS at the moment.

Fixes #88.
2015-09-24 23:18:44 -04:00
Paul Osborne
eab583b411 ioctl: return result type rather than raw integer
This change also adds macro usages in the tests.  Nothing is asserted
but the use of the macros provides a basic compile-time check that
is otherwise missing.

Signed-off-by: Paul Osborne <osbpau@gmail.com>
2015-08-12 19:49:18 -05:00
Corey Richardson
3f3845896e conditionally enable ioctl test for linux 2015-08-12 19:29:21 -05:00
Corey Richardson
23332d6e8d Fix tests 2015-08-12 19:29:21 -05:00
Tim JIANG
08a55288d1 Make it compatible for Android.
* Fixed an unused_import error in `termios.rs` for Android.
* Fixed undefined references to `preadv` and `pwritev` for Android -
  At least they don't exist from API level 3 to 21.
* Fixed the uid > 0 and gid > 0 checks in `stat`'s tests - Running the
  tests by root is possible, especially when running on a rooted Android
  device.

Those changes made rust-nix buildable (again) on Android. All the tests
passed as well.
2015-07-27 10:31:26 -07:00
Joseph Kain
c20401b51c Add status to WaitStatus
* Extend the enums in WaitStatus to include all process states (signaled,
  stopped, exited, continued).
* Decode status from waitpid
* Return appropate WaitStatus
* Update tests to use the new WaitStatus
* Add new tests for specific status values
2015-07-13 11:58:34 -07:00
Trip Volpe
a8182ce667 Add support for preadv and pwritev to sys/uio on Linux. 2015-07-13 11:41:48 -07:00
Joseph Kain
b7e64a7545 Fix off-by-one error calling Rng::gen_range
Fix the boundary condition so that we never call

    Rng::gen_range(64, 64).

Helps #144
2015-07-04 14:35:27 -07:00
Florian Hartwig
d8010d83ea Add pwrite and pread 2015-06-05 23:52:19 +02:00
Carl Lerche
74d1831880 Test sockopt const values 2015-05-21 15:02:12 -07:00
Paul Osborne
a43613ac77 ioctl: implement generic support for the ioctl syscall and supporting functions
This commit provides a new implementation for ioctl that is much
more generic, allowing for clients to use send any manner of ioctl
requests at special files.  The implementation provides two main features
that help to raise the level of abstraction over that provided by libc.

1. The module now provides functions that provide the same functionality
   as the linux kernel _IO* macros.  These are used frequently in the
   linux kernel for building ops for ioctls.  The use of these helper
   functions are not required.
2. Functions are provided for the 3 main types of ioctl usage patterns
   (read, write, and execute).  For many subystems, the read() call
   which returns a Result<T> and the write calls taking a &T provide
   a nice interface.

All of the methods wrapping ioctl are unsafe and will probably need to
remain that way unless knowledge of the semantics of every possible
ioctl call are added to the nix library.  The best that exists for
ioctls are some conventions around the op, but even these conventions
are really only used for newer devices added to the kernel.

This change resolves #108
2015-05-12 22:25:22 -07:00
Qingping Hou
40539b5c23 feat: add execvpe 2015-05-05 05:23:05 -04:00
Florian Hartwig
e3d86a9ccd Add socketpair 2015-04-11 23:51:13 +02:00
Carl Lerche
ffc8826dfe Remove usage of std::num::Int 2015-04-01 20:35:24 -07:00
Carl Lerche
15256eb1c2 Track Rust nightly 2015-03-28 17:05:47 -07:00
Carl Lerche
bf3d7c4939 Tweak conversion in test 2015-03-25 16:39:51 -07:00
Carl Lerche
0d5ea0b16d Track Rust master 2015-03-25 10:52:05 -07:00
Carl Lerche
47d2332c3c NixResult -> nix::Result; NixError -> nix::Error 2015-03-24 23:25:10 -07:00
Carl Lerche
2b60633c8b Track Rust nightlies 2015-03-19 15:08:45 -07:00
Carl Lerche
e8a58c83a5 Further SockAddr & NixPath cleanup 2015-02-27 11:14:38 -08:00
Carl Lerche
8a7cd5675d Large cleanup, mostly of socket functions 2015-02-25 12:24:43 -08:00
Carl Lerche
88988a31a0 Remove prefix from SockAddr variants 2015-02-22 20:50:34 -08:00
Carl Lerche
eb278aa4d7 Implement round trip SockAddr conversions 2015-02-22 12:57:01 -08:00
Carl Lerche
6af51aa232 Fix uio and add SockAddr conversions 2015-02-21 22:42:10 -08:00
Carl Lerche
60ccee778b Cleanup readv & writev + tests 2015-02-21 14:33:27 -08:00