Repository: GuillaumeGomez/sysinfo
Pull request #1292 (2024-06-25 18:53:56)

Add `disk` feature
Part of https://github.com/GuillaumeGomez/sysinfo/issues/965.


Patch:
diff --git a/.cirrus.yml b/.cirrus.yml
index 4483e58..5c93bf8 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -13,6 +13,9 @@ task:
     - cargo check
     - RUSTFLAGS=-Dwarnings cargo check --no-default-features
     - RUSTFLAGS=-Dwarnings cargo check --no-default-features --features system
+    - RUSTFLAGS=-Dwarnings cargo check --no-default-features --features debug,serde,system
+    - RUSTFLAGS=-Dwarnings cargo check --no-default-features --features disk
+    - RUSTFLAGS=-Dwarnings cargo check --no-default-features --features debug,serde,disk
     - cargo clippy -- -D warnings
     - cargo check --example simple
     - FREEBSD_CI=1 cargo test -- --test-threads=1
@@ -33,6 +36,9 @@ task:
     - cargo check
     - RUSTFLAGS=-Dwarnings cargo check --no-default-features
     - RUSTFLAGS=-Dwarnings cargo check --no-default-features --features system
+    - RUSTFLAGS=-Dwarnings cargo check --no-default-features --features debug,serde,system
+    - RUSTFLAGS=-Dwarnings cargo check --no-default-features --features disk
+    - RUSTFLAGS=-Dwarnings cargo check --no-default-features --features debug,serde,disk
     - cargo clippy -- -D warnings
     - cargo check --example simple
     - FREEBSD_CI=1 cargo test -- --test-threads=1
@@ -55,6 +61,9 @@ task:
     - cargo check
     - RUSTFLAGS=-Dwarnings cargo check --no-default-features
     - RUSTFLAGS=-Dwarnings cargo check --no-default-features --features system
+    - RUSTFLAGS=-Dwarnings cargo check --no-default-features --features debug,serde,system
+    - RUSTFLAGS=-Dwarnings cargo check --no-default-features --features disk
+    - RUSTFLAGS=-Dwarnings cargo check --no-default-features --features debug,serde,disk
     - RUSTFLAGS=-Dwarnings cargo check --no-default-features --features apple-sandbox
     - cargo clippy -- -D warnings
     - cargo check --example simple
diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index df5d5f9..bf2227c 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -91,6 +91,27 @@ jobs:
           args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --features=debug
           use-cross: ${{ matrix.triple.cross }}
 
+      - name: Check debug feature
+        uses: ClementTsang/cargo-action@v0.0.6
+        with:
+          command: rustc
+          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features=debug
+          use-cross: ${{ matrix.triple.cross }}
+
+      - name: Check debug feature
+        uses: ClementTsang/cargo-action@v0.0.6
+        with:
+          command: rustc
+          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features=debug,serde,system
+          use-cross: ${{ matrix.triple.cross }}
+
+      - name: Check debug feature
+        uses: ClementTsang/cargo-action@v0.0.6
+        with:
+          command: rustc
+          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features=debug,serde,disk
+          use-cross: ${{ matrix.triple.cross }}
+
       - name: Check without multithreading
         uses: ClementTsang/cargo-action@v0.0.6
         with:
@@ -105,6 +126,13 @@ jobs:
           args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features system
           use-cross: ${{ matrix.triple.cross }}
 
+      - name: Check features
+        uses: ClementTsang/cargo-action@v0.0.6
+        with:
+          command: check
+          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features disk
+          use-cross: ${{ matrix.triple.cross }}
+
       - name: Check example
         uses: ClementTsang/cargo-action@v0.0.6
         with:
diff --git a/Cargo.lock b/Cargo.lock
index 2583e60..429b6a8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -221,7 +221,6 @@ name = "sysinfo"
 version = "0.30.12"
 dependencies = [
  "bstr",
- "cfg-if",
  "core-foundation-sys",
  "libc",
  "memchr",
diff --git a/Cargo.toml b/Cargo.toml
index 0c48c6c..9b87924 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,7 +15,13 @@ edition = "2021"
 name = "sysinfo"
 
 [features]
-default = ["system", "multithread"]
+default = ["disk", "system", "multithread"]
+disk = [
+    "windows/Win32_Storage_FileSystem",
+    "windows/Win32_System_IO",
+    "windows/Win32_System_Ioctl",
+    "windows/Win32_System_WindowsProgramming",
+]
 system = [
     "windows/Wdk_System_SystemInformation",
     "windows/Wdk_System_SystemServices",
@@ -59,7 +65,6 @@ rustdoc-args = ["--generate-link-to-definition"]
 
 [dependencies]
 bstr = "1.9.0"
-cfg-if = "1.0"
 memchr = "2.7.1"
 rayon = { version = "^1.8", optional = true }
 serde = { version = "^1.0.190", optional = true }
@@ -75,13 +80,9 @@ windows = { version = "0.56", features = [
     "Win32_Security",
     "Win32_Security_Authentication_Identity",
     "Win32_Security_Authorization",
-    "Win32_Storage_FileSystem",
     "Win32_System_Com",
-    "Win32_System_IO",
-    "Win32_System_Ioctl",
     "Win32_System_Rpc",
     "Win32_System_Variant",
-    "Win32_System_WindowsProgramming",
     "Win32_System_Wmi",
 ]}
 
diff --git a/src/common/mod.rs b/src/common/mod.rs
index 12e9867..05f2d0b 100644
--- a/src/common/mod.rs
+++ b/src/common/mod.rs
@@ -1,6 +1,7 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
 pub(crate) mod component;
+#[cfg(feature = "disk")]
 pub(crate) mod disk;
 pub(crate) mod network;
 #[cfg(feature = "system")]
@@ -65,7 +66,7 @@ macro_rules! gid {
     };
 }
 
-cfg_if::cfg_if! {
+cfg_if! {
     if #[cfg(all(
         not(feature = "unknown-ci"),
         any(
diff --git a/src/common/system.rs b/src/common/system.rs
index b490724..8485487 100644
--- a/src/common/system.rs
+++ b/src/common/system.rs
@@ -1644,7 +1644,7 @@ impl Process {
     /// }
     /// ```
     pub fn tasks(&self) -> Option<&HashSet<Pid>> {
-        cfg_if::cfg_if! {
+        cfg_if! {
             if #[cfg(all(
                 any(target_os = "linux", target_os = "android"),
                 not(feature = "unknown-ci")
@@ -1673,7 +1673,7 @@ impl Process {
     /// }
     /// ```
     pub fn thread_kind(&self) -> Option<ThreadKind> {
-        cfg_if::cfg_if! {
+        cfg_if! {
             if #[cfg(all(
                 any(target_os = "linux", target_os = "android"),
                 not(feature = "unknown-ci")
@@ -1740,7 +1740,7 @@ macro_rules! pid_decl {
     };
 }
 
-cfg_if::cfg_if! {
+cfg_if! {
     if #[cfg(all(
         not(feature = "unknown-ci"),
         any(
@@ -2303,7 +2303,7 @@ impl RefreshKind {
 /// ```
 #[allow(clippy::unnecessary_wraps)]
 pub fn get_current_pid() -> Result<Pid, &'static str> {
-    cfg_if::cfg_if! {
+    cfg_if! {
         if #[cfg(feature = "unknown-ci")] {
             fn inner() -> Result<Pid, &'static str> {
                 Err("Unknown platform (CI)")
diff --git a/src/debug.rs b/src/debug.rs
index 29567ce..5345fe2 100644
--- a/src/debug.rs
+++ b/src/debug.rs
@@ -1,6 +1,6 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
-use crate::{Component, Components, Disk, Disks, NetworkData, Networks, User, Users};
+use crate::{Component, Components, NetworkData, Networks, User, Users};
 
 use std::fmt;
 
@@ -33,7 +33,8 @@ impl fmt::Debug for crate::System {
     }
 }
 
-impl fmt::Debug for Disk {
+#[cfg(feature = "disk")]
+impl fmt::Debug for crate::Disk {
     fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(
             fmt,
@@ -49,6 +50,13 @@ impl fmt::Debug for Disk {
     }
 }
 
+#[cfg(feature = "disk")]
+impl fmt::Debug for crate::Disks {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        f.debug_list().entries(self.iter()).finish()
+    }
+}
+
 #[cfg(feature = "system")]
 impl fmt::Debug for crate::Process {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -126,12 +134,6 @@ impl fmt::Debug for NetworkData {
     }
 }
 
-impl fmt::Debug for Disks {
-    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_list().entries(self.iter()).finish()
-    }
-}
-
 impl fmt::Debug for Users {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.debug_list().entries(self.iter()).finish()
diff --git a/src/lib.rs b/src/lib.rs
index 71f526d..bb2ad90 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,8 +1,8 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
-#![cfg_attr(feature = "system", doc = include_str!("../README.md"))]
+#![cfg_attr(any(feature = "system", feature = "disk"), doc = include_str!("../README.md"))]
 #![cfg_attr(
-    not(feature = "system"),
+    not(any(feature = "system", feature = "disk")),
     doc = "For crate-level documentation, all features need to be enabled."
 )]
 #![cfg_attr(feature = "serde", doc = include_str!("../md_doc/serde.md"))]
@@ -17,7 +17,7 @@
 #[macro_use]
 mod macros;
 
-cfg_if::cfg_if! {
+cfg_if! {
     if #[cfg(feature = "unknown-ci")] {
         // This is used in CI to check that the build for unknown targets is compiling fine.
         mod unknown;
@@ -56,29 +56,31 @@ cfg_if::cfg_if! {
 
 pub use crate::common::{
     component::{Component, Components},
-    disk::{Disk, DiskKind, Disks},
     network::{IpNetwork, MacAddr, NetworkData, Networks},
     user::{Group, Groups, User, Users},
     Gid, Uid,
 };
 
+#[cfg(feature = "disk")]
+pub use crate::common::disk::{Disk, DiskKind, Disks};
 #[cfg(feature = "system")]
 pub use crate::common::system::{
     get_current_pid, CGroupLimits, Cpu, CpuRefreshKind, DiskUsage, LoadAvg, MemoryRefreshKind, Pid,
     Process, ProcessRefreshKind, ProcessStatus, RefreshKind, Signal, System, ThreadKind,
     UpdateKind,
 };
+#[cfg(feature = "system")]
+pub use crate::sys::{MINIMUM_CPU_UPDATE_INTERVAL, SUPPORTED_SIGNALS};
 
 pub(crate) use crate::common::user::GroupInner;
 pub use crate::sys::IS_SUPPORTED_SYSTEM;
 pub(crate) use crate::sys::{
-    ComponentInner, ComponentsInner, DiskInner, DisksInner, NetworkDataInner, NetworksInner,
-    UserInner,
+    ComponentInner, ComponentsInner, NetworkDataInner, NetworksInner, UserInner,
 };
 #[cfg(feature = "system")]
 pub(crate) use crate::sys::{CpuInner, ProcessInner, SystemInner};
-#[cfg(feature = "system")]
-pub use crate::sys::{MINIMUM_CPU_UPDATE_INTERVAL, SUPPORTED_SIGNALS};
+#[cfg(feature = "disk")]
+pub(crate) use crate::sys::{DiskInner, DisksInner};
 
 #[cfg(feature = "c-interface")]
 pub use crate::c_interface::*;
@@ -116,7 +118,7 @@ pub(crate) mod utils;
 /// let s = System::new_all();
 /// ```
 pub fn set_open_files_limit(mut _new_limit: isize) -> bool {
-    cfg_if::cfg_if! {
+    cfg_if! {
         if #[cfg(all(feature = "system", not(feature = "unknown-ci"), any(target_os = "linux", target_os = "android")))]
         {
             use crate::sys::system::remaining_files;
@@ -177,6 +179,14 @@ use sysinfo::", stringify!($imports), r";
         ThreadKind,
         UpdateKind,
     );
+
+    #[cfg(not(feature = "disk"))]
+    compile_fail_import!(
+        no_disk_feature =>
+        Disk,
+        Disks,
+        DiskKind,
+    );
 }
 
 #[cfg(test)]
diff --git a/src/macros.rs b/src/macros.rs
index c2b856a..2b85587 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -90,3 +90,233 @@ macro_rules! retry_eintr {
         }
     }};
 }
+
+//FIXME: Remove this code if https://github.com/rust-lang/cfg-if/pull/78 is ever merged.
+macro_rules! cfg_if {
+    // match if/else chains with a final `else`
+    (
+        $(
+            if #[cfg( $i_meta:meta )] { $( $i_tokens:tt )* }
+        ) else+
+        else { $( $e_tokens:tt )* }
+    ) => {
+        cfg_if! {
+            @__items () ;
+            $(
+                (( $i_meta ) ( $( $i_tokens )* )) ,
+            )+
+            (() ( $( $e_tokens )* )) ,
+        }
+    };
+
+    // Allow to multiple conditions in a same call.
+    (
+        $(
+            if #[cfg( $i_meta:meta )] { $( $i_tokens:tt )* }
+        ) else+
+        else { $( $e_tokens:tt )* }
+        if $($extra_conditions:tt)+
+    ) => {
+        cfg_if! {
+            @__items () ;
+            $(
+                (( $i_meta ) ( $( $i_tokens )* )) ,
+            )+
+            (() ( $( $e_tokens )* )) ,
+        }
+        cfg_if! {
+            if $($extra_conditions)+
+        }
+    };
+
+    // match if/else chains lacking a final `else`
+    (
+        if #[cfg( $i_meta:meta )] { $( $i_tokens:tt )* }
+        $(
+            else if #[cfg( $e_meta:meta )] { $( $e_tokens:tt )* }
+        )*
+    ) => {
+        cfg_if! {
+            @__items () ;
+            (( $i_meta ) ( $( $i_tokens )* )) ,
+            $(
+                (( $e_meta ) ( $( $e_tokens )* )) ,
+            )*
+        }
+    };
+
+    // Allow to multiple conditions in a same call.
+    (
+        if #[cfg( $i_meta:meta )] { $( $i_tokens:tt )* }
+        $(
+            else if #[cfg( $e_meta:meta )] { $( $e_tokens:tt )* }
+        )*
+        if $($extra_conditions:tt)+
+    ) => {
+        cfg_if! {
+            @__items () ;
+            (( $i_meta ) ( $( $i_tokens )* )) ,
+            $(
+                (( $e_meta ) ( $( $e_tokens )* )) ,
+            )*
+        }
+        cfg_if! {
+            if $($extra_conditions)+
+        }
+    };
+
+    // Internal and recursive macro to emit all the items
+    //
+    // Collects all the previous cfgs in a list at the beginning, so they can be
+    // negated. After the semicolon is all the remaining items.
+    (@__items ( $( $_:meta , )* ) ; ) => {};
+    (
+        @__items ( $( $no:meta , )* ) ;
+        (( $( $yes:meta )? ) ( $( $tokens:tt )* )) ,
+        $( $rest:tt , )*
+    ) => {
+        // Emit all items within one block, applying an appropriate #[cfg]. The
+        // #[cfg] will require all `$yes` matchers specified and must also negate
+        // all previous matchers.
+        #[cfg(all(
+            $( $yes , )?
+            not(any( $( $no ),* ))
+        ))]
+        cfg_if! { @__identity $( $tokens )* }
+
+        // Recurse to emit all other items in `$rest`, and when we do so add all
+        // our `$yes` matchers to the list of `$no` matchers as future emissions
+        // will have to negate everything we just matched as well.
+        cfg_if! {
+            @__items ( $( $no , )* $( $yes , )? ) ;
+            $( $rest , )*
+        }
+    };
+
+    // Internal macro to make __apply work out right for different match types,
+    // because of how macros match/expand stuff.
+    (@__identity $( $tokens:tt )* ) => {
+        $( $tokens )*
+    };
+}
+
+#[cfg(test)]
+#[allow(unexpected_cfgs)]
+mod tests {
+    cfg_if! {
+        if #[cfg(test)] {
+            use core::option::Option as Option2;
+            fn works1() -> Option2<u32> { Some(1) }
+        } else {
+            fn works1() -> Option<u32> { None }
+        }
+    }
+
+    cfg_if! {
+        if #[cfg(foo)] {
+            fn works2() -> bool { false }
+        } else if #[cfg(test)] {
+            fn works2() -> bool { true }
+        } else {
+            fn works2() -> bool { false }
+        }
+    }
+
+    cfg_if! {
+        if #[cfg(foo)] {
+            fn works3() -> bool { false }
+        } else {
+            fn works3() -> bool { true }
+        }
+    }
+
+    cfg_if! {
+        if #[cfg(test)] {
+            use core::option::Option as Option3;
+            fn works4() -> Option3<u32> { Some(1) }
+        }
+    }
+
+    cfg_if! {
+        if #[cfg(foo)] {
+            fn works5() -> bool { false }
+        } else if #[cfg(test)] {
+            fn works5() -> bool { true }
+        }
+    }
+
+    cfg_if! {
+        if #[cfg(foo)] {
+            fn works6() -> bool { false }
+        } else if #[cfg(test)] {
+            fn works6() -> bool { true }
+        }
+        if #[cfg(test)] {
+            fn works7() -> bool { true }
+        } else {
+            fn works7() -> bool { false }
+        }
+    }
+
+    cfg_if! {
+        if #[cfg(test)] {
+            fn works8() -> bool { true }
+        } else if #[cfg(foo)] {
+            fn works8() -> bool { false }
+        }
+        if #[cfg(foo)] {
+            fn works9() -> bool { false }
+        } else if #[cfg(test)] {
+            fn works9() -> bool { true }
+        }
+    }
+
+    #[test]
+    fn it_works() {
+        assert!(works1().is_some());
+        assert!(works2());
+        assert!(works3());
+        assert!(works4().is_some());
+        assert!(works5());
+        assert!(works6());
+        assert!(works7());
+        assert!(works8());
+        assert!(works9());
+    }
+
+    #[test]
+    #[allow(clippy::assertions_on_constants)]
+    fn test_usage_within_a_function() {
+        cfg_if! {if #[cfg(debug_assertions)] {
+            // we want to put more than one thing here to make sure that they
+            // all get configured properly.
+            assert!(cfg!(debug_assertions));
+            assert_eq!(4, 2+2);
+        } else {
+            assert!(works1().is_some());
+            assert_eq!(10, 5+5);
+        }}
+    }
+
+    #[allow(dead_code)]
+    trait Trait {
+        fn blah(&self);
+    }
+
+    #[allow(dead_code)]
+    struct Struct;
+
+    impl Trait for Struct {
+        cfg_if! {
+            if #[cfg(feature = "blah")] {
+                fn blah(&self) {
+                    unimplemented!();
+                }
+            } else {
+                fn blah(&self) {
+                    unimplemented!();
+                }
+            }
+        }
+    }
+}
diff --git a/src/serde.rs b/src/serde.rs
index daef35f..8d62ceb 100644
--- a/src/serde.rs
+++ b/src/serde.rs
@@ -2,6 +2,7 @@
 
 use serde::{ser::SerializeStruct, Serialize, Serializer};
 
+#[cfg(feature = "disk")]
 impl Serialize for crate::Disk {
     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     where
@@ -24,6 +25,36 @@ impl Serialize for crate::Disk {
     }
 }
 
+#[cfg(feature = "disk")]
+impl Serialize for crate::Disks {
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+    where
+        S: Serializer,
+    {
+        serializer.collect_seq(self.iter())
+    }
+}
+
+#[cfg(feature = "disk")]
+impl Serialize for crate::DiskKind {
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+    where
+        S: Serializer,
+    {
+        let (index, variant, maybe_value) = match *self {
+            Self::HDD => (0, "HDD", None),
+            Self::SSD => (1, "SSD", None),
+            Self::Unknown(ref s) => (2, "Unknown", Some(s)),
+        };
+
+        if let Some(ref value) = maybe_value {
+            serializer.serialize_newtype_variant("DiskKind", index, variant, value)
+        } else {
+            serializer.serialize_unit_variant("DiskKind", index, variant)
+        }
+    }
+}
+
 impl Serialize for crate::Gid {
     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     where
@@ -138,6 +169,7 @@ impl serde::Serialize for crate::System {
     }
 }
 
+#[cfg(feature = "system")]
 impl Serialize for crate::CGroupLimits {
     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     where
@@ -163,15 +195,6 @@ impl Serialize for crate::Networks {
     }
 }
 
-impl Serialize for crate::Disks {
-    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
-    where
-        S: Serializer,
-    {
-        serializer.collect_seq(self.iter())
-    }
-}
-
 impl Serialize for crate::Components {
     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     where
@@ -190,6 +213,7 @@ impl Serialize for crate::Users {
     }
 }
 
+#[cfg(feature = "system")]
 impl Serialize for crate::ThreadKind {
     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     where
@@ -204,6 +228,7 @@ impl Serialize for crate::ThreadKind {
     }
 }
 
+#[cfg(feature = "system")]
 impl Serialize for crate::Signal {
     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     where
@@ -248,6 +273,7 @@ impl Serialize for crate::Signal {
     }
 }
 
+#[cfg(feature = "system")]
 impl Serialize for crate::LoadAvg {
     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     where
@@ -345,25 +371,7 @@ impl Serialize for crate::Group {
     }
 }
 
-impl Serialize for crate::DiskKind {
-    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
-    where
-        S: Serializer,
-    {
-        let (index, variant, maybe_value) = match *self {
-            Self::HDD => (0, "HDD", None),
-            Self::SSD => (1, "SSD", None),
-            Self::Unknown(ref s) => (2, "Unknown", Some(s)),
-        };
-
-        if let Some(ref value) = maybe_value {
-            serializer.serialize_newtype_variant("DiskKind", index, variant, value)
-        } else {
-            serializer.serialize_unit_variant("DiskKind", index, variant)
-        }
-    }
-}
-
+#[cfg(feature = "system")]
 impl Serialize for crate::ProcessStatus {
     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     where
@@ -393,6 +401,7 @@ impl Serialize for crate::ProcessStatus {
     }
 }
 
+#[cfg(feature = "system")]
 impl Serialize for crate::DiskUsage {
     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     where
diff --git a/src/unix/apple/ffi.rs b/src/unix/apple/ffi.rs
index f659680..615e63f 100644
--- a/src/unix/apple/ffi.rs
+++ b/src/unix/apple/ffi.rs
@@ -1,31 +1,35 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
-use core_foundation_sys::{
-    array::CFArrayRef, dictionary::CFDictionaryRef, error::CFErrorRef, string::CFStringRef,
-    url::CFURLRef,
-};
-
 // Reexport items defined in either macos or ios ffi module.
 #[cfg(not(target_os = "ios"))]
 pub use crate::sys::inner::ffi::*;
 
-#[link(name = "CoreFoundation", kind = "framework")]
-extern "C" {
-    pub fn CFURLCopyResourcePropertiesForKeys(
-        url: CFURLRef,
-        keys: CFArrayRef,
-        error: *mut CFErrorRef,
-    ) -> CFDictionaryRef;
+cfg_if! {
+    if #[cfg(feature = "disk")] {
+        use core_foundation_sys::{
+            array::CFArrayRef, dictionary::CFDictionaryRef, error::CFErrorRef, string::CFStringRef,
+            url::CFURLRef,
+        };
+
+        #[link(name = "CoreFoundation", kind = "framework")]
+        extern "C" {
+            pub fn CFURLCopyResourcePropertiesForKeys(
+                url: CFURLRef,
+                keys: CFArrayRef,
+                error: *mut CFErrorRef,
+            ) -> CFDictionaryRef;
 
-    pub static kCFURLVolumeIsEjectableKey: CFStringRef;
-    pub static kCFURLVolumeIsRemovableKey: CFStringRef;
-    pub static kCFURLVolumeAvailableCapacityKey: CFStringRef;
-    pub static kCFURLVolumeAvailableCapacityForImportantUsageKey: CFStringRef;
-    pub static kCFURLVolumeTotalCapacityKey: CFStringRef;
-    pub static kCFURLVolumeNameKey: CFStringRef;
-    pub static kCFURLVolumeIsLocalKey: CFStringRef;
-    pub static kCFURLVolumeIsInternalKey: CFStringRef;
-    pub static kCFURLVolumeIsBrowsableKey: CFStringRef;
+            pub static kCFURLVolumeIsEjectableKey: CFStringRef;
+            pub static kCFURLVolumeIsRemovableKey: CFStringRef;
+            pub static kCFURLVolumeAvailableCapacityKey: CFStringRef;
+            pub static kCFURLVolumeAvailableCapacityForImportantUsageKey: CFStringRef;
+            pub static kCFURLVolumeTotalCapacityKey: CFStringRef;
+            pub static kCFURLVolumeNameKey: CFStringRef;
+            pub static kCFURLVolumeIsLocalKey: CFStringRef;
+            pub static kCFURLVolumeIsInternalKey: CFStringRef;
+            pub static kCFURLVolumeIsBrowsableKey: CFStringRef;
+        }
+    }
 }
 
 #[cfg_attr(feature = "debug", derive(Eq, Hash, PartialEq))]
diff --git a/src/unix/apple/macos/ffi.rs b/src/unix/apple/macos/ffi.rs
index 7385e72..70a2de2 100644
--- a/src/unix/apple/macos/ffi.rs
+++ b/src/unix/apple/macos/ffi.rs
@@ -1,46 +1,64 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
-use core_foundation_sys::base::{mach_port_t, CFAllocatorRef};
-use core_foundation_sys::dictionary::{CFDictionaryRef, CFMutableDictionaryRef};
+use core_foundation_sys::base::CFAllocatorRef;
+#[cfg(any(feature = "system", feature = "disk", target_arch = "x86", target_arch = "x86_64"))]
+use core_foundation_sys::base::mach_port_t;
+#[cfg(any(feature = "system", feature = "disk"))]
+use core_foundation_sys::dictionary::CFDictionaryRef;
+#[cfg(any(feature = "system", feature = "disk", target_arch = "x86", target_arch = "x86_64"))]
+use core_foundation_sys::dictionary::CFMutableDictionaryRef;
 use core_foundation_sys::string::CFStringRef;
 
-use libc::{c_char, kern_return_t};
+use libc::c_char;
+#[cfg(any(feature = "system", feature = "disk", target_arch = "x86", target_arch = "x86_64"))]
+use libc::kern_return_t;
 
 // Note: IOKit is only available on MacOS up until very recent iOS versions: https://developer.apple.com/documentation/iokit
 
+#[cfg(any(feature = "system", feature = "disk", target_arch = "x86", target_arch = "x86_64"))]
 #[allow(non_camel_case_types)]
 pub type io_object_t = mach_port_t;
 
+#[cfg(any(feature = "system", feature = "disk", target_arch = "x86", target_arch = "x86_64"))]
 #[allow(non_camel_case_types)]
 pub type io_iterator_t = io_object_t;
+#[cfg(any(feature = "system", feature = "disk"))]
 #[allow(non_camel_case_types)]
 pub type io_registry_entry_t = io_object_t;
 // This is a hack, `io_name_t` should normally be `[c_char; 128]` but Rust makes it very annoying
 // to deal with that so we go around it a bit.
 #[allow(non_camel_case_types, dead_code)]
 pub type io_name = [c_char; 128];
+#[cfg(any(feature = "system", feature = "disk"))]
 #[allow(non_camel_case_types)]
 pub type io_name_t = *const c_char;
 
+#[cfg(any(feature = "system", feature = "disk"))]
 pub type IOOptionBits = u32;
 
-#[allow(non_upper_case_globals)]
-pub const kIOServicePlane: &[u8] = b"IOService\0";
-#[allow(non_upper_case_globals)]
-pub const kIOPropertyDeviceCharacteristicsKey: &str = "Device Characteristics";
-#[allow(non_upper_case_globals)]
-pub const kIOPropertyMediumTypeKey: &str = "Medium Type";
-#[allow(non_upper_case_globals)]
-pub const kIOPropertyMediumTypeSolidStateKey: &str = "Solid State";
-#[allow(non_upper_case_globals)]
-pub const kIOPropertyMediumTypeRotationalKey: &str = "Rotational";
+cfg_if! {
+    if #[cfg(feature = "disk")] {
+        #[allow(non_upper_case_globals)]
+        pub const kIOServicePlane: &[u8] = b"IOService\0";
+        #[allow(non_upper_case_globals)]
+        pub const kIOPropertyDeviceCharacteristicsKey: &str = "Device Characteristics";
+        #[allow(non_upper_case_globals)]
+        pub const kIOPropertyMediumTypeKey: &str = "Medium Type";
+        #[allow(non_upper_case_globals)]
+        pub const kIOPropertyMediumTypeSolidStateKey: &str = "Solid State";
+        #[allow(non_upper_case_globals)]
+        pub const kIOPropertyMediumTypeRotationalKey: &str = "Rotational";
+    }
+}
 
 // Based on https://github.com/libusb/libusb/blob/bed8d3034eac74a6e1ba123b5c270ea63cb6cf1a/libusb/os/darwin_usb.c#L54-L55,
 // we can simply set it to 0 (and is the same value as its replacement `kIOMainPortDefault`).
 #[allow(non_upper_case_globals)]
+#[cfg(any(feature = "system", feature = "disk", target_arch = "x86", target_arch = "x86_64"))]
 pub const kIOMasterPortDefault: mach_port_t = 0;
 
 // Note: Obtaining information about disks using IOKIt is allowed inside the default macOS App Sandbox.
+#[cfg(any(feature = "system", feature = "disk", target_arch = "x86", target_arch = "x86_64"))]
 #[link(name = "IOKit", kind = "framework")]
 extern "C" {
     pub fn IOServiceGetMatchingServices(
@@ -48,34 +66,37 @@ extern "C" {
         matching: CFMutableDictionaryRef,
         existing: *mut io_iterator_t,
     ) -> kern_return_t;
-    #[allow(dead_code)]
+    #[cfg(any(feature = "system", target_arch = "x86", target_arch = "x86_64"))]
     pub fn IOServiceMatching(a: *const c_char) -> CFMutableDictionaryRef;
 
     pub fn IOIteratorNext(iterator: io_iterator_t) -> io_object_t;
 
     pub fn IOObjectRelease(obj: io_object_t) -> kern_return_t;
 
+    #[cfg(any(feature = "system", feature = "disk"))]
     pub fn IORegistryEntryCreateCFProperty(
         entry: io_registry_entry_t,
         key: CFStringRef,
         allocator: CFAllocatorRef,
         options: IOOptionBits,
     ) -> CFDictionaryRef;
+    #[cfg(feature = "disk")]
     pub fn IORegistryEntryGetParentEntry(
         entry: io_registry_entry_t,
         plane: io_name_t,
         parent: *mut io_registry_entry_t,
     ) -> kern_return_t;
-    #[allow(dead_code)]
-    pub fn IORegistryEntryGetName(entry: io_registry_entry_t, name: io_name_t) -> kern_return_t;
-
+    #[cfg(feature = "disk")]
     pub fn IOBSDNameMatching(
         mainPort: mach_port_t,
         options: u32,
         bsdName: *const c_char,
     ) -> CFMutableDictionaryRef;
+    #[cfg(feature = "system")]
+    pub fn IORegistryEntryGetName(entry: io_registry_entry_t, name: io_name_t) -> kern_return_t;
 }
-#[allow(dead_code)]
+
+#[cfg(any(feature = "system", target_arch = "x86", target_arch = "x86_64"))]
 pub const KIO_RETURN_SUCCESS: i32 = 0;
 
 extern "C" {
diff --git a/src/unix/apple/macos/mod.rs b/src/unix/apple/macos/mod.rs
index 694bf4f..d3823b8 100644
--- a/src/unix/apple/macos/mod.rs
+++ b/src/unix/apple/macos/mod.rs
@@ -1,23 +1,34 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
-pub mod disk;
 pub mod ffi;
-pub(crate) mod utils;
 
-#[cfg(all(feature = "system", not(feature = "apple-sandbox")))]
-pub(crate) mod cpu;
+cfg_if! {
+    if #[cfg(all(feature = "system", not(feature = "apple-sandbox")))] {
+        pub(crate) mod cpu;
+        pub mod system;
+        pub mod process;
+    }
+    if #[cfg(all(feature = "system", feature = "apple-sandbox"))] {
+        pub use crate::sys::app_store::process;
+    }
 
-#[cfg(all(feature = "system", not(feature = "apple-sandbox")))]
-pub mod system;
+    if #[cfg(any(
+            feature = "system",
+            feature = "disk",
+            target_arch = "x86",
+            target_arch = "x86_64",
+        ))]
+    {
+        pub(crate) mod utils;
+    }
 
-#[cfg(not(feature = "apple-sandbox"))]
-pub mod component;
+    if #[cfg(feature = "disk")] {
+        pub mod disk;
+    }
 
-#[cfg(all(feature = "system", not(feature = "apple-sandbox")))]
-pub mod process;
-
-#[cfg(feature = "apple-sandbox")]
-pub use crate::sys::app_store::component;
-
-#[cfg(all(feature = "system", feature = "apple-sandbox"))]
-pub use crate::sys::app_store::process;
+    if #[cfg(feature = "apple-sandbox")] {
+        pub use crate::sys::app_store::component;
+    } else {
+        pub mod component;
+    }
+}
diff --git a/src/unix/apple/macos/utils.rs b/src/unix/apple/macos/utils.rs
index ff870db..f527f47 100644
--- a/src/unix/apple/macos/utils.rs
+++ b/src/unix/apple/macos/utils.rs
@@ -11,6 +11,7 @@ impl IOReleaser {
         IoObject::new(obj).map(Self)
     }
 
+    #[cfg(feature = "disk")]
     pub(crate) unsafe fn new_unchecked(obj: u32) -> Self {
         // Chance at catching in-development mistakes
         debug_assert_ne!(obj, 0);
diff --git a/src/unix/apple/mod.rs b/src/unix/apple/mod.rs
index 1678237..93d3e6b 100644
--- a/src/unix/apple/mod.rs
+++ b/src/unix/apple/mod.rs
@@ -4,14 +4,13 @@
 pub(crate) mod app_store;
 
 pub mod component;
-pub mod disk;
 mod ffi;
 pub mod groups;
 pub mod network;
 pub mod users;
 mod utils;
 
-cfg_if::cfg_if! {
+cfg_if! {
     if #[cfg(target_os = "macos")] {
         pub(crate) mod macos;
         pub(crate) use self::macos as inner;
@@ -21,7 +20,7 @@ cfg_if::cfg_if! {
     }
 }
 
-cfg_if::cfg_if! {
+cfg_if! {
     if #[cfg(feature = "system")] {
         pub mod cpu;
         pub mod process;
@@ -32,14 +31,18 @@ cfg_if::cfg_if! {
         pub(crate) use self::system::SystemInner;
         pub use self::system::{MINIMUM_CPU_UPDATE_INTERVAL, SUPPORTED_SIGNALS};
     }
+    if #[cfg(feature = "disk")] {
+        pub mod disk;
+
+        pub(crate) use self::disk::DiskInner;
+        pub(crate) use crate::unix::DisksInner;
+    }
 }
 
 pub(crate) use self::component::{ComponentInner, ComponentsInner};
-pub(crate) use self::disk::DiskInner;
 pub(crate) use self::network::{NetworkDataInner, NetworksInner};
 pub(crate) use crate::unix::groups::get_groups;
 pub(crate) use crate::unix::users::{get_users, UserInner};
-pub(crate) use crate::unix::DisksInner;
 
 #[doc = include_str!("../../../md_doc/is_supported.md")]
 pub const IS_SUPPORTED_SYSTEM: bool = true;
diff --git a/src/unix/apple/utils.rs b/src/unix/apple/utils.rs
index 72e8499..dc7b28b 100644
--- a/src/unix/apple/utils.rs
+++ b/src/unix/apple/utils.rs
@@ -7,8 +7,10 @@ use std::ptr::NonNull;
 // More information about the ownership policy for CoreFoundation pelease refer the link below:
 // https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html#//apple_ref/doc/uid/20001148-CJBEJBHH
 #[repr(transparent)]
+#[allow(dead_code)]
 pub(crate) struct CFReleaser<T>(NonNull<T>);
 
+#[allow(dead_code)]
 impl<T> CFReleaser<T> {
     pub(crate) fn new(ptr: *const T) -> Option<Self> {
         // This cast is OK because `NonNull` is a transparent wrapper
@@ -34,6 +36,7 @@ impl<T> Drop for CFReleaser<T> {
 unsafe impl<T> Send for CFReleaser<T> {}
 unsafe impl<T> Sync for CFReleaser<T> {}
 
+#[cfg(feature = "disk")]
 pub(crate) fn vec_to_rust(buf: Vec<i8>) -> Option<String> {
     String::from_utf8(
         buf.into_iter()
diff --git a/src/unix/freebsd/disk.rs b/src/unix/freebsd/disk.rs
index aac1be0..c65eb7b 100644
--- a/src/unix/freebsd/disk.rs
+++ b/src/unix/freebsd/disk.rs
@@ -123,7 +123,7 @@ pub unsafe fn get_all_list(container: &mut Vec<Disk>) {
             | b"linsysfs" => {
                 sysinfo_debug!(
                     "Memory filesystem `{:?}`, ignoring it.",
-                    c_buf_to_str(&fs_info.f_fstypename).unwrap(),
+                    c_buf_to_utf8_str(&fs_info.f_fstypename).unwrap(),
                 );
                 continue;
             }
diff --git a/src/unix/freebsd/mod.rs b/src/unix/freebsd/mod.rs
index 8ab692f..c6f02ee 100644
--- a/src/unix/freebsd/mod.rs
+++ b/src/unix/freebsd/mod.rs
@@ -1,11 +1,10 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
 pub mod component;
-pub mod disk;
 pub mod network;
 mod utils;
 
-cfg_if::cfg_if! {
+cfg_if! {
     if #[cfg(feature = "system")] {
         pub mod cpu;
         pub mod process;
@@ -16,14 +15,18 @@ cfg_if::cfg_if! {
         pub(crate) use self::system::SystemInner;
         pub use self::system::{MINIMUM_CPU_UPDATE_INTERVAL, SUPPORTED_SIGNALS};
     }
+    if #[cfg(feature = "disk")] {
+        pub mod disk;
+
+        pub(crate) use self::disk::DiskInner;
+        pub(crate) use crate::unix::DisksInner;
+    }
 }
 
 pub(crate) use self::component::{ComponentInner, ComponentsInner};
-pub(crate) use self::disk::DiskInner;
 pub(crate) use self::network::{NetworkDataInner, NetworksInner};
 pub(crate) use crate::unix::groups::get_groups;
 pub(crate) use crate::unix::users::{get_users, UserInner};
-pub(crate) use crate::unix::DisksInner;
 
 #[doc = include_str!("../../../md_doc/is_supported.md")]
 pub const IS_SUPPORTED_SYSTEM: bool = true;
diff --git a/src/unix/linux/mod.rs b/src/unix/linux/mod.rs
index 6eabccc..e1c42c0 100644
--- a/src/unix/linux/mod.rs
+++ b/src/unix/linux/mod.rs
@@ -1,11 +1,10 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
 pub mod component;
-pub mod disk;
 pub mod network;
 pub(crate) mod utils;
 
-cfg_if::cfg_if! {
+cfg_if! {
     if #[cfg(feature = "system")] {
         pub mod cpu;
         pub mod process;
@@ -16,14 +15,18 @@ cfg_if::cfg_if! {
         pub(crate) use self::system::SystemInner;
         pub use self::system::{MINIMUM_CPU_UPDATE_INTERVAL, SUPPORTED_SIGNALS};
     }
+    if #[cfg(feature = "disk")] {
+        pub mod disk;
+
+        pub(crate) use self::disk::DiskInner;
+        pub(crate) use crate::unix::DisksInner;
+    }
 }
 
 pub(crate) use self::component::{ComponentInner, ComponentsInner};
-pub(crate) use self::disk::DiskInner;
 pub(crate) use self::network::{NetworkDataInner, NetworksInner};
 pub(crate) use crate::unix::groups::get_groups;
 pub(crate) use crate::unix::users::{get_users, UserInner};
-pub(crate) use crate::unix::DisksInner;
 
 #[doc = include_str!("../../../md_doc/is_supported.md")]
 pub const IS_SUPPORTED_SYSTEM: bool = true;
diff --git a/src/unix/mod.rs b/src/unix/mod.rs
index 95dfe31..e712b15 100644
--- a/src/unix/mod.rs
+++ b/src/unix/mod.rs
@@ -1,6 +1,6 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
-cfg_if::cfg_if! {
+cfg_if! {
     if #[cfg(any(target_os = "macos", target_os = "ios"))] {
         pub(crate) mod apple;
         pub(crate) use apple as sys;
@@ -22,23 +22,25 @@ cfg_if::cfg_if! {
     } else {
         compile_error!("Invalid cfg!");
     }
+
+    if #[cfg(feature = "disk")] {
+        pub(crate) struct DisksInner {
+            pub(crate) disks: Vec<crate::Disk>,
+        }
+
+        impl DisksInner {
+            pub(crate) fn from_vec(disks: Vec<crate::Disk>) -> Self {
+                Self { disks }
+            }
+
+            pub(crate) fn into_vec(self) -> Vec<crate::Disk> {
+                self.disks
+            }
+        }
+    }
 }
 
 pub(crate) mod groups;
 pub(crate) mod network_helper;
 pub(crate) mod users;
 pub(crate) mod utils;
-
-pub(crate) struct DisksInner {
-    pub(crate) disks: Vec<crate::Disk>,
-}
-
-impl DisksInner {
-    pub(crate) fn from_vec(disks: Vec<crate::Disk>) -> Self {
-        Self { disks }
-    }
-
-    pub(crate) fn into_vec(self) -> Vec<crate::Disk> {
-        self.disks
-    }
-}
diff --git a/src/unknown/mod.rs b/src/unknown/mod.rs
index f8fe1f8..5931e46 100644
--- a/src/unknown/mod.rs
+++ b/src/unknown/mod.rs
@@ -1,12 +1,11 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
 pub mod component;
-pub mod disk;
 pub mod groups;
 pub mod network;
 pub mod users;
 
-cfg_if::cfg_if! {
+cfg_if! {
     if #[cfg(feature = "system")] {
         pub mod cpu;
         pub mod process;
@@ -17,10 +16,15 @@ cfg_if::cfg_if! {
         pub(crate) use self::system::SystemInner;
         pub use self::system::{MINIMUM_CPU_UPDATE_INTERVAL, SUPPORTED_SIGNALS};
     }
+
+    if #[cfg(feature = "disk")] {
+        pub mod disk;
+
+        pub(crate) use self::disk::{DiskInner, DisksInner};
+    }
 }
 
 pub(crate) use self::component::{ComponentInner, ComponentsInner};
-pub(crate) use self::disk::{DiskInner, DisksInner};
 pub(crate) use self::groups::get_groups;
 pub(crate) use self::network::{NetworkDataInner, NetworksInner};
 pub(crate) use self::users::{get_users, UserInner};
diff --git a/src/windows/cpu.rs b/src/windows/cpu.rs
index 1830bd2..1507d26 100644
--- a/src/windows/cpu.rs
+++ b/src/windows/cpu.rs
@@ -21,10 +21,10 @@ use windows::Win32::System::Performance::{
 use windows::Win32::System::Power::{
     CallNtPowerInformation, ProcessorInformation, PROCESSOR_POWER_INFORMATION,
 };
-use windows::Win32::System::SystemInformation::{self, GetSystemInfo};
+use windows::Win32::System::SystemInformation;
 use windows::Win32::System::SystemInformation::{
-    GetLogicalProcessorInformationEx, RelationAll, RelationProcessorCore, SYSTEM_INFO,
-    SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX,
+    GetLogicalProcessorInformationEx, GetSystemInfo, RelationAll, RelationProcessorCore,
+    SYSTEM_INFO, SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX,
 };
 use windows::Win32::System::Threading::{
     CreateEventA, RegisterWaitForSingleObject, INFINITE, WT_EXECUTEDEFAULT,
diff --git a/src/windows/mod.rs b/src/windows/mod.rs
index aba1736..f7a25d7 100644
--- a/src/windows/mod.rs
+++ b/src/windows/mod.rs
@@ -1,12 +1,11 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
 mod component;
-mod disk;
 mod groups;
 mod network;
 pub(crate) mod network_helper;
 
-cfg_if::cfg_if! {
+cfg_if! {
     if #[cfg(feature = "system")] {
         mod process;
         mod cpu;
@@ -17,6 +16,11 @@ cfg_if::cfg_if! {
         pub(crate) use self::system::SystemInner;
         pub use self::system::{MINIMUM_CPU_UPDATE_INTERVAL, SUPPORTED_SIGNALS};
     }
+    if #[cfg(feature = "disk")] {
+        mod disk;
+
+        pub(crate) use self::disk::{DiskInner, DisksInner};
+    }
 }
 
 mod sid;
@@ -24,7 +28,6 @@ mod users;
 mod utils;
 
 pub(crate) use self::component::{ComponentInner, ComponentsInner};
-pub(crate) use self::disk::{DiskInner, DisksInner};
 pub(crate) use self::groups::get_groups;
 pub(crate) use self::network::{NetworkDataInner, NetworksInner};
 pub(crate) use self::sid::Sid;
diff --git a/src/windows/system.rs b/src/windows/system.rs
index 0ebb6e7..d593837 100644
--- a/src/windows/system.rs
+++ b/src/windows/system.rs
@@ -24,7 +24,7 @@ use windows::Win32::System::ProcessStatus::{K32GetPerformanceInfo, PERFORMANCE_I
 use windows::Win32::System::Registry::{
     RegCloseKey, RegOpenKeyExW, RegQueryValueExW, HKEY, HKEY_LOCAL_MACHINE, KEY_READ, REG_NONE,
 };
-use windows::Win32::System::SystemInformation::{self, GetSystemInfo};
+use windows::Win32::System::SystemInformation;
 use windows::Win32::System::SystemInformation::{
     ComputerNamePhysicalDnsHostname, GetComputerNameExW, GetTickCount64, GlobalMemoryStatusEx,
     MEMORYSTATUSEX, SYSTEM_INFO,
@@ -493,8 +493,7 @@ impl SystemInner {
     pub(crate) fn cpu_arch() -> Option<String> {
         unsafe {
             // https://docs.microsoft.com/fr-fr/windows/win32/api/sysinfoapi/ns-sysinfoapi-system_info
-            let mut info = SYSTEM_INFO::default();
-            GetSystemInfo(&mut info);
+            let info = SYSTEM_INFO::default();
             match info.Anonymous.Anonymous.wProcessorArchitecture {
                 SystemInformation::PROCESSOR_ARCHITECTURE_ALPHA => Some("alpha".to_string()),
                 SystemInformation::PROCESSOR_ARCHITECTURE_ALPHA64 => Some("alpha64".to_string()),
diff --git a/src/windows/utils.rs b/src/windows/utils.rs
index e45db59..95ca6e8 100644
--- a/src/windows/utils.rs
+++ b/src/windows/utils.rs
@@ -1,8 +1,9 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
 use std::ops::Deref;
-use windows::core::{PCWSTR, PWSTR};
+use windows::core::PWSTR;
 use windows::Win32::Foundation::{CloseHandle, HANDLE};
+#[cfg(feature = "disk")]
 use windows::Win32::Storage::FileSystem::{
     CreateFileW, FILE_ACCESS_RIGHTS, FILE_SHARE_READ, FILE_SHARE_WRITE, OPEN_EXISTING,
 };
@@ -30,11 +31,12 @@ impl HandleWrapper {
         }
     }
 
+    #[cfg(feature = "disk")]
     pub(crate) unsafe fn new_from_file(
         drive_name: &[u16],
         open_rights: FILE_ACCESS_RIGHTS,
     ) -> Option<Self> {
-        let lpfilename = PCWSTR::from_raw(drive_name.as_ptr());
+        let lpfilename = windows::core::PCWSTR::from_raw(drive_name.as_ptr());
         let handle = CreateFileW(
             lpfilename,
             open_rights.0,


Test patch:
diff --git a/tests/disk_list.rs b/tests/disk_list.rs
index f0649f5..9ddaefb 100644
--- a/tests/disk_list.rs
+++ b/tests/disk_list.rs
@@ -1,7 +1,7 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
 #[test]
-#[cfg(feature = "system")]
+#[cfg(all(feature = "system", feature = "disk"))]
 fn test_disks() {
     if sysinfo::IS_SUPPORTED_SYSTEM {
         let s = sysinfo::System::new_all();