Skip to content

Commit 09414af

Browse files
author
Jethro Beekman
committed
Get rid of libc crate dependency in sgxs-loaders
1 parent c856bb5 commit 09414af

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

intel-sgx/sgxs-loaders/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ no_sgx_enclave_common = []
3131
# External dependencies
3232
bitflags = "1" # MIT/Apache-2.0
3333
nix = "0.15" # MIT
34-
libc = "0.2" # MIT/Apache-2.0
3534
failure = "0.1.1" # MIT/Apache-2.0
3635
failure_derive = "0.1.1" # MIT/Apache-2.0
3736
libloading = "0.5" # ISC

intel-sgx/sgxs-loaders/src/isgx/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
mod ioctl;
88

9-
use libc;
109
use std::convert::TryFrom;
1110
use std::fs::{File, OpenOptions};
1211
use std::io::{self, Error as IoError, Result as IoResult};
@@ -17,6 +16,7 @@ use std::ptr;
1716
use std::sync::Arc;
1817

1918
use nix::sys::mman::{mmap, munmap, ProtFlags as Prot, MapFlags as Map};
19+
use nix::errno::Errno;
2020

2121
use sgx_isa::{Attributes, Einittoken, ErrorCode, Miscselect, Secinfo, Secs, Sigstruct, PageType, SecinfoFlags};
2222
use sgxs::einittoken::EinittokenProvider;
@@ -309,7 +309,7 @@ impl EnclaveLoad for InnerDevice {
309309
fn is_enotty(result: &Result<(), Error>) -> bool {
310310
match result {
311311
Err(Error::Init(SgxIoctlError::Io(ref err))) => {
312-
err.raw_os_error() == Some(libc::ENOTTY)
312+
err.raw_os_error() == Some(Errno::ENOTTY as _)
313313
}
314314
_ => false,
315315
}
@@ -351,7 +351,7 @@ impl EnclaveLoad for InnerDevice {
351351
)
352352
},
353353
Augusta => {
354-
Err(Error::Init(SgxIoctlError::Io(IoError::from_raw_os_error(libc::ENOTTY))))
354+
Err(Error::Init(SgxIoctlError::Io(Errno::ENOTTY.into())))
355355
}
356356
}
357357
}
@@ -382,7 +382,7 @@ impl EnclaveLoad for InnerDevice {
382382
}
383383

384384
fn destroy(mapping: &mut Mapping<Self>) {
385-
unsafe { libc::munmap(mapping.base as usize as *mut _, mapping.size as usize) };
385+
unsafe { let _ = munmap(mapping.base as usize as *mut _, mapping.size as usize); }
386386
}
387387
}
388388

@@ -450,7 +450,7 @@ impl Device {
450450
for &(path, family) in DEFAULT_DEVICE_PATHS {
451451
match Self::open(path, family) {
452452
Err(ref e) if e.kind() == io::ErrorKind::NotFound => continue,
453-
Err(ref e) if e.raw_os_error() == Some(libc::ENOTDIR as _) => continue,
453+
Err(ref e) if e.raw_os_error() == Some(Errno::ENOTDIR as _) => continue,
454454
result => return result,
455455
}
456456
}

0 commit comments

Comments
 (0)