Skip to content

Commit

Permalink
Add --persist <upperdir> flag to allow the user to specify the overla…
Browse files Browse the repository at this point in the history
…y's upperdir

Signed-off-by: Ariel Miculas-Trif <[email protected]>
  • Loading branch information
ariel-miculas committed Oct 4, 2024
1 parent 65ad0d6 commit a62c2b0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions exe/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ struct Mount {
digest: Option<String>,
#[arg(short, long, conflicts_with = "foreground")]
writable: bool,
#[arg(short, long, conflicts_with = "foreground")]
persist: Option<String>,
}

#[derive(Args)]
Expand Down Expand Up @@ -229,7 +231,7 @@ fn main() -> anyhow::Result<()> {
init_syslog(log_level)?;
}

if m.writable && !Uid::effective().is_root() {
if (m.writable || m.persist.is_some()) && !Uid::effective().is_root() {
anyhow::bail!("Writable mounts can only be created by the root user!")
}

Expand All @@ -242,8 +244,8 @@ fn main() -> anyhow::Result<()> {

let manifest_verity = m.digest.map(hex::decode).transpose()?;

if m.writable {
// We only support background mounts with the writable flag
if m.writable || m.persist.is_some() {
// We only support background mounts with the writable|persist flag
let (recv, mut init_notify) = os_pipe::pipe()?;
let pfs_mountpoint = mountpoint.join("ro");
fs::create_dir_all(&pfs_mountpoint)?;
Expand All @@ -259,7 +261,10 @@ fn main() -> anyhow::Result<()> {
move || {
let ovl_workdir = mountpoint.join("work");
fs::create_dir_all(&ovl_workdir)?;
let ovl_upperdir = mountpoint.join("upper");
let ovl_upperdir = match m.persist {
None => mountpoint.join("upper"),
Some(upperdir) => Path::new(&upperdir).to_path_buf(),
};
fs::create_dir_all(&ovl_upperdir)?;
let overlay = Overlay::writable(
[pfs_mountpoint.as_path()].into_iter(),
Expand Down

0 comments on commit a62c2b0

Please sign in to comment.