Skip to content

Commit

Permalink
[starnix] Expand namespace globs
Browse files Browse the repository at this point in the history
This is an attempt to reduce the amount of namespace globs to see if
it can help out with the trait expansion bug
rust-lang/rust#116996.

Change-Id: I58b6aa8484bab186980b76ccea1fcd34091b60ed
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/941676
Fuchsia-Auto-Submit: Erick Tryzelaar <etryzelaar@google.com>
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Reviewed-by: Kevin Lindkvist <lindkvist@google.com>
  • Loading branch information
erickt authored and Rebase bot committed Nov 7, 2023
1 parent 019927d commit b7ee22c
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 40 deletions.
45 changes: 42 additions & 3 deletions src/starnix/kernel/device/binder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,51 @@ use crate::{
FsNode, FsNodeHandle, FsNodeInfo, FsNodeOps, FsStr, FsString, NamespaceNode, SpecialNode,
VecDirectory, VecDirectoryEntry,
},
logging::*,
logging::{log_error, log_trace, log_warn, not_implemented},
mm::{
vmo::round_up_to_increment, DesiredAddress, MappedVmo, MappingName, MappingOptions,
MemoryAccessor, MemoryAccessorExt, ProtectionFlags,
},
mutable_state::Guard,
syscalls::*,
syscalls::{SyscallArg, SyscallResult, SUCCESS},
task::{
CurrentTask, EventHandler, Kernel, SimpleWaiter, Task, WaitCanceler, WaitQueue, Waiter,
},
types::*,
types::{
binder_buffer_object, binder_driver_command_protocol,
binder_driver_command_protocol_BC_ACQUIRE, binder_driver_command_protocol_BC_ACQUIRE_DONE,
binder_driver_command_protocol_BC_CLEAR_DEATH_NOTIFICATION,
binder_driver_command_protocol_BC_DEAD_BINDER_DONE,
binder_driver_command_protocol_BC_DECREFS, binder_driver_command_protocol_BC_ENTER_LOOPER,
binder_driver_command_protocol_BC_FREE_BUFFER, binder_driver_command_protocol_BC_INCREFS,
binder_driver_command_protocol_BC_INCREFS_DONE,
binder_driver_command_protocol_BC_REGISTER_LOOPER,
binder_driver_command_protocol_BC_RELEASE, binder_driver_command_protocol_BC_REPLY,
binder_driver_command_protocol_BC_REPLY_SG,
binder_driver_command_protocol_BC_REQUEST_DEATH_NOTIFICATION,
binder_driver_command_protocol_BC_TRANSACTION,
binder_driver_command_protocol_BC_TRANSACTION_SG, binder_driver_return_protocol,
binder_driver_return_protocol_BR_ACQUIRE,
binder_driver_return_protocol_BR_CLEAR_DEATH_NOTIFICATION_DONE,
binder_driver_return_protocol_BR_DEAD_BINDER, binder_driver_return_protocol_BR_DEAD_REPLY,
binder_driver_return_protocol_BR_DECREFS, binder_driver_return_protocol_BR_ERROR,
binder_driver_return_protocol_BR_FAILED_REPLY, binder_driver_return_protocol_BR_INCREFS,
binder_driver_return_protocol_BR_RELEASE, binder_driver_return_protocol_BR_REPLY,
binder_driver_return_protocol_BR_SPAWN_LOOPER,
binder_driver_return_protocol_BR_TRANSACTION,
binder_driver_return_protocol_BR_TRANSACTION_COMPLETE,
binder_driver_return_protocol_BR_TRANSACTION_SEC_CTX, binder_fd_array_object,
binder_object_header, binder_transaction_data,
binder_transaction_data__bindgen_ty_2__bindgen_ty_1, binder_transaction_data_sg,
binder_uintptr_t, binder_version, binder_write_read,
errno::{errno, errno_from_code, error},
flat_binder_object, mode, pid_t, release_after, release_on_error, statfs,
struct_with_union_into_bytes, transaction_flags_TF_ONE_WAY, uapi, ArcKey, DeviceType,
Errno, OpenFlags, OwnedRef, Releasable, ReleaseGuard, TempRef, TempRefKey, UserAddress,
UserBuffer, UserRef, WeakRef, BINDERFS_SUPER_MAGIC, BINDER_BUFFER_FLAG_HAS_PARENT,
BINDER_CURRENT_PROTOCOL_VERSION, BINDER_TYPE_BINDER, BINDER_TYPE_FD, BINDER_TYPE_FDA,
BINDER_TYPE_HANDLE, BINDER_TYPE_PTR, EINTR,
},
};
use derivative::Derivative;
use fidl::endpoints::ClientEnd;
Expand Down Expand Up @@ -4190,6 +4224,11 @@ pub mod tests {
fs::FdFlags,
mm::{MemoryAccessor, PAGE_SIZE},
testing::*,
types::{
binder_transaction_data__bindgen_ty_1, binder_transaction_data__bindgen_ty_2,
errno::{EBADF, EINVAL},
BINDER_TYPE_WEAK_HANDLE,
},
};
use assert_matches::assert_matches;
use fidl::endpoints::{create_endpoints, RequestStream, ServerEnd};
Expand Down
18 changes: 13 additions & 5 deletions src/starnix/kernel/device/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ use crate::{
device::{framebuffer::Framebuffer, DeviceMode},
fs::{
buffers::{InputBuffer, OutputBuffer},
fileops_impl_nonseekable,
kobject::{KObjectDeviceAttribute, KType},
sysfs::SysFsDirectory,
*,
FdEvents, FileObject, FileOps, FsNode,
},
logging::*,
logging::{log_info, log_warn, not_implemented},
mm::MemoryAccessorExt,
syscalls::*,
syscalls::{SyscallArg, SyscallResult, SUCCESS},
task::{CurrentTask, EventHandler, Kernel, WaitCanceler, WaitQueue, Waiter},
types::*,
types::{
errno::{error, Errno},
timeval, timeval_from_time, uapi, DeviceType, OpenFlags, UserAddress, UserRef, ABS_CNT,
ABS_X, ABS_Y, BTN_MISC, BTN_TOOL_FINGER, BTN_TOUCH, BUS_VIRTUAL, FF_CNT, INPUT_MAJOR,
INPUT_PROP_CNT, INPUT_PROP_DIRECT, KEYBOARD_INPUT_MINOR, KEY_CNT, KEY_POWER, LED_CNT,
MSC_CNT, REL_CNT, SW_CNT, TOUCH_INPUT_MINOR,
},
};

use fidl::endpoints::Proxy as _; // for `on_closed()`
Expand Down Expand Up @@ -875,9 +882,10 @@ mod test {

use super::*;
use crate::{
fs::buffers::VecOutputBuffer,
fs::{buffers::VecOutputBuffer, FileHandle},
task::Kernel,
testing::{create_kernel_and_task, map_memory, AutoReleasableTask},
types::errno::EAGAIN,
};
use anyhow::anyhow;
use assert_matches::assert_matches;
Expand Down
6 changes: 3 additions & 3 deletions src/starnix/kernel/device/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use crate::{
fs::{kobject::*, sysfs::SysFsDirectory, FileOps, FsNode},
logging::log_error,
task::*,
types::*,
task::CurrentTask,
types::{errno, error, DeviceType, Errno, OpenFlags, DYN_MAJOR},
};

use starnix_lock::{Mutex, RwLock};
Expand Down Expand Up @@ -330,7 +330,7 @@ impl DeviceOps for Arc<RwLock<DynRegistry>> {
#[cfg(test)]
mod tests {
use super::*;
use crate::{device::mem::DevNull, fs::*, testing::*};
use crate::{device::mem::DevNull, fs::*, testing::*, types::MEM_MAJOR};

#[::fuchsia::test]
fn registry_fails_to_add_duplicate_device() {
Expand Down
6 changes: 5 additions & 1 deletion src/starnix/kernel/task/abstract_socket_namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ use std::{
sync::{Arc, Weak},
};

use crate::{fs::socket::*, task::CurrentTask, types::*};
use crate::{
fs::socket::{Socket, SocketAddress, SocketHandle},
task::CurrentTask,
types::{errno, error, Errno},
};

/// A registry of abstract sockets.
///
Expand Down
9 changes: 6 additions & 3 deletions src/starnix/kernel/task/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::{
fs::{
devtmpfs::devtmpfs_create_device,
inotify::InotifyLimits,
kobject::*,
kobject::{KObjectDeviceAttribute, KType, UEventAction},
socket::{
GenericMessage, GenericNetlink, NetlinkSenderReceiverProvider, NetlinkToClientSender,
SocketAddress,
Expand All @@ -43,8 +43,11 @@ use crate::{
logging::log_error,
mm::{FutexTable, SharedFutexKey},
power::PowerManager,
task::*,
types::{DeviceType, Errno, OpenFlags, *},
task::{
AbstractUnixSocketNamespace, AbstractVsockSocketNamespace, CurrentTask, IpTables,
KernelThreads, NetstackDevices, PidTable, StopState, UtsNamespace, UtsNamespaceHandle,
},
types::{errno, from_status_like_fdio, DeviceType, Errno, OpenFlags},
vdso::vdso_loader::Vdso,
};

Expand Down
65 changes: 40 additions & 25 deletions src/starnix/kernel/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,57 @@ pub mod range_ext;
pub mod signals;
pub mod uapi;

pub(crate) use union::*;
pub(crate) use union::struct_with_union_into_bytes;

pub use arc_key::*;
pub use auth::*;
pub use device_type::*;
pub use errno::*;
pub use file_mode::*;
pub use mount_flags::*;
pub use open_flags::*;
pub use ownership::*;
pub use personality::*;
pub use resource_limits::*;
pub use seal_flags::*;
pub use signals::*;
pub use stats::*;
pub use time::*;
pub use arc_key::{ArcKey, PtrKey, WeakKey};
pub use device_type::{
DeviceType, DYN_MAJOR, INPUT_MAJOR, KEYBOARD_INPUT_MINOR, LOOP_MAJOR, MEM_MAJOR,
TOUCH_INPUT_MINOR, TTY_ALT_MAJOR,
};
pub(crate) use file_mode::mode;
pub use file_mode::{Access, FileMode};
pub use mount_flags::MountFlags;
pub use open_flags::OpenFlags;
pub(crate) use ownership::{async_release_after, release_after, release_on_error};
pub use ownership::{
debug_assert_no_local_temp_ref, OwnedRef, OwnedRefByRef, Releasable, ReleasableByRef,
ReleaseGuard, TempRef, TempRefKey, WeakRef,
};
pub use personality::PersonalityFlags;
pub use resource_limits::{Resource, ResourceLimits};
pub use seal_flags::SealFlags;
pub use stats::TaskTimeStats;
pub use time::{
duration_from_poll_timeout, duration_from_timespec, duration_from_timeval,
duration_to_scheduler_clock, itimerspec_from_deadline_interval, time_from_timespec,
timespec_from_duration, timespec_from_time, timespec_is_zero, timeval_from_duration,
timeval_from_time, NANOS_PER_SECOND, SCHEDULER_CLOCK_HZ,
};
pub use uapi::*;
pub use user_address::*;
pub use user_buffer::*;

// Manually export names that are ambiguous between the name below and the one defined in uapi.
pub use auth::{
CAP_CHOWN, CAP_DAC_OVERRIDE, CAP_DAC_READ_SEARCH, CAP_FOWNER, CAP_FSETID, CAP_KILL,
CAP_LINUX_IMMUTABLE, CAP_MAC_OVERRIDE, CAP_MKNOD, CAP_NET_ADMIN, CAP_NET_RAW, CAP_SETGID,
CAP_SETPCAP, CAP_SETUID, CAP_SYS_ADMIN, CAP_SYS_BOOT, CAP_SYS_CHROOT, CAP_SYS_NICE,
CAP_SYS_PTRACE, CAP_SYS_RESOURCE, CAP_WAKE_ALARM,
Capabilities, PtraceAccessMode, CAP_CHOWN, CAP_DAC_OVERRIDE, CAP_DAC_READ_SEARCH, CAP_FOWNER,
CAP_FSETID, CAP_KILL, CAP_LINUX_IMMUTABLE, CAP_MAC_OVERRIDE, CAP_MKNOD, CAP_NET_ADMIN,
CAP_NET_RAW, CAP_SETGID, CAP_SETPCAP, CAP_SETUID, CAP_SYS_ADMIN, CAP_SYS_BOOT, CAP_SYS_CHROOT,
CAP_SYS_NICE, CAP_SYS_PTRACE, CAP_SYS_RESOURCE, CAP_WAKE_ALARM, PTRACE_MODE_ATTACH_REALCREDS,
PTRACE_MODE_FSCREDS, PTRACE_MODE_REALCREDS,
};

pub(crate) use crate::types::errno::{
errno, errno_from_code, errno_from_zxio_code, error, from_status_like_fdio,
};
pub use errno::{
EACCES, EAGAIN, EBADF, EEXIST, EINPROGRESS, EINTR, EINVAL, ENAMETOOLONG, ENOENT, ENOSPC,
ENOSYS, ENOTDIR, EPERM, ETIMEDOUT,
Errno, ErrnoCode, ErrnoResultExt, SourceContext, EACCES, EAGAIN, EBADF, EEXIST, EINPROGRESS,
EINTR, EINVAL, ENAMETOOLONG, ENOENT, ENOSPC, ENOSYS, ENOTDIR, EPERM, ERESTART, ERESTARTNOHAND,
ERESTARTNOINTR, ERESTARTSYS, ERESTART_RESTARTBLOCK, ETIMEDOUT,
};

pub use signals::{
SIGABRT, SIGALRM, SIGBUS, SIGCHLD, SIGCONT, SIGFPE, SIGHUP, SIGILL, SIGINT, SIGIO, SIGKILL,
SIGPIPE, SIGPROF, SIGPWR, SIGQUIT, SIGRTMIN, SIGSEGV, SIGSTKFLT, SIGSTOP, SIGSYS, SIGTERM,
SIGTRAP, SIGTSTP, SIGTTIN, SIGTTOU, SIGURG, SIGUSR1, SIGUSR2, SIGVTALRM, SIGWINCH, SIGXCPU,
SIGXFSZ,
SigSet, Signal, UncheckedSignal, SIGABRT, SIGALRM, SIGBUS, SIGCHLD, SIGCONT, SIGFPE, SIGHUP,
SIGILL, SIGINT, SIGIO, SIGKILL, SIGPIPE, SIGPROF, SIGPWR, SIGQUIT, SIGRTMIN, SIGSEGV,
SIGSTKFLT, SIGSTOP, SIGSYS, SIGTERM, SIGTRAP, SIGTSTP, SIGTTIN, SIGTTOU, SIGURG, SIGUSR1,
SIGUSR2, SIGVTALRM, SIGWINCH, SIGXCPU, SIGXFSZ, UNBLOCKABLE_SIGNALS,
};

0 comments on commit b7ee22c

Please sign in to comment.