@@ -11,7 +11,7 @@ use bincode;
11
11
use fnv:: FnvHasher ;
12
12
use libc:: { self , MAP_FAILED , MAP_SHARED , PROT_READ , PROT_WRITE , SOCK_SEQPACKET , SOL_SOCKET } ;
13
13
use libc:: { SO_LINGER , S_IFMT , S_IFSOCK , c_char, c_int, c_void, getsockopt} ;
14
- use libc:: { iovec, mode_t, msghdr, off_t , recvmsg, sendmsg} ;
14
+ use libc:: { iovec, mode_t, msghdr, recvmsg, sendmsg} ;
15
15
use libc:: { setsockopt, size_t, sockaddr, sockaddr_un, socketpair, socklen_t, sa_family_t} ;
16
16
use std:: cell:: Cell ;
17
17
use std:: cmp;
@@ -32,6 +32,7 @@ use std::thread;
32
32
use mio:: unix:: EventedFd ;
33
33
use mio:: { Poll , Token , Events , Ready , PollOpt } ;
34
34
use tempfile:: { Builder , TempDir } ;
35
+ use shmemfdrs:: create_shmem;
35
36
36
37
const MAX_FDS_IN_CMSG : u32 = 64 ;
37
38
@@ -953,31 +954,6 @@ fn recv(fd: c_int, blocking_mode: BlockingMode)
953
954
Ok ( ( main_data_buffer, channels, shared_memory_regions) )
954
955
}
955
956
956
- #[ cfg( not( all( target_os="linux" , feature="memfd" ) ) ) ]
957
- fn create_shmem ( name : CString , length : usize ) -> c_int {
958
- unsafe {
959
- // NB: the FreeBSD man page for shm_unlink states that it requires
960
- // write permissions, but testing shows that read-write is required.
961
- let fd = libc:: shm_open ( name. as_ptr ( ) ,
962
- libc:: O_CREAT | libc:: O_RDWR | libc:: O_EXCL ,
963
- 0o600 ) ;
964
- assert ! ( fd >= 0 ) ;
965
- assert ! ( libc:: shm_unlink( name. as_ptr( ) ) == 0 ) ;
966
- assert ! ( libc:: ftruncate( fd, length as off_t) == 0 ) ;
967
- fd
968
- }
969
- }
970
-
971
- #[ cfg( all( feature="memfd" , target_os="linux" ) ) ]
972
- fn create_shmem ( name : CString , length : usize ) -> c_int {
973
- unsafe {
974
- let fd = memfd_create ( name. as_ptr ( ) , 0 ) ;
975
- assert ! ( fd >= 0 ) ;
976
- assert ! ( libc:: ftruncate( fd, length as off_t) == 0 ) ;
977
- fd
978
- }
979
- }
980
-
981
957
struct UnixCmsg {
982
958
cmsg_buffer : * mut cmsghdr ,
983
959
msghdr : msghdr ,
@@ -1053,11 +1029,6 @@ fn is_socket(fd: c_int) -> bool {
1053
1029
1054
1030
// FFI stuff follows:
1055
1031
1056
- #[ cfg( all( feature="memfd" , target_os="linux" ) ) ]
1057
- unsafe fn memfd_create ( name : * const c_char , flags : usize ) -> c_int {
1058
- syscall ! ( MEMFD_CREATE , name, flags) as c_int
1059
- }
1060
-
1061
1032
#[ allow( non_snake_case) ]
1062
1033
fn CMSG_LEN ( length : size_t ) -> size_t {
1063
1034
CMSG_ALIGN ( mem:: size_of :: < cmsghdr > ( ) ) + length
0 commit comments