From 2fe9a70006e7d38ba919434bcff2c7cc5ffc664f Mon Sep 17 00:00:00 2001 From: Johannes Leupolz Date: Tue, 9 Dec 2025 09:20:51 +0000 Subject: [PATCH] Remove unused imports --- vuinputd/src/cuse_device/vuinput_ioctl.rs | 15 +++--------- vuinputd/src/cuse_device/vuinput_open.rs | 20 ++++------------ vuinputd/src/cuse_device/vuinput_release.rs | 19 ++------------- vuinputd/src/cuse_device/vuinput_write.rs | 20 ++++------------ vuinputd/src/jobs/inject_in_container_job.rs | 2 +- vuinputd/src/jobs/mknod_input_device.rs | 3 +-- .../src/jobs/remove_from_container_job.rs | 5 ++-- vuinputd/src/jobs/runtime_data.rs | 1 - vuinputd/src/main.rs | 24 ++++--------------- vuinputd/src/process_tools/mod.rs | 5 ++-- 10 files changed, 26 insertions(+), 88 deletions(-) diff --git a/vuinputd/src/cuse_device/vuinput_ioctl.rs b/vuinputd/src/cuse_device/vuinput_ioctl.rs index 9d747aa..d157471 100644 --- a/vuinputd/src/cuse_device/vuinput_ioctl.rs +++ b/vuinputd/src/cuse_device/vuinput_ioctl.rs @@ -2,23 +2,14 @@ // // Author: Johannes Leupolz -use libc::{O_CLOEXEC, input_id}; -use libc::{iovec, off_t, size_t, EBADRQC, EIO, ENOENT}; +use libc::{iovec, size_t, EBADRQC}; use libc::{uinput_abs_setup, uinput_ff_erase, uinput_ff_upload, uinput_setup}; use ::cuse_lowlevel::*; -use log::{debug, error, info, trace}; -use std::collections::HashMap; -use std::ffi::{CStr, CString}; -use std::{fs, ptr}; -use std::fs::{File, OpenOptions}; +use log::{debug}; +use std::ffi::{CStr}; use std::io::Write; -use std::io::{self, ErrorKind}; use std::os::fd::AsRawFd; use std::os::raw::{c_char, c_int, c_uint, c_void}; -use std::os::unix::fs::{FileTypeExt, MetadataExt, OpenOptionsExt}; -use std::path::Path; -use std::sync::atomic::{AtomicU64, Ordering}; -use std::sync::{Arc, Mutex, OnceLock, RwLock}; use uinput_ioctls::*; use crate::cuse_device::{SYS_INPUT_DIR, VuFileHandle, VuInputDevice, fetch_device_node, get_vuinput_state}; diff --git a/vuinputd/src/cuse_device/vuinput_open.rs b/vuinputd/src/cuse_device/vuinput_open.rs index 67b0e4b..9acfffd 100644 --- a/vuinputd/src/cuse_device/vuinput_open.rs +++ b/vuinputd/src/cuse_device/vuinput_open.rs @@ -3,24 +3,14 @@ // Author: Johannes Leupolz use std::sync::OnceLock; -use libc::{O_CLOEXEC, input_id}; -use libc::{iovec, off_t, size_t, EBADRQC, EIO, ENOENT}; -use libc::{uinput_abs_setup, uinput_ff_erase, uinput_ff_upload, uinput_setup}; +use libc::{O_CLOEXEC}; +use libc::{ENOENT}; use ::cuse_lowlevel::*; -use log::{debug, error, info, trace}; -use std::collections::HashMap; -use std::ffi::{CStr, CString}; -use std::{fs, ptr}; -use std::fs::{File, OpenOptions}; -use std::io::Write; -use std::io::{self, ErrorKind}; -use std::os::fd::AsRawFd; -use std::os::raw::{c_char, c_int, c_uint, c_void}; -use std::os::unix::fs::{FileTypeExt, MetadataExt, OpenOptionsExt}; +use log::{debug, error}; +use std::fs::{OpenOptions}; +use std::os::unix::fs::{OpenOptionsExt}; use std::path::Path; use std::sync::atomic::{AtomicU64, Ordering}; -use std::sync::{Arc, Mutex, RwLock}; -use uinput_ioctls::*; use crate::process_tools::{Pid, get_requesting_process}; use crate::cuse_device::*; diff --git a/vuinputd/src/cuse_device/vuinput_release.rs b/vuinputd/src/cuse_device/vuinput_release.rs index ee80a63..9454e5c 100644 --- a/vuinputd/src/cuse_device/vuinput_release.rs +++ b/vuinputd/src/cuse_device/vuinput_release.rs @@ -2,24 +2,9 @@ // // Author: Johannes Leupolz -use libc::{O_CLOEXEC, input_id}; -use libc::{iovec, off_t, size_t, EBADRQC, EIO, ENOENT}; -use libc::{uinput_abs_setup, uinput_ff_erase, uinput_ff_upload, uinput_setup}; use ::cuse_lowlevel::*; -use log::{debug, error, info, trace}; -use std::collections::HashMap; -use std::ffi::{CStr, CString}; -use std::{fs, ptr}; -use std::fs::{File, OpenOptions}; -use std::io::Write; -use std::io::{self, ErrorKind}; -use std::os::fd::AsRawFd; -use std::os::raw::{c_char, c_int, c_uint, c_void}; -use std::os::unix::fs::{FileTypeExt, MetadataExt, OpenOptionsExt}; -use std::path::Path; -use std::sync::atomic::{AtomicU64, Ordering}; -use std::sync::{Arc, Mutex, OnceLock, RwLock}; -use uinput_ioctls::*; +use log::{debug}; +use std::sync::{Arc}; use crate::{cuse_device::*, jobs}; use crate::job_engine::JOB_DISPATCHER; use crate::jobs::remove_from_container_job::RemoveFromContainerJob; diff --git a/vuinputd/src/cuse_device/vuinput_write.rs b/vuinputd/src/cuse_device/vuinput_write.rs index b8e57c8..b788dcb 100644 --- a/vuinputd/src/cuse_device/vuinput_write.rs +++ b/vuinputd/src/cuse_device/vuinput_write.rs @@ -2,25 +2,15 @@ // // Author: Johannes Leupolz -use libc::{O_CLOEXEC, input_id}; -use libc::{iovec, off_t, size_t, EBADRQC, EIO, ENOENT}; -use libc::{uinput_abs_setup, uinput_ff_erase, uinput_ff_upload, uinput_setup}; +use libc::{off_t, size_t, EIO}; +use libc::{uinput_abs_setup, uinput_setup}; use ::cuse_lowlevel::*; -use log::{debug, error, info, trace}; -use std::collections::HashMap; -use std::ffi::{CStr, CString}; -use std::{fs, ptr}; -use std::fs::{File, OpenOptions}; +use log::{debug, trace}; use std::io::Write; -use std::io::{self, ErrorKind}; use std::os::fd::AsRawFd; -use std::os::raw::{c_char, c_int, c_uint, c_void}; -use std::os::unix::fs::{FileTypeExt, MetadataExt, OpenOptionsExt}; -use std::path::Path; -use std::sync::atomic::{AtomicU64, Ordering}; -use std::sync::{Arc, Mutex, OnceLock, RwLock}; +use std::os::raw::{c_char}; use uinput_ioctls::*; -use libc::{__s32, __u16, c_ulong, input_event}; +use libc::{__s32, __u16, input_event}; use crate::cuse_device::*; diff --git a/vuinputd/src/jobs/inject_in_container_job.rs b/vuinputd/src/jobs/inject_in_container_job.rs index eca8fb2..4c0dd93 100644 --- a/vuinputd/src/jobs/inject_in_container_job.rs +++ b/vuinputd/src/jobs/inject_in_container_job.rs @@ -111,7 +111,7 @@ impl InjectInContainerJob { // wait a maximum of 5 seconds == 50 attempts Timer::after(Duration::from_millis(100)).await; } - if (netlink_data.is_none() || runtime_data.is_none()) { + if netlink_data.is_none() || runtime_data.is_none() { if netlink_data.is_none() { debug!("Give up reading netlink data"); } diff --git a/vuinputd/src/jobs/mknod_input_device.rs b/vuinputd/src/jobs/mknod_input_device.rs index 9c39af5..4f2252b 100644 --- a/vuinputd/src/jobs/mknod_input_device.rs +++ b/vuinputd/src/jobs/mknod_input_device.rs @@ -3,10 +3,9 @@ // Author: Johannes Leupolz use nix::sys::stat::{makedev, mknod, stat, Mode, SFlag}; -use nix::unistd::{chown, Gid, Uid}; use std::error::Error; use std::fs; -use std::os::unix::fs::{MetadataExt, PermissionsExt}; +use std::os::unix::fs::{PermissionsExt}; use std::path::Path; pub fn ensure_input_device(dev_path: String, major: u64, minor: u64) -> Result<(), Box> { diff --git a/vuinputd/src/jobs/remove_from_container_job.rs b/vuinputd/src/jobs/remove_from_container_job.rs index 1de6865..12b066d 100644 --- a/vuinputd/src/jobs/remove_from_container_job.rs +++ b/vuinputd/src/jobs/remove_from_container_job.rs @@ -2,12 +2,11 @@ // // Author: Johannes Leupolz -use std::{collections::HashMap, future::Future, pin::Pin, sync::{Arc, Condvar, Mutex}, time::Duration}; +use std::{future::Future, pin::Pin, sync::{Arc, Condvar, Mutex}}; -use async_io::Timer; use log::debug; -use crate::{job_engine::job::{Job, JobTarget}, jobs::{mknod_input_device::remove_input_device, monitor_udev_job::EVENT_STORE, netlink_message::send_udev_monitor_message_with_properties, runtime_data::{delete_udev_data, ensure_udev_structure, read_udev_data, write_udev_data}}, process_tools::{Pid, RequestingProcess, await_process, run_in_net_and_mnt_namespace}}; +use crate::{job_engine::job::{Job, JobTarget}, jobs::{mknod_input_device::remove_input_device, monitor_udev_job::EVENT_STORE, netlink_message::send_udev_monitor_message_with_properties, runtime_data::{delete_udev_data}}, process_tools::{Pid, RequestingProcess, await_process, run_in_net_and_mnt_namespace}}; diff --git a/vuinputd/src/jobs/runtime_data.rs b/vuinputd/src/jobs/runtime_data.rs index 94327d4..f74b05a 100644 --- a/vuinputd/src/jobs/runtime_data.rs +++ b/vuinputd/src/jobs/runtime_data.rs @@ -78,7 +78,6 @@ pub fn read_udev_data(major: u64, minor: u64) -> io::Result { #[cfg(test)] mod tests { - use super::*; #[test] fn test_replacement_and_filter() { diff --git a/vuinputd/src/main.rs b/vuinputd/src/main.rs index 500fcfe..52f2410 100644 --- a/vuinputd/src/main.rs +++ b/vuinputd/src/main.rs @@ -17,33 +17,19 @@ // naming: dev_path vs dev_node. I guess I mean the same. // Send warning, if udev monitor does not exist - -use libc::{O_CLOEXEC, input_id}; -use libc::{iovec, off_t, size_t, EBADRQC, EIO, ENOENT}; -use libc::{uinput_abs_setup, uinput_ff_erase, uinput_ff_upload, uinput_setup}; use ::cuse_lowlevel::*; -use log::{debug, error, info, trace}; +use log::info; use std::collections::HashMap; -use std::ffi::{CStr, CString}; -use std::{fs, ptr}; -use std::fs::{File, OpenOptions}; -use std::io::Write; -use std::io::{self, ErrorKind}; -use std::os::fd::AsRawFd; -use std::os::raw::{c_char, c_int, c_uint, c_void}; -use std::os::unix::fs::{FileTypeExt, MetadataExt, OpenOptionsExt}; -use std::path::Path; -use std::sync::atomic::{AtomicU64, Ordering}; -use std::sync::{Arc, Mutex, OnceLock, RwLock}; -use uinput_ioctls::*; +use std::ffi::CString; +use std::os::raw::{c_char}; +use std::sync::atomic::{AtomicU64}; +use std::sync::{Mutex, RwLock}; pub mod cuse_device; use crate::cuse_device::vuinput_open::VUINPUT_COUNTER; use crate::cuse_device::{DEDUP_LAST_ERROR, VUINPUT_STATE, vuinput_make_cuse_ops}; -use crate::jobs::inject_in_container_job::InjectInContainerJob; use crate::jobs::monitor_udev_job::MonitorBackgroundLoop; -use crate::jobs::remove_from_container_job::RemoveFromContainerJob; pub mod process_tools; diff --git a/vuinputd/src/process_tools/mod.rs b/vuinputd/src/process_tools/mod.rs index 2d7b686..24952c0 100644 --- a/vuinputd/src/process_tools/mod.rs +++ b/vuinputd/src/process_tools/mod.rs @@ -9,11 +9,10 @@ use nix::{ unistd::{fork, ForkResult}, }; use std::{ - fs::{self, File}, io::Read, os::fd::{AsFd, FromRawFd, OwnedFd, RawFd}, path::{self, Path}, process, sync::OnceLock, thread, time::Duration + fs::{self, File}, io::Read, os::fd::{AsFd, FromRawFd, OwnedFd, RawFd}, path::{Path}, process, sync::OnceLock }; -use std::io::{self, BufRead}; -use std::path::PathBuf; +use std::io; pub static SELF_NAMESPACES: OnceLock= OnceLock::new();