From 78ff1a689b8b68f16e2fcd7a084b9e3161044530 Mon Sep 17 00:00:00 2001 From: Ruihan Li Date: Wed, 1 Oct 2025 15:54:13 +0800 Subject: [PATCH] Fix wrong formats in `{uid,gid}_map` --- kernel/src/fs/procfs/pid/task/gid_map.rs | 7 +++---- kernel/src/fs/procfs/pid/task/uid_map.rs | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/kernel/src/fs/procfs/pid/task/gid_map.rs b/kernel/src/fs/procfs/pid/task/gid_map.rs index 54567021c..a3be564a6 100644 --- a/kernel/src/fs/procfs/pid/task/gid_map.rs +++ b/kernel/src/fs/procfs/pid/task/gid_map.rs @@ -8,7 +8,7 @@ use crate::{ utils::{mkmod, Inode}, }, prelude::*, - process::Process, + process::{Gid, Process}, }; /// Represents the inode at `/proc/[pid]/task/[tid]/gid_map` (and also `/proc/[pid]/gid_map`). @@ -30,8 +30,7 @@ impl FileOps for GidMapFileOps { // This is the default GID map for the initial user namespace. // TODO: Retrieve the GID map from the user namespace of the current process // instead of returning this hard-coded value. - const INVALID_GID: u32 = u32::MAX; - let res = format!("{:>10}{:>10}{:>10}", 0, 0, INVALID_GID); - Ok(res.into_bytes()) + let output = format!("{:>10} {:>10} {:>10}\n", 0, 0, u32::from(Gid::INVALID)); + Ok(output.into_bytes()) } } diff --git a/kernel/src/fs/procfs/pid/task/uid_map.rs b/kernel/src/fs/procfs/pid/task/uid_map.rs index cdbd20d99..48ac8d6f5 100644 --- a/kernel/src/fs/procfs/pid/task/uid_map.rs +++ b/kernel/src/fs/procfs/pid/task/uid_map.rs @@ -8,7 +8,7 @@ use crate::{ utils::{mkmod, Inode}, }, prelude::*, - process::Process, + process::{Process, Uid}, }; /// Represents the inode at `/proc/[pid]/task/[tid]/uid_map` (and also `/proc/[pid]/uid_map`). @@ -30,8 +30,7 @@ impl FileOps for UidMapFileOps { // This is the default UID map for the initial user namespace. // TODO: Retrieve the UID map from the user namespace of the current process // instead of returning this hard-coded value. - const INVALID_UID: u32 = u32::MAX; - let res = format!("{:>10}{:>10}{:>10}", 0, 0, INVALID_UID); - Ok(res.into_bytes()) + let output = format!("{:>10} {:>10} {:>10}\n", 0, 0, u32::from(Uid::INVALID)); + Ok(output.into_bytes()) } }