Răsfoiți Sursa

remove(bindgen): move all the used constants to `kernel::constants`

greatbridf 8 luni în urmă
părinte
comite
262b76ad95

+ 0 - 209
Cargo.lock

@@ -13,15 +13,6 @@ dependencies = [
  "log",
 ]
 
-[[package]]
-name = "aho-corasick"
-version = "1.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
-dependencies = [
- "memchr",
-]
-
 [[package]]
 name = "arch"
 version = "0.1.0"
@@ -50,26 +41,6 @@ version = "1.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
 
-[[package]]
-name = "bindgen"
-version = "0.70.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f49d8fed880d473ea71efb9bf597651e77201bdd4893efe54c9e5d65ae04ce6f"
-dependencies = [
- "bitflags",
- "cexpr",
- "clang-sys",
- "itertools",
- "log",
- "prettyplease",
- "proc-macro2",
- "quote",
- "regex",
- "rustc-hash",
- "shlex",
- "syn",
-]
-
 [[package]]
 name = "bit_field"
 version = "0.10.2"
@@ -90,32 +61,12 @@ dependencies = [
  "intrusive_list",
 ]
 
-[[package]]
-name = "cexpr"
-version = "0.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
-dependencies = [
- "nom",
-]
-
 [[package]]
 name = "cfg-if"
 version = "1.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
 
-[[package]]
-name = "clang-sys"
-version = "1.8.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
-dependencies = [
- "glob",
- "libc",
- "libloading",
-]
-
 [[package]]
 name = "either"
 version = "1.13.0"
@@ -226,7 +177,6 @@ dependencies = [
  "acpi",
  "arch",
  "atomic_unique_refcell",
- "bindgen",
  "bitflags",
  "buddy_allocator",
  "eonix_hal",
@@ -245,12 +195,6 @@ dependencies = [
  "slab_allocator",
 ]
 
-[[package]]
-name = "glob"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
-
 [[package]]
 name = "intrusive-collections"
 version = "0.9.7"
@@ -273,34 +217,12 @@ dependencies = [
  "either",
 ]
 
-[[package]]
-name = "libc"
-version = "0.2.164"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f"
-
-[[package]]
-name = "libloading"
-version = "0.8.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
-dependencies = [
- "cfg-if",
- "windows-targets",
-]
-
 [[package]]
 name = "log"
 version = "0.4.22"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
 
-[[package]]
-name = "memchr"
-version = "2.7.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
-
 [[package]]
 name = "memoffset"
 version = "0.9.1"
@@ -310,22 +232,6 @@ dependencies = [
  "autocfg",
 ]
 
-[[package]]
-name = "minimal-lexical"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
-
-[[package]]
-name = "nom"
-version = "7.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
-dependencies = [
- "memchr",
- "minimal-lexical",
-]
-
 [[package]]
 name = "pointers"
 version = "0.1.0"
@@ -334,16 +240,6 @@ version = "0.1.0"
 name = "posix_types"
 version = "0.1.0"
 
-[[package]]
-name = "prettyplease"
-version = "0.2.25"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033"
-dependencies = [
- "proc-macro2",
- "syn",
-]
-
 [[package]]
 name = "proc-macro2"
 version = "1.0.92"
@@ -362,47 +258,6 @@ dependencies = [
  "proc-macro2",
 ]
 
-[[package]]
-name = "regex"
-version = "1.11.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
-dependencies = [
- "aho-corasick",
- "memchr",
- "regex-automata",
- "regex-syntax",
-]
-
-[[package]]
-name = "regex-automata"
-version = "0.4.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
-dependencies = [
- "aho-corasick",
- "memchr",
- "regex-syntax",
-]
-
-[[package]]
-name = "regex-syntax"
-version = "0.8.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
-
-[[package]]
-name = "rustc-hash"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
-
-[[package]]
-name = "shlex"
-version = "1.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
-
 [[package]]
 name = "slab_allocator"
 version = "0.1.0"
@@ -428,67 +283,3 @@ name = "unicode-ident"
 version = "1.0.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
-
-[[package]]
-name = "windows-targets"
-version = "0.52.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
-dependencies = [
- "windows_aarch64_gnullvm",
- "windows_aarch64_msvc",
- "windows_i686_gnu",
- "windows_i686_gnullvm",
- "windows_i686_msvc",
- "windows_x86_64_gnu",
- "windows_x86_64_gnullvm",
- "windows_x86_64_msvc",
-]
-
-[[package]]
-name = "windows_aarch64_gnullvm"
-version = "0.52.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
-
-[[package]]
-name = "windows_aarch64_msvc"
-version = "0.52.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
-
-[[package]]
-name = "windows_i686_gnu"
-version = "0.52.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
-
-[[package]]
-name = "windows_i686_gnullvm"
-version = "0.52.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
-
-[[package]]
-name = "windows_i686_msvc"
-version = "0.52.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
-
-[[package]]
-name = "windows_x86_64_gnu"
-version = "0.52.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
-
-[[package]]
-name = "windows_x86_64_gnullvm"
-version = "0.52.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
-
-[[package]]
-name = "windows_x86_64_msvc"
-version = "0.52.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"

+ 0 - 3
Cargo.toml

@@ -38,9 +38,6 @@ log_trace = ["trace_syscall", "trace_scheduler"]
 log_debug = []
 smp = []
 
-[build-dependencies]
-bindgen = "0.70.1"
-
 [profile.dev]
 panic = "abort"
 

+ 1 - 33
build.rs

@@ -1,33 +1 @@
-use std::{
-    io::{stderr, Write},
-    path::PathBuf,
-};
-
-fn main() {
-    let headers = ["rust-headers.hpp"];
-
-    let bindings = bindgen::Builder::default()
-        .use_core()
-        .ctypes_prefix("core::ffi")
-        .headers(headers)
-        .clang_arg("-I./gblibc/include")
-        .clang_arg("-std=c++20")
-        .opaque_type("std::.*")
-        .enable_cxx_namespaces()
-        .parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
-        .generate()
-        .expect("Unable to generate bindings");
-
-    let out_path = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
-    let out = bindings.write_to_file(out_path.join("src/bindings.rs"));
-
-    if let Err(err) = out {
-        writeln!(
-            stderr().lock(),
-            "out_dir = {}",
-            out_path.as_path().display()
-        )
-        .unwrap();
-        Result::<(), _>::Err(err).expect("Couldn't write bindings!");
-    }
-}
+fn main() {}

+ 1 - 1
src/driver/ahci/command.rs

@@ -1,4 +1,4 @@
-use super::bindings::EINVAL;
+use crate::kernel::constants::EINVAL;
 use crate::kernel::mem::paging::Page;
 use crate::prelude::*;
 

+ 1 - 2
src/driver/ahci/mod.rs

@@ -3,14 +3,13 @@ use crate::{
     io::Buffer as _,
     kernel::{
         block::{make_device, BlockDevice},
-        constants::EINVAL,
+        constants::{EINVAL, EIO},
         interrupt::register_irq_handler,
         pcie::{self, Header, PCIDevice, PCIDriver, PciError},
     },
     prelude::*,
 };
 use alloc::{format, sync::Arc};
-use bindings::EIO;
 use control::AdapterControl;
 use defs::*;
 use eonix_mm::address::{AddrOps as _, PAddr};

+ 1 - 1
src/driver/ahci/port.rs

@@ -6,11 +6,11 @@ use super::{
 };
 use crate::driver::ahci::command_table::CommandTable;
 use crate::kernel::block::{BlockDeviceRequest, BlockRequestQueue};
+use crate::kernel::constants::{EINVAL, EIO};
 use crate::kernel::mem::paging::Page;
 use crate::kernel::mem::AsMemoryBlock as _;
 use crate::prelude::*;
 use alloc::collections::vec_deque::VecDeque;
-use bindings::{EINVAL, EIO};
 use core::pin::pin;
 use eonix_mm::address::{Addr as _, PAddr};
 use eonix_runtime::task::Task;

+ 0 - 4
src/driver/e1000e.rs

@@ -1,17 +1,13 @@
 // use crate::prelude::*;
 //
-// use crate::bindings::root::kernel::hw::pci;
 // use crate::kernel::interrupt::register_irq_handler;
 // use crate::kernel::mem::{paging, phys};
 // use crate::net::netdev;
 // use alloc::boxed::Box;
 // use alloc::vec::Vec;
-// use bindings::EFAULT;
 // use paging::Page;
 // use phys::{NoCachePP, PhysPtr};
 //
-// use crate::bindings::root::{EAGAIN, EINVAL, EIO};
-//
 // mod defs;
 //
 // #[repr(C)]

+ 1 - 1
src/fs/fat32.rs

@@ -1,6 +1,7 @@
 mod dir;
 mod file;
 
+use crate::kernel::constants::EIO;
 use crate::{
     io::{Buffer, ByteBuffer, UninitBuffer},
     kernel::{
@@ -23,7 +24,6 @@ use alloc::{
     sync::{Arc, Weak},
     vec::Vec,
 };
-use bindings::EIO;
 use core::{ops::ControlFlow, sync::atomic::Ordering};
 use dir::Dirs as _;
 use eonix_runtime::task::Task;

+ 2 - 3
src/fs/fat32/dir.rs

@@ -1,10 +1,9 @@
+use super::file::ClusterReadIterator;
+use crate::kernel::constants::EINVAL;
 use crate::prelude::*;
-
 use alloc::{string::String, sync::Arc};
 use itertools::Itertools;
 
-use super::{bindings::EINVAL, file::ClusterReadIterator};
-
 #[repr(C, packed)]
 pub(super) struct RawDirEntry {
     name: [u8; 8],

+ 1 - 1
src/fs/procfs.rs

@@ -1,3 +1,4 @@
+use crate::kernel::constants::{EACCES, ENOTDIR};
 use crate::{
     io::Buffer,
     kernel::{
@@ -14,7 +15,6 @@ use crate::{
     prelude::*,
 };
 use alloc::sync::{Arc, Weak};
-use bindings::{EACCES, ENOTDIR};
 use core::{ops::ControlFlow, sync::atomic::Ordering};
 use eonix_runtime::task::Task;
 use eonix_sync::{AsProof as _, AsProofMut as _, LazyLock, Locked};

+ 1 - 1
src/fs/tmpfs.rs

@@ -1,3 +1,4 @@
+use crate::kernel::constants::{EINVAL, EIO, EISDIR};
 use crate::{
     io::Buffer,
     kernel::constants::{S_IFBLK, S_IFCHR, S_IFDIR, S_IFLNK, S_IFREG},
@@ -12,7 +13,6 @@ use crate::{
     prelude::*,
 };
 use alloc::sync::{Arc, Weak};
-use bindings::{EINVAL, EIO, EISDIR};
 use core::{ops::ControlFlow, sync::atomic::Ordering};
 use eonix_runtime::task::Task;
 use eonix_sync::{AsProof as _, AsProofMut as _, Locked, ProofMut};

+ 1 - 3
src/io.rs

@@ -1,5 +1,5 @@
+use crate::kernel::constants::EFAULT;
 use crate::prelude::*;
-use bindings::EFAULT;
 use core::{cmp, mem::MaybeUninit};
 
 #[must_use]
@@ -191,7 +191,6 @@ impl Buffer for ByteBuffer<'_> {
 ///
 /// The iterator returns a tuple of (start, len) for each chunk.
 pub struct Chunks {
-    start: usize,
     end: usize,
     cur: usize,
     chunk_len: usize,
@@ -200,7 +199,6 @@ pub struct Chunks {
 impl Chunks {
     pub const fn new(start: usize, total_len: usize, chunk_len: usize) -> Self {
         Self {
-            start,
             end: start + total_len,
             cur: start,
             chunk_len,

+ 1 - 1
src/kernel/block.rs

@@ -3,6 +3,7 @@ use super::{
     mem::{paging::Page, AsMemoryBlock as _},
     vfs::DevId,
 };
+use crate::kernel::constants::{EEXIST, EINVAL, EIO};
 use crate::{
     io::{Buffer, FillResult, UninitBuffer},
     prelude::*,
@@ -11,7 +12,6 @@ use alloc::{
     collections::btree_map::{BTreeMap, Entry},
     sync::Arc,
 };
-use bindings::{EEXIST, EINVAL, EIO};
 use core::cmp::Ordering;
 
 pub fn make_device(major: u32, minor: u32) -> DevId {

+ 64 - 2
src/kernel/constants.rs

@@ -16,26 +16,88 @@ pub const SIG_SETMASK: u32 = 2;
 pub const CLOCK_REALTIME: u32 = 0;
 pub const CLOCK_MONOTONIC: u32 = 1;
 
+pub const EPERM: u32 = 1;
 pub const ENOENT: u32 = 2;
+pub const ESRCH: u32 = 3;
+pub const EINTR: u32 = 4;
 pub const EIO: u32 = 5;
 pub const ENXIO: u32 = 6;
 pub const ENOEXEC: u32 = 8;
+pub const EBADF: u32 = 9;
+pub const ECHILD: u32 = 10;
+pub const ENOMEM: u32 = 12;
+pub const EACCES: u32 = 13;
 pub const EFAULT: u32 = 14;
 pub const EEXIST: u32 = 17;
+pub const ENODEV: u32 = 19;
+pub const ENOTDIR: u32 = 20;
+pub const EISDIR: u32 = 21;
 pub const EINVAL: u32 = 22;
+pub const ENOTTY: u32 = 25;
+pub const ESPIPE: u32 = 29;
+// pub const EROFS: u32 = 30;
+pub const EPIPE: u32 = 32;
+pub const ERANGE: u32 = 34;
 pub const ENOSYS: u32 = 38;
+pub const ELOOP: u32 = 40;
+pub const EOVERFLOW: u32 = 75;
 
-#[allow(dead_code)]
-pub const S_IFIFO: u32 = 0o010000;
+// pub const S_IFIFO: u32 = 0o010000;
 pub const S_IFCHR: u32 = 0o020000;
 pub const S_IFDIR: u32 = 0o040000;
 pub const S_IFBLK: u32 = 0o060000;
 pub const S_IFREG: u32 = 0o100000;
 pub const S_IFLNK: u32 = 0o120000;
+// pub const S_IFSOCK: u32 = 0o140000;
+pub const S_IFMT: u32 = 0o170000;
 
 pub const RLIMIT_STACK: u32 = 0x3;
 
+pub const AT_FDCWD: i32 = -100;
+pub const AT_STATX_SYNC_AS_STAT: u32 = 0;
+pub const AT_SYMLINK_NOFOLLOW: u32 = 0x0100;
+// pub const AT_REMOVEDIR: u32 = 0x0200;
+// pub const AT_SYMLINK_FOLLOW: u32 = 0x0400;
 pub const AT_EMPTY_PATH: u32 = 0x1000;
+// pub const AT_STATX_DONT_SYNC: u32 = 0x2000;
+pub const AT_STATX_SYNC_TYPE: u32 = 0x6000;
+// pub const AT_STATX_SYNC_FORCE: u32 = 0x8000;
+
+pub const SEEK_SET: u32 = 0;
+pub const SEEK_CUR: u32 = 1;
+pub const SEEK_END: u32 = 2;
+
+// pub const O_RDONLY: u32 = 0;
+pub const O_WRONLY: u32 = 1;
+pub const O_RDWR: u32 = 2;
+pub const O_CREAT: u32 = 64;
+pub const O_EXCL: u32 = 128;
+pub const O_TRUNC: u32 = 512;
+pub const O_APPEND: u32 = 1024;
+pub const O_DIRECTORY: u32 = 65536;
+pub const O_CLOEXEC: u32 = 524288;
+
+pub const F_DUPFD: u32 = 0;
+pub const F_GETFD: u32 = 1;
+pub const F_SETFD: u32 = 2;
+// pub const F_GETFL: u32 = 3;
+// pub const F_SETFL: u32 = 4;
+pub const F_DUPFD_CLOEXEC: u32 = 1030;
+pub const FD_CLOEXEC: u32 = 1;
+
+pub const STATX_TYPE: u32 = 1;
+pub const STATX_MODE: u32 = 2;
+pub const STATX_NLINK: u32 = 4;
+pub const STATX_UID: u32 = 8;
+pub const STATX_GID: u32 = 16;
+pub const STATX_ATIME: u32 = 32;
+pub const STATX_MTIME: u32 = 64;
+pub const STATX_CTIME: u32 = 128;
+pub const STATX_INO: u32 = 256;
+pub const STATX_SIZE: u32 = 512;
+pub const STATX_BLOCKS: u32 = 1024;
+// pub const STATX_BASIC_STATS: u32 = 2047;
+// pub const STATX_BTIME: u32 = 2048;
 
 bitflags! {
     #[derive(Debug, Clone, Copy)]

+ 1 - 1
src/kernel/interrupt.rs

@@ -1,7 +1,7 @@
 use super::cpu::local_cpu;
 use super::mem::handle_kernel_page_fault;
 use super::timer::timer_interrupt;
-use crate::bindings::root::EINVAL;
+use crate::kernel::constants::EINVAL;
 use crate::{driver::Port8, prelude::*};
 use alloc::sync::Arc;
 use arch::TrapContext;

+ 1 - 1
src/kernel/mem/mm_list.rs

@@ -6,10 +6,10 @@ use super::address::{VAddrExt as _, VRangeExt as _};
 use super::page_alloc::GlobalPageAlloc;
 use super::paging::{AllocZeroed as _, PageUnmanaged};
 use super::{AsMemoryBlock, MMArea, Page};
+use crate::kernel::constants::{EEXIST, EFAULT, EINVAL, ENOMEM};
 use crate::{prelude::*, sync::ArcSwap};
 use alloc::collections::btree_set::BTreeSet;
 use arch::DefaultPagingMode;
-use bindings::{EEXIST, EFAULT, EINVAL, ENOMEM};
 use core::fmt;
 use core::sync::atomic::{AtomicUsize, Ordering};
 use eonix_mm::address::{Addr as _, PAddr};

+ 41 - 6
src/kernel/syscall/file_rw.rs

@@ -1,3 +1,7 @@
+use crate::kernel::constants::{
+    AT_FDCWD, AT_STATX_SYNC_AS_STAT, AT_STATX_SYNC_TYPE, AT_SYMLINK_NOFOLLOW, EBADF, SEEK_CUR,
+    SEEK_END, SEEK_SET, S_IFBLK, S_IFCHR,
+};
 use crate::{
     io::{Buffer, BufferFill},
     kernel::{
@@ -14,13 +18,44 @@ use crate::{
     path::Path,
     prelude::*,
 };
-use bindings::{
-    statx, AT_FDCWD, AT_STATX_SYNC_AS_STAT, AT_STATX_SYNC_TYPE, AT_SYMLINK_NOFOLLOW, EBADF,
-    SEEK_CUR, SEEK_END, SEEK_SET, S_IFBLK, S_IFCHR,
-};
 use core::mem::MaybeUninit;
 use eonix_runtime::task::Task;
 
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct StatXTimestamp {
+    pub tv_sec: i64,
+    pub tv_nsec: u32,
+    pub __reserved: i32,
+}
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct StatX {
+    pub stx_mask: u32,
+    pub stx_blksize: u32,
+    pub stx_attributes: u64,
+    pub stx_nlink: u32,
+    pub stx_uid: u32,
+    pub stx_gid: u32,
+    pub stx_mode: u16,
+    pub __spare0: [u16; 1usize],
+    pub stx_ino: u64,
+    pub stx_size: u64,
+    pub stx_blocks: u64,
+    pub stx_attributes_mask: u64,
+    pub stx_atime: StatXTimestamp,
+    pub stx_btime: StatXTimestamp,
+    pub stx_ctime: StatXTimestamp,
+    pub stx_mtime: StatXTimestamp,
+    pub stx_rdev_major: u32,
+    pub stx_rdev_minor: u32,
+    pub stx_dev_major: u32,
+    pub stx_dev_minor: u32,
+    pub stx_mnt_id: u64,
+    pub stx_dio_alignment: [u64; 13usize],
+}
+
 #[eonix_macros::define_syscall(0x03)]
 fn read(fd: u32, buffer: *mut u8, bufsize: usize) -> KResult<usize> {
     let mut buffer = UserBuffer::new(buffer, bufsize)?;
@@ -95,8 +130,8 @@ fn statx(dirfd: u32, path: *const u8, flags: u32, mask: u32, buffer: *mut u8) ->
         unimplemented!("AT_STATX_SYNC_TYPE={:x}", flags & AT_STATX_SYNC_TYPE);
     }
 
-    let mut stat: statx = unsafe { MaybeUninit::zeroed().assume_init() };
-    let mut buffer = UserBuffer::new(buffer, core::mem::size_of::<statx>())?;
+    let mut stat: StatX = unsafe { MaybeUninit::zeroed().assume_init() };
+    let mut buffer = UserBuffer::new(buffer, core::mem::size_of::<StatX>())?;
 
     if (flags & AT_EMPTY_PATH) != 0 {
         let file = thread.files.get(dirfd).ok_or(EBADF)?;

+ 1 - 1
src/kernel/syscall/mm.rs

@@ -1,4 +1,5 @@
 use super::FromSyscallArg;
+use crate::kernel::constants::{EINVAL, ENOMEM};
 use crate::{
     kernel::{
         constants::{UserMmapFlags, UserMmapProtocol},
@@ -6,7 +7,6 @@ use crate::{
     },
     prelude::*,
 };
-use bindings::{EINVAL, ENOMEM};
 use eonix_mm::address::{Addr as _, AddrOps as _, VAddr};
 use eonix_runtime::task::Task;
 

+ 1 - 1
src/kernel/syscall/procops.rs

@@ -2,6 +2,7 @@ use super::sysinfo::TimeVal;
 use super::SyscallNoReturn;
 use crate::elf::ParsedElf32;
 use crate::io::Buffer;
+use crate::kernel::constants::{EINVAL, ENOENT, ENOTDIR, ERANGE, ESRCH};
 use crate::kernel::constants::{
     ENOSYS, PR_GET_NAME, PR_SET_NAME, RLIMIT_STACK, SIG_BLOCK, SIG_SETMASK, SIG_UNBLOCK,
 };
@@ -18,7 +19,6 @@ use crate::SIGNAL_NOW;
 use crate::{kernel::user::dataflow::UserBuffer, prelude::*};
 use alloc::borrow::ToOwned;
 use alloc::ffi::CString;
-use bindings::{EINVAL, ENOENT, ENOTDIR, ERANGE, ESRCH};
 use bitflags::bitflags;
 use eonix_hal::traits::trap::RawTrapContext;
 use eonix_mm::address::Addr as _;

+ 1 - 1
src/kernel/task/process.rs

@@ -2,6 +2,7 @@ use super::{
     process_group::ProcessGroupBuilder, signal::RaiseResult, thread::ThreadBuilder, ProcessGroup,
     ProcessList, Session, Signal, Thread,
 };
+use crate::kernel::constants::{ECHILD, EINTR, EPERM, ESRCH};
 use crate::{
     kernel::mem::MMList,
     prelude::*,
@@ -13,7 +14,6 @@ use alloc::{
     collections::{btree_map::BTreeMap, vec_deque::VecDeque},
     sync::{Arc, Weak},
 };
-use bindings::{ECHILD, EINTR, EPERM, ESRCH};
 use core::sync::atomic::{AtomicU32, Ordering};
 use eonix_runtime::task::Task;
 use eonix_sync::{

+ 1 - 1
src/kernel/task/session.rs

@@ -1,10 +1,10 @@
 use super::{Process, ProcessGroup, ProcessList, Signal, Thread};
+use crate::kernel::constants::EPERM;
 use crate::{kernel::Terminal, prelude::*};
 use alloc::{
     collections::btree_map::BTreeMap,
     sync::{Arc, Weak},
 };
-use bindings::EPERM;
 use eonix_sync::{AsProof as _, AsProofMut as _, Locked, Proof, ProofMut, RwLock};
 
 #[derive(Debug)]

+ 1 - 1
src/kernel/task/signal.rs

@@ -3,10 +3,10 @@ mod signal_action;
 mod signal_mask;
 
 use super::{ProcessList, Thread, WaitObject, WaitType};
+use crate::kernel::constants::{EFAULT, EINVAL};
 use crate::{kernel::user::UserPointer, prelude::*};
 use alloc::collections::binary_heap::BinaryHeap;
 use arch::{FpuState, TrapContext};
-use bindings::{EFAULT, EINVAL};
 use core::{cmp::Reverse, task::Waker};
 use eonix_hal::traits::trap::RawTrapContext;
 use eonix_runtime::task::Task;

+ 1 - 1
src/kernel/terminal.rs

@@ -2,12 +2,12 @@ use super::{
     task::{ProcessList, Session, Signal, Thread},
     user::{UserPointer, UserPointerMut},
 };
+use crate::kernel::constants::{EINTR, ENOTTY, EPERM};
 use crate::{io::Buffer, prelude::*, sync::CondVar};
 use alloc::{
     collections::vec_deque::VecDeque,
     sync::{Arc, Weak},
 };
-use bindings::{EINTR, ENOTTY, EPERM};
 use bitflags::bitflags;
 use eonix_log::ConsoleWrite;
 use eonix_runtime::task::Task;

+ 1 - 2
src/kernel/user/dataflow.rs

@@ -1,6 +1,5 @@
+use crate::kernel::constants::{EFAULT, EINVAL};
 use core::{arch::asm, ffi::CStr};
-
-use bindings::{EFAULT, EINVAL};
 use eonix_preempt::assert_preempt_enabled;
 
 use crate::{

+ 5 - 5
src/kernel/vfs/dentry.rs

@@ -4,18 +4,18 @@ use super::{
     inode::{Ino, Inode, Mode, WriteOffset},
     s_isblk, s_ischr, s_isdir, s_isreg, DevId, FsContext,
 };
+use crate::kernel::constants::{
+    EEXIST, EINVAL, EISDIR, ELOOP, ENOENT, ENOTDIR, EPERM, ERANGE, O_CREAT, O_EXCL,
+};
 use crate::{
     hash::KernelHasher,
     io::{Buffer, ByteBuffer},
-    kernel::{block::BlockDevice, CharDevice},
+    kernel::{block::BlockDevice, syscall::file_rw::StatX, CharDevice},
     path::{Path, PathComponent},
     prelude::*,
     rcu::{RCUNode, RCUPointer},
 };
 use alloc::sync::Arc;
-use bindings::{
-    statx, EEXIST, EINVAL, EISDIR, ELOOP, ENOENT, ENOTDIR, EPERM, ERANGE, O_CREAT, O_EXCL,
-};
 use core::{
     fmt,
     hash::{BuildHasher, BuildHasherDefault, Hasher},
@@ -413,7 +413,7 @@ impl Dentry {
         }
     }
 
-    pub fn statx(&self, stat: &mut statx, mask: u32) -> KResult<()> {
+    pub fn statx(&self, stat: &mut StatX, mask: u32) -> KResult<()> {
         self.get_inode()?.statx(stat, mask)
     }
 

+ 1 - 1
src/kernel/vfs/dentry/dcache.rs

@@ -1,11 +1,11 @@
 use super::{Dentry, Inode};
+use crate::kernel::constants::ENOENT;
 use crate::{
     kernel::vfs::{s_isdir, s_islnk},
     prelude::*,
     rcu::{RCUIterator, RCUList},
 };
 use alloc::sync::Arc;
-use bindings::ENOENT;
 use core::sync::atomic::Ordering;
 
 const DCACHE_HASH_BITS: u32 = 8;

+ 5 - 4
src/kernel/vfs/file.rs

@@ -3,6 +3,10 @@ use super::{
     inode::{Mode, WriteOffset},
     s_isblk, s_isdir, s_isreg,
 };
+use crate::kernel::{
+    constants::{EBADF, EFAULT, EINTR, EINVAL, ENOTDIR, ENOTTY, EOVERFLOW, EPIPE, ESPIPE, S_IFMT},
+    syscall::file_rw::StatX,
+};
 use crate::{
     io::{Buffer, BufferFill, ByteBuffer, Chunks},
     kernel::{
@@ -17,9 +21,6 @@ use crate::{
     sync::CondVar,
 };
 use alloc::{collections::vec_deque::VecDeque, sync::Arc};
-use bindings::{
-    statx, EBADF, EFAULT, EINTR, EINVAL, ENOTDIR, ENOTTY, EOVERFLOW, EPIPE, ESPIPE, S_IFMT,
-};
 use bitflags::bitflags;
 use core::{ops::ControlFlow, sync::atomic::Ordering};
 use eonix_runtime::task::Task;
@@ -543,7 +544,7 @@ impl File {
         }
     }
 
-    pub fn statx(&self, buffer: &mut statx, mask: u32) -> KResult<()> {
+    pub fn statx(&self, buffer: &mut StatX, mask: u32) -> KResult<()> {
         match self {
             File::Inode(inode) => inode.dentry.statx(buffer, mask),
             _ => Err(EBADF),

+ 4 - 4
src/kernel/vfs/filearray.rs

@@ -3,6 +3,10 @@ use super::{
     inode::Mode,
     s_ischr, FsContext, Spin,
 };
+use crate::kernel::constants::{
+    EBADF, EISDIR, ENOTDIR, FD_CLOEXEC, F_DUPFD, F_DUPFD_CLOEXEC, F_GETFD, F_SETFD, O_APPEND,
+    O_CLOEXEC, O_DIRECTORY, O_RDWR, O_TRUNC, O_WRONLY,
+};
 use crate::{
     kernel::{
         console::get_console,
@@ -17,10 +21,6 @@ use alloc::{
     collections::btree_map::{BTreeMap, Entry},
     sync::Arc,
 };
-use bindings::{
-    EBADF, EISDIR, ENOTDIR, FD_CLOEXEC, F_DUPFD, F_DUPFD_CLOEXEC, F_GETFD, F_SETFD, O_APPEND,
-    O_CLOEXEC, O_DIRECTORY, O_RDWR, O_TRUNC, O_WRONLY,
-};
 use core::sync::atomic::Ordering;
 use itertools::{
     FoldWhile::{Continue, Done},

+ 6 - 7
src/kernel/vfs/inode.rs

@@ -1,11 +1,10 @@
 use super::{dentry::Dentry, s_isblk, s_ischr, vfs::Vfs, DevId, TimeSpec};
-use crate::{io::Buffer, prelude::*};
-use alloc::sync::{Arc, Weak};
-use bindings::{
-    statx, EINVAL, EISDIR, ENOTDIR, EPERM, STATX_ATIME, STATX_BLOCKS, STATX_CTIME, STATX_GID,
-    STATX_INO, STATX_MODE, STATX_MTIME, STATX_NLINK, STATX_SIZE, STATX_TYPE, STATX_UID, S_IFDIR,
-    S_IFMT,
+use crate::kernel::constants::{
+    EINVAL, EISDIR, ENOTDIR, EPERM, STATX_ATIME, STATX_BLOCKS, STATX_CTIME, STATX_GID, STATX_INO,
+    STATX_MODE, STATX_MTIME, STATX_NLINK, STATX_SIZE, STATX_TYPE, STATX_UID, S_IFDIR, S_IFMT,
 };
+use crate::{io::Buffer, kernel::syscall::file_rw::StatX, prelude::*};
+use alloc::sync::{Arc, Weak};
 use core::{
     mem::MaybeUninit,
     ops::ControlFlow,
@@ -143,7 +142,7 @@ pub trait Inode: Send + Sync + InodeInner {
         Err(EPERM)
     }
 
-    fn statx(&self, stat: &mut statx, mask: u32) -> KResult<()> {
+    fn statx(&self, stat: &mut StatX, mask: u32) -> KResult<()> {
         // Safety: ffi should have checked reference
         let vfs = self.vfs.upgrade().expect("Vfs is dropped");
 

+ 2 - 2
src/kernel/vfs/mod.rs

@@ -1,6 +1,6 @@
+use crate::kernel::constants::{S_IFBLK, S_IFCHR, S_IFDIR, S_IFLNK, S_IFMT, S_IFREG};
 use crate::prelude::*;
 use alloc::sync::Arc;
-use bindings::{dev_t, S_IFBLK, S_IFCHR, S_IFDIR, S_IFLNK, S_IFMT, S_IFREG};
 use dentry::Dentry;
 use eonix_sync::LazyLock;
 use inode::Mode;
@@ -12,7 +12,7 @@ pub mod inode;
 pub mod mount;
 pub mod vfs;
 
-pub type DevId = dev_t;
+pub type DevId = u32;
 
 pub fn s_isreg(mode: Mode) -> bool {
     (mode & S_IFMT) == S_IFREG

+ 1 - 1
src/kernel/vfs/mount.rs

@@ -3,9 +3,9 @@ use super::{
     inode::Inode,
     vfs::Vfs,
 };
+use crate::kernel::constants::{EEXIST, ENODEV, ENOTDIR};
 use crate::prelude::*;
 use alloc::{collections::btree_map::BTreeMap, string::ToString as _, sync::Arc};
-use bindings::{EEXIST, ENODEV, ENOTDIR};
 use eonix_sync::LazyLock;
 
 pub const MS_RDONLY: u64 = 1 << 0;

+ 0 - 2
src/prelude.rs

@@ -12,8 +12,6 @@ macro_rules! dont_check {
 
 pub(crate) use dont_check;
 
-pub use crate::bindings::root as bindings;
-
 pub(crate) use crate::kernel::console::{
     print, println, println_debug, println_fatal, println_info, println_trace, println_warn,
 };