Fix wrong formats in `{uid,gid}_map`

This commit is contained in:
Ruihan Li 2025-10-01 15:54:13 +08:00 committed by Tate, Hongliang Tian
parent 50eaffc731
commit 78ff1a689b
2 changed files with 6 additions and 8 deletions

View File

@ -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())
}
}

View File

@ -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())
}
}