|
2 | 2 | // Copyright © 2020 The developers of linux-support. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/linux-support/master/COPYRIGHT.
|
3 | 3 |
|
4 | 4 |
|
5 |
| -use crate::syscall::SystemCallResult; |
6 |
| - |
7 | 5 | /// A Linux kernel module name.
|
8 | 6 | #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
9 | 7 | #[derive(Deserialize, Serialize)]
|
@@ -247,22 +245,16 @@ impl LinuxKernelModuleName
|
247 | 245 | let name: CString = self.into();
|
248 | 246 | const flags: c_long = O_NONBLOCK as c_long;
|
249 | 247 |
|
250 |
| - let system_call_result = system_call_delete_module(name.as_c_str(), flags); |
251 |
| - match system_call_result |
| 248 | + match system_call_delete_module(name.as_c_str(), flags).as_usize() |
252 | 249 | {
|
253 | 250 | 0 => Ok(true),
|
254 | 251 |
|
255 |
| - -1 => match SystemCallErrorNumber::from_errno_panic() |
256 |
| - { |
257 |
| - EPERM => Err(io_error_permission_denied("permission denied")), |
258 |
| - EBUSY => Err(io_error_permission_denied("busy")), |
259 |
| - ENOENT => Ok(false), |
260 |
| - EWOULDBLOCK => Err(io_error_permission_denied("in use")), |
261 |
| - |
262 |
| - EFAULT => panic!("EFAULT should not occur"), |
263 |
| - |
264 |
| - unexpected_error @ _ => unexpected_error!(delete_module, SystemCallResult::usize_to_system_call_error_number(unexpected_error)), |
265 |
| - }, |
| 252 | + SystemCallResult::EPERM_usize => Err(io_error_permission_denied("permission denied")), |
| 253 | + SystemCallResult::EBUSY_usize => Err(io_error_permission_denied("busy")), |
| 254 | + SystemCallResult::ENOENT_usize => Ok(false), |
| 255 | + SystemCallResult::EWOULDBLOCK_usize => Err(io_error_permission_denied("in use")), |
| 256 | + SystemCallResult::EFAULT_usize => panic!("EFAULT should not occur"), |
| 257 | + unexpected_error @ SystemCallResult::InclusiveErrorRangeStartsFrom_usize ..= SystemCallResult::InclusiveErrorRangeEndsAt_usize => unexpected_error!(delete_module, SystemCallResult::usize_to_system_call_error_number(unexpected_error)), |
266 | 258 |
|
267 | 259 | unexpected @ _ => unexpected_result!(delete_module, unexpected),
|
268 | 260 | }
|
|
0 commit comments