about summary refs log tree commit diff
path: root/library/std_detect/src/detect/os/linux/mod.rs
diff options
context:
space:
mode:
authorJakub Beránek <berykubik@gmail.com>2025-07-18 08:49:28 +0200
committerJakub Beránek <berykubik@gmail.com>2025-07-22 20:22:16 +0200
commit81d90d8257e59bc27acd6ec98f3cce3d27de6755 (patch)
tree0847d69c61f6f9e90373cc8fae9dcb7f5913581a /library/std_detect/src/detect/os/linux/mod.rs
parent5e52677a82c6c146469561c97ca4c63a75242102 (diff)
downloadrust-81d90d8257e59bc27acd6ec98f3cce3d27de6755.tar.gz
rust-81d90d8257e59bc27acd6ec98f3cce3d27de6755.zip
Improve error messages of auxv loading
Diffstat (limited to 'library/std_detect/src/detect/os/linux/mod.rs')
-rw-r--r--library/std_detect/src/detect/os/linux/mod.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/library/std_detect/src/detect/os/linux/mod.rs b/library/std_detect/src/detect/os/linux/mod.rs
index 9accd41717b..5ae2aaeab5b 100644
--- a/library/std_detect/src/detect/os/linux/mod.rs
+++ b/library/std_detect/src/detect/os/linux/mod.rs
@@ -6,14 +6,16 @@ use alloc::vec::Vec;
 mod auxvec;
 
 #[cfg(feature = "std_detect_file_io")]
-fn read_file(path: &str) -> Result<Vec<u8>, ()> {
-    let mut path = Vec::from(path.as_bytes());
+fn read_file(orig_path: &str) -> Result<Vec<u8>, alloc::string::String> {
+    use alloc::format;
+
+    let mut path = Vec::from(orig_path.as_bytes());
     path.push(0);
 
     unsafe {
         let file = libc::open(path.as_ptr() as *const libc::c_char, libc::O_RDONLY);
         if file == -1 {
-            return Err(());
+            return Err(format!("Cannot open file at {orig_path}"));
         }
 
         let mut data = Vec::new();
@@ -23,7 +25,7 @@ fn read_file(path: &str) -> Result<Vec<u8>, ()> {
             match libc::read(file, spare.as_mut_ptr() as *mut _, spare.len()) {
                 -1 => {
                     libc::close(file);
-                    return Err(());
+                    return Err(format!("Error while reading from file at {orig_path}"));
                 }
                 0 => break,
                 n => data.set_len(data.len() + n as usize),