// * This file is part of the uutils coreutils package.
+// *
+// * For the full copyright and license information, please view the LICENSE
+// * file that was distributed with this source code.
+//! Provides a summary representation of a filesystem.
+//!
+//! A [`Filesystem`] struct represents a device containing a
+//! filesystem mounted at a particular directory. It also includes
+//! information on amount of space available and amount of space used.
+#[cfg(windows)]
+usestd::path::Path;
+
+#[cfg(unix)]
+useuucore::fsext::statfs;
+useuucore::fsext::{FsUsage, MountInfo};
+
+/// Summary representation of a filesystem.
+///
+/// A [`Filesystem`] struct represents a device containing a
+/// filesystem mounted at a particular directory. The
+/// [`Filesystem::mount_info`] field exposes that information. The
+/// [`Filesystem::usage`] field provides information on the amount of
+/// space available on the filesystem and the amount of space used.
+#[derive(Debug, Clone)]
+pub(crate) structFilesystem {
+ /// Information about the mounted device, mount directory, and related options.
+ pubmount_info: MountInfo,
+
+ /// Information about the amount of space used on the filesystem.
+ pubusage: FsUsage,
+}
+
+implFilesystem {
+ // TODO: resolve uuid in `mount_info.dev_name` if exists
+ pub(crate) fnnew(mount_info: MountInfo) -> Option<Self> {
+ let_stat_path=if!mount_info.mount_dir.is_empty() {
+ mount_info.mount_dir.clone()
+ } else {
+ #[cfg(unix)]
+ {
+ mount_info.dev_name.clone()
+ }
+ #[cfg(windows)]
+ {
+ // On windows, we expect the volume id
+ mount_info.dev_id.clone()
+ }
+ };
+ #[cfg(unix)]
+ letusage=FsUsage::new(statfs(_stat_path).ok()?);
+ #[cfg(windows)]
+ letusage=FsUsage::new(Path::new(&_stat_path));
+ Some(Self { mount_info, usage })
+ }
+}
+
+
+
\ No newline at end of file
diff --git a/dev/src/uu_df/table.rs.html b/dev/src/uu_df/table.rs.html
index 40828131f..fa7890db2 100644
--- a/dev/src/uu_df/table.rs.html
+++ b/dev/src/uu_df/table.rs.html
@@ -585,6 +585,7 @@
583584585
+586
// * This file is part of the uutils coreutils package.// *// * For the full copyright and license information, please view the LICENSE
@@ -599,7 +600,8 @@
usenumber_prefix::NumberPrefix;
usecrate::columns::Column;
-usecrate::{BlockSize, Filesystem, Options};
+usecrate::filesystem::Filesystem;
+usecrate::{BlockSize, Options};
useuucore::fsext::{FsUsage, MountInfo};
usestd::fmt;
diff --git a/dev/src/uu_nproc/nproc.rs.html b/dev/src/uu_nproc/nproc.rs.html
index 07a2ee5c4..cf7bd8a22 100644
--- a/dev/src/uu_nproc/nproc.rs.html
+++ b/dev/src/uu_nproc/nproc.rs.html
@@ -152,8 +152,8 @@
pubfnuumain(args: impluucore::Args) -> UResult<()> {
letmatches=uu_app().get_matches_from(args);
- letmutignore=matchmatches.value_of(OPT_IGNORE) {
- Some(numstr) => matchnumstr.parse() {
+ letignore=matchmatches.value_of(OPT_IGNORE) {
+ Some(numstr) => matchnumstr.trim().parse() {
Ok(num) => num,
Err(e) => {
returnErr(USimpleError::new(
@@ -165,18 +165,18 @@
None => 0,
};
- if!matches.is_present(OPT_ALL) {
- // OMP_NUM_THREADS doesn't have an impact on --all
- ignore+=matchenv::var("OMP_NUM_THREADS") {
- Ok(threadstr) => threadstr.parse().unwrap_or(0),
- Err(_) => 0,
- };
- }
-
letmutcores=ifmatches.is_present(OPT_ALL) {
num_cpus_all()
} else {
- num_cpus::get()
+ // OMP_NUM_THREADS doesn't have an impact on --all
+ matchenv::var("OMP_NUM_THREADS") {
+ // Uses the OpenMP variable to force the number of threads
+ // If the parsing fails, returns the number of CPU
+ Ok(threadstr) => threadstr.parse().unwrap_or_else(|_|num_cpus::get()),
+ // the variable 'OMP_NUM_THREADS' doesn't exit
+ // fallback to the regular CPU detection
+ Err(_) => num_cpus::get(),
+ }
};
ifcores<=ignore {
diff --git a/dev/uu_df/fn.uu_app.html b/dev/uu_df/fn.uu_app.html
index b24fd3442..120536b1a 100644
--- a/dev/uu_df/fn.uu_app.html
+++ b/dev/uu_df/fn.uu_app.html
@@ -1,4 +1,4 @@
uu_app in uu_df - Rust
\ No newline at end of file
diff --git a/dev/uu_df/fn.uumain.html b/dev/uu_df/fn.uumain.html
index 7dd2e345c..a7ccdeceb 100644
--- a/dev/uu_df/fn.uumain.html
+++ b/dev/uu_df/fn.uumain.html
@@ -1,4 +1,4 @@
uumain in uu_df - Rust
\ No newline at end of file
diff --git a/dev/uu_df/index.html b/dev/uu_df/index.html
index 3f6002772..35370422e 100644
--- a/dev/uu_df/index.html
+++ b/dev/uu_df/index.html
@@ -1,5 +1,5 @@
uu_df - Rust