mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-27 15:37:02 +00:00
fix
This commit is contained in:
@@ -8,6 +8,7 @@ use super::{DiskInfo, IOStats};
|
|||||||
|
|
||||||
/// Returns total and free bytes available in a directory, e.g. `/`.
|
/// Returns total and free bytes available in a directory, e.g. `/`.
|
||||||
pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<DiskInfo> {
|
pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<DiskInfo> {
|
||||||
|
let path_display = p.as_ref().display();
|
||||||
let stat_fs = statfs(p.as_ref())?;
|
let stat_fs = statfs(p.as_ref())?;
|
||||||
|
|
||||||
let bsize = stat_fs.block_size() as u64;
|
let bsize = stat_fs.block_size() as u64;
|
||||||
@@ -19,7 +20,7 @@ pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<DiskInfo> {
|
|||||||
Some(reserved) => reserved,
|
Some(reserved) => reserved,
|
||||||
None => {
|
None => {
|
||||||
return Err(Error::other(format!(
|
return Err(Error::other(format!(
|
||||||
"detected f_bavail space ({bavail}) > f_bfree space ({bfree}), fs corruption at ({p.as_ref().display()}). please run 'fsck'"
|
"detected f_bavail space ({bavail}) > f_bfree space ({bfree}), fs corruption at ({path_display}). please run 'fsck'"
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -28,7 +29,7 @@ pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<DiskInfo> {
|
|||||||
Some(total) => total * bsize,
|
Some(total) => total * bsize,
|
||||||
None => {
|
None => {
|
||||||
return Err(Error::other(format!(
|
return Err(Error::other(format!(
|
||||||
"detected reserved space ({reserved}) > blocks space ({blocks}), fs corruption at ({p.as_ref().display()}). please run 'fsck'"
|
"detected reserved space ({reserved}) > blocks space ({blocks}), fs corruption at ({path_display}). please run 'fsck'"
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -38,7 +39,7 @@ pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<DiskInfo> {
|
|||||||
Some(used) => used,
|
Some(used) => used,
|
||||||
None => {
|
None => {
|
||||||
return Err(Error::other(format!(
|
return Err(Error::other(format!(
|
||||||
"detected free space ({free}) > total drive space ({total}), fs corruption at ({p.as_ref().display()}). please run 'fsck'"
|
"detected free space ({free}) > total drive space ({total}), fs corruption at ({path_display}). please run 'fsck'"
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ use std::path::Path;
|
|||||||
|
|
||||||
/// Returns total and free bytes available in a directory, e.g. `/`.
|
/// Returns total and free bytes available in a directory, e.g. `/`.
|
||||||
pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<DiskInfo> {
|
pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<DiskInfo> {
|
||||||
|
let path_display = p.as_ref().display();
|
||||||
let stat = statfs(p.as_ref())?;
|
let stat = statfs(p.as_ref())?;
|
||||||
|
|
||||||
let bsize = stat.block_size() as u64;
|
let bsize = stat.block_size() as u64;
|
||||||
@@ -16,10 +17,7 @@ pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<DiskInfo> {
|
|||||||
Some(reserved) => reserved,
|
Some(reserved) => reserved,
|
||||||
None => {
|
None => {
|
||||||
return Err(Error::other(format!(
|
return Err(Error::other(format!(
|
||||||
"detected f_bavail space ({}) > f_bfree space ({}), fs corruption at ({}). please run 'fsck'",
|
"detected f_bavail space ({bavail}) > f_bfree space ({bfree}), fs corruption at ({path_display}). please run 'fsck'",
|
||||||
bavail,
|
|
||||||
bfree,
|
|
||||||
p.as_ref().display()
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -28,10 +26,7 @@ pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<DiskInfo> {
|
|||||||
Some(total) => total * bsize,
|
Some(total) => total * bsize,
|
||||||
None => {
|
None => {
|
||||||
return Err(Error::other(format!(
|
return Err(Error::other(format!(
|
||||||
"detected reserved space ({}) > blocks space ({}), fs corruption at ({}). please run 'fsck'",
|
"detected reserved space ({reserved}) > blocks space ({blocks}), fs corruption at ({path_display}). please run 'fsck'",
|
||||||
reserved,
|
|
||||||
blocks,
|
|
||||||
p.as_ref().display()
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -41,10 +36,7 @@ pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<DiskInfo> {
|
|||||||
Some(used) => used,
|
Some(used) => used,
|
||||||
None => {
|
None => {
|
||||||
return Err(Error::other(format!(
|
return Err(Error::other(format!(
|
||||||
"detected free space ({}) > total drive space ({}), fs corruption at ({}). please run 'fsck'",
|
"detected free space ({free}) > total drive space ({total}), fs corruption at ({path_display}). please run 'fsck'"
|
||||||
free,
|
|
||||||
total,
|
|
||||||
p.as_ref().display()
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use winapi::um::winnt::{LPCWSTR, WCHAR};
|
|||||||
|
|
||||||
/// Returns total and free bytes available in a directory, e.g. `C:\`.
|
/// Returns total and free bytes available in a directory, e.g. `C:\`.
|
||||||
pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<DiskInfo> {
|
pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<DiskInfo> {
|
||||||
|
let path_display = p.as_ref().display();
|
||||||
let path_wide: Vec<WCHAR> = p
|
let path_wide: Vec<WCHAR> = p
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.canonicalize()?
|
.canonicalize()?
|
||||||
@@ -41,10 +42,7 @@ pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<DiskInfo> {
|
|||||||
|
|
||||||
if free > total {
|
if free > total {
|
||||||
return Err(Error::other(format!(
|
return Err(Error::other(format!(
|
||||||
"detected free space ({}) > total drive space ({}), fs corruption at ({}). please run 'fsck'",
|
"detected free space ({free}) > total drive space ({total}), fs corruption at ({path_display}). please run 'fsck'"
|
||||||
free,
|
|
||||||
total,
|
|
||||||
p.as_ref().display()
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user