Commit Graph

431 Commits

Author SHA1 Message Date
Alan Somers
3ccb3130eb Merge github.com:nix-rust/nix into evfilt 2016-10-13 21:26:43 -06:00
Alan Somers
b5ce388e41 Use libc_bitflags! for EventFlag
Don't use it for FilterFlag, because it triggers recursion limit reached error
2016-10-02 12:19:48 -06:00
Homu
1222f52954 Auto merge of #428 - philippkeller:mkstemp, r=fiveop
Add Mkstemp (fixed for rust 1.2)

I fixed @antifuchs addition of `mkstmp` in https://github.com/nix-rust/nix/pull/365 by making it compile in Rust 1.2 and adding documentation.

A few remarks:

- made it working with Rust 1.2 which needed `to_bytes_with_nul()`. I think the implementation is memory safe but would like to have a pair of eyes checking that
- replaced Path by PathBuf so it's more in line with getcwd
- I didn't move it into another module. If this still the consensus then I would like to do that but in a separate PR (probably moving all stdio methods out)
- it's true that unistd doesn't need mkstmp since there is the crate tempdir and tempfile, but I'd love to see this here for completeness
2016-10-02 22:36:18 +09:00
Philipp Keller
7c0f5e3598 Add debug_assert ensuring popped byte is nul 2016-09-28 07:02:15 +02:00
Philipp Keller
60a70c6b1e Remove double copy of array (to_owned() and PathBuf::from), use OsString::from_vec on existing path var rather than construct string from pointer 2016-09-27 22:23:36 +02:00
Philipp Keller
95ac98a0b5 move path outside closure to avoid use after free, restructed for easier readability 2016-09-27 21:45:26 +02:00
Alan Somers
2c97154d3e struct KEvent should wrap an inner libc::kevent structure 2016-09-18 22:41:54 -06:00
Tim Ryan
1f2d896b96 Removes SIGSTKFLT when cross-compiling to MIPS. 2016-09-17 23:50:58 +02:00
Homu
9f3f7c2189 Auto merge of #429 - Idolf:master, r=fiveop
Fixed a bug where UnixAddr::new_abstract forgot to count the null-byte.
2016-09-18 04:25:10 +09:00
Homu
6ea8f7f91c Auto merge of #427 - oconnor663:pipe2, r=fiveop
call pipe2 directly on Linux

A first shot at fixing https://github.com/nix-rust/nix/issues/414. This approach keeps the old implementation for platforms other than `notbsd`, because `libc` only exposes `pipe2` in the `notbsd` module.

I've tested this by hand on my Linux machine in a couple ways:

- Create a toy program that opens a pipe and passes it to `cat`, which hags if `O_CLOEXEC` doesn't get set properly. Confirm that it doesn't hang, but that it does if I pass `0` as the flags to `libc::pipe2`.
- Delete the new implementation entirely, and delete the `cfg` guards on the old implementation, and confirm that above is still true.

I haven't actually tested a cross compilation build though. Is there a standard way to do that?
2016-09-18 04:14:05 +09:00
Mathias Svensson
26e1b6d785 Fixed a bug where UnixAddr::new_abstract forgot to count the null-byte. 2016-09-17 19:23:49 +02:00
Homu
3c8ff4ab91 Auto merge of #410 - fiveop:epoll_create1, r=posborne
Add epoll_create1

In order to get @kubo39's PR #384 forward, I cleaned up the commit history a bit and added `EpollEvent` back.

Since this module is used by mio, maybe @carllerche could comment on these changes.
2016-09-17 01:55:43 +09:00
Philipp Keller
80df83be20 fixing build for aarch64-unknown-linux-gnu (which expects the pointer to be *mut u8 whereas x86_64 and i686 expect it to be *mut i8) 2016-09-16 17:19:14 +02:00
Philipp Keller
631a27a545 made it running with rust 1.2, added documentation to mkstemp 2016-09-16 07:14:29 +02:00
Philipp Matthias Schaefer
2b0c9919ac Rename EpollEventKind to EpollFlags, according to convention. 2016-09-15 22:08:04 +02:00
Philipp Matthias Schaefer
c9edda389b Add EpollCrateFlags bitflag type. 2016-09-15 22:07:43 +02:00
Jack O'Connor
b28005f658 make unsafe code more fine-grained in pipe2 2016-09-15 09:52:38 -07:00
Jack O'Connor
71688a082a call pipe2 directly on Linux 2016-09-14 16:12:57 -07:00
Sebastian Dröge
0f9cc0589c Add MSG_CMSG_CLOEXEC to MsgFlags on Linux
Fixes #421.
2016-09-09 18:11:01 +03:00
Alan Somers
a62b2a3d71 Remove macos NOTE_ definitions that aren't in libc 2016-09-08 20:31:34 -06:00
Alan Somers
cf5fccf100 Reconcile with libc changes
The final version of libc's PR #379 removed a few definitions, and fixed
OpenBSD's definition of fn kevent.
2016-09-08 19:58:09 -06:00
Philipp Matthias Schaefer
584794d791 Add property readers to EpollEvent 2016-09-08 21:23:52 +02:00
Philipp Matthias Schaefer
da36438f5b Readd EpollEvent 2016-09-08 21:23:52 +02:00
Hiroki Noda
dfcf126676 Use libc's declarations 2016-09-08 21:23:52 +02:00
Hiroki Noda
26d211710c Not to set EPOLL_CLOEXEC by default. 2016-09-08 21:23:52 +02:00
Hiroki Noda
7508fd3596 Add epoll_create1 and set EPOLL_CLOEXEC flag by default. 2016-09-08 21:23:52 +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
5f1e144de9 resolving all remarks by @posborne, fixed max line length=99, fixed rust 1.2.0 error in doc-test 2016-09-07 07:17:36 +02:00
Philipp Keller
37e4f9756d rust 1.2.0 doesn't support expect, switched to proper match block 2016-09-06 22:28:13 +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
c0a578539a fixed the trailing whitespaces 2016-09-06 17:19:07 +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
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
Alan Somers
a17bb7b26b Define kqueue-related stuff in terms of libc
Change 11aa1f34243d5bbb7d6327a6607bd9d2530f3954 to libc added kqueue-related
definitions.  They are more accurate and more complete than nix's own
definitions.  Use them where possible.

Also, rationalize Nix's definitions so its public API will be as similar as
possible across all OSes.
2016-09-02 05:09:51 -06: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
8ed552100d Run rustfmt on mqueue.rs 2016-08-31 20:19:27 +02: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
899a13061f Replace parts of ffi module by libc functions in sched.rs 2016-08-29 21:48:13 +02:00
Homu
fd4a510635 Auto merge of #407 - untitaker:fullfsync-fcntl, r=fiveop
Add FcntlArg::F_FULLFSYNC

https://developer.apple.com/library/ios/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fsync.2.html
2016-08-27 04:38:23 +09:00
Markus Unterwaditzer
ae6635f7a6 Add FcntlArg::F_FULLFSYNC
https://developer.apple.com/library/ios/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fsync.2.html
2016-08-26 09:47:45 +02:00
Murarth
aa426634ad Implement Clone for FdSet on Mac/iOS 2016-08-25 14:10:59 -07:00
Alan Somers
077d979acb Fix nix on FreeBSD amd64
On Linux, the cmsg_len field of struct cmsghdr has type size_t, but it
has size socklen_t on POSIX-compliant operating systems.  So on
POSIX-compliant 64-bit operating systems, struct cmsghdr has padding
gaps that aren't present on Linux.  Most of the issues fixed by this
commit related to those gaps.

src/sys/socket/ffi.rs
	Fix the type of the cmsg_data field so the struct layout will be
	correct.

src/sys/socket/mod.rs
	In CmsgIterator.next, only return a single file descriptor.
	sendmsg(2) can only stuff a single file descriptor into each
	cmsg.

	In cmsg_align, fix the rounding calculation, and eliminate a
	division instruction.

	Add a missing cmsg_align call in ControlMessage.len

	In ControlMessage.encode_into, add any necessary padding bytes
	between the cmsghdr and the data.

	In sendmsg, fix some len<->capacity confusion.
2016-08-10 21:12:53 +02:00
Alan Somers
36789c78a7 Fix the sockopt_impl matcher rule order.
Rules for generic types were located above rules for specific types, so the
rules for specific types never got matched.  This caused the
sys::socket::sockopt::test::can_get_listen_on_tcp_socket test to fail on
FreeBSD.  The solution is to put all of the generic rules at the bottom.
2016-08-10 21:12:53 +02:00
Alan Somers
bae5a37339 Fix the sethostname binding on FreeBSD and DragonflyBSD 2016-08-10 21:12:53 +02:00
Tobias Bucher
c4ae567db9 Fix NetBSD build 2016-07-18 22:25:25 +02:00
Sergey Bugaev
215f3872b1 Name enum variants after the libc constants 2016-07-14 14:56:21 +03:00
Sergey Bugaev
8f6b162fb1 Revert "Manually match on RebootMode::*"
This reverts commit 012c6623c9.
2016-07-14 14:54:21 +03:00
Sergey Bugaev
f682458c82 Add some documentation 2016-07-14 00:51:52 +03:00