Skip to content

Commit 2543c9e

Browse files
committed
Removes Errno
1 parent 8598dc1 commit 2543c9e

File tree

5 files changed

+12
-39
lines changed

5 files changed

+12
-39
lines changed

src/errno/mod.rs

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/fd/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::errno::Errno;
21
use crate::pcpu::Pcpu;
32
use crate::thread::Thread;
43
use crate::uio::{IoVec, Uio, UioRw, UioSeg};
@@ -20,11 +19,11 @@ pub unsafe fn openat<K: Kernel>(
2019
seg: UioSeg,
2120
flags: OpenFlags,
2221
mode: c_int,
23-
) -> Result<OwnedFd<K>, Errno> {
22+
) -> Result<OwnedFd<K>, NonZero<c_int>> {
2423
let td = K::Pcpu::curthread();
2524
let errno = kern.kern_openat(td, fd, path, seg, flags, mode);
2625

27-
match Errno::new(errno) {
26+
match NonZero::new(errno) {
2827
Some(v) => Err(v),
2928
None => Ok(OwnedFd {
3029
kern,

src/file/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::errno::Errno;
21
use crate::pcpu::Pcpu;
32
use crate::Kernel;
43
use core::ffi::c_int;
4+
use core::num::NonZero;
55
use core::ptr::null_mut;
66
use core::sync::atomic::{fence, AtomicU32, Ordering};
77

@@ -25,12 +25,12 @@ impl<K: Kernel> OwnedFile<K> {
2525
Self { kern, file }
2626
}
2727

28-
pub fn from_fd(kern: K, fd: c_int) -> Result<Self, Errno> {
28+
pub fn from_fd(kern: K, fd: c_int) -> Result<Self, NonZero<c_int>> {
2929
let td = K::Pcpu::curthread();
3030
let mut fp = null_mut();
3131
let errno = unsafe { kern.fget(td, fd, &mut fp, 0, null_mut()) };
3232

33-
match Errno::new(errno) {
33+
match NonZero::new(errno) {
3434
Some(v) => Err(v),
3535
None => Ok(Self { kern, file: fp }),
3636
}

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use core::ops::Deref;
2020
use core::ptr::{null_mut, read_unaligned, write_unaligned};
2121
pub use okf_macros::*;
2222

23-
pub mod errno;
2423
pub mod fd;
2524
pub mod file;
2625
pub mod lock;

src/socket/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
pub use self::inet::*;
2-
use crate::errno::Errno;
32
use crate::thread::Thread;
43
use crate::Kernel;
54
use core::ffi::{c_int, c_short, c_ushort};
5+
use core::num::NonZero;
66
use core::ptr::null_mut;
77

88
mod inet;
@@ -20,10 +20,10 @@ pub unsafe fn bind<K: Kernel>(
2020
so: *mut K::Socket,
2121
nam: &mut SockAddr,
2222
td: *mut K::Thread,
23-
) -> Result<(), Errno> {
23+
) -> Result<(), NonZero<c_int>> {
2424
let errno = kern.sobind(so, nam, td);
2525

26-
match Errno::new(errno) {
26+
match NonZero::new(errno) {
2727
Some(v) => Err(v),
2828
None => Ok(()),
2929
}
@@ -37,10 +37,10 @@ pub unsafe fn listen<K: Kernel>(
3737
so: *mut K::Socket,
3838
backlog: c_int,
3939
td: *mut K::Thread,
40-
) -> Result<(), Errno> {
40+
) -> Result<(), NonZero<c_int>> {
4141
let errno = kern.solisten(so, backlog, td);
4242

43-
match Errno::new(errno) {
43+
match NonZero::new(errno) {
4444
Some(v) => Err(v),
4545
None => Ok(()),
4646
}
@@ -73,12 +73,12 @@ impl<K: Kernel> OwnedSocket<K> {
7373
ty: c_int,
7474
proto: c_int,
7575
td: *mut K::Thread,
76-
) -> Result<Self, Errno> {
76+
) -> Result<Self, NonZero<c_int>> {
7777
let mut sock = null_mut();
7878
let cred = (*td).cred();
7979
let errno = kern.socreate(dom, &mut sock, ty, proto, cred, td);
8080

81-
match Errno::new(errno) {
81+
match NonZero::new(errno) {
8282
Some(v) => Err(v),
8383
None => Ok(Self { kern, sock }),
8484
}

0 commit comments

Comments
 (0)