From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 219AC1D856; Fri, 05 Dec 2025 16:23:13 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 9E6FA1D7BA; Fri, 05 Dec 2025 16:23:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_PASS,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 Received: from mail-yw1-x1133.google.com (mail-yw1-x1133.google.com [IPv6:2607:f8b0:4864:20::1133]) by atuin.qyliss.net (Postfix) with ESMTPS id 1A52C1D7B0 for ; Fri, 05 Dec 2025 16:23:02 +0000 (UTC) Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-78c329724a6so674587b3.2 for ; Fri, 05 Dec 2025 08:23:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764951779; x=1765556579; darn=spectrum-os.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=8fZqN9tzXlAi7fLaJLMtGIuHY2qC/Oaa5QhetmbtJ1k=; b=SPx4/illysw6t/h0e7FLjgipMC7HLbyaSi6Evvcen024pvyHuWNDdg3bCB99pRHx9o IpKFfpAHDLYQvrPrrR6rr8no9sgPyLyVW6eF/GSvfnDXtAIPtUDrMpgOWmDxaYowqCYU cBdBVXjY6tHvQVjbLI79RnbkmjBs3/lbTMth9BqAMbefYsz59m3TW2zUWu7XdwQfzmou KMv24oAmoal5IoKVEjtjCY6AAJ53nJao7UJST++7zzEL9P6yukpR5PajRFwOk45Xd0ZK /ErQOrBLfUGMJJG1RnZ03jcbGKRqiHlO6ietbg54xwya6/fZ0uEDFu455gVJ4V6YtE6z eNYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764951779; x=1765556579; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=8fZqN9tzXlAi7fLaJLMtGIuHY2qC/Oaa5QhetmbtJ1k=; b=s2oSRtD0g4x8tSeNfHjWvp7p890sVOoYbDXTkGCKkR6b+bG1zh8WnPAXCDbbzRf1ow mS1l1RptdiikzGYQv+2EYg+awQYxBttODipCkjm1NMx60U45sI4/ay3B+Lf72s6t0nBX bfdd53tK6dNhP6yoC00hqBn4AYQHsn1T8so6WvhCQxgwtYADKH2lRm7kWGtZ6mnqQ/9y 3X5dFqPglAzu/UXEecH6EP8ENDw7q1GVgGySoA0fJp+FXd4fhn79A9zqCqnLjBSolxmC yIXEXYXvFGBe7HAuGjHIAaTD8cT/NUlwAqyMxBPKCnDlkyeDg/H9qtJGf8lS4uidzVKu rkgQ== X-Gm-Message-State: AOJu0YwaCwF/HTkgTe2YttUAkhmY9kMUByPiwl46DJljfStAz6Dci0Rq XuMVVcN6DV2NQqYlSu6mzwqlZc+IF82qtYhdZ9Fixouxoscg8ckZv29jSHMZCg== X-Gm-Gg: ASbGnctYOc3BtCO281iBRi6OkxN7/+SGuBIIVtrgkbhxySkamWlNWJ8YnWayWGkul7c 01Y64p2xhG1RaGbAcZ+xL3LsfE9+qA2mcz4DZh38dHMThVfHgSa5/FIyPK4IdCkd7pdI/CMxVDQ C8DgrxrtPjoIMryiOnWLhpJ1fFoJ/a4h7ZEcelwrIIcqlHVwQdhdXLqWYmjXBOYTVzH0RwlP/PD BJU0zKXawMV8dKEQ2cxffIs7YhHcqTSYug/yX/cfSR8XsgZdCwkNsfjw5gL3QjG98c3lDmoWa5L FNbqam+54Q8ThWT/xpJYl+NVl8sXn2Jbp/A8gROEfd3y57IYuZI947oonxHuZDetevSmvh97RA9 20WWhl+iiVGvZSDRyIWMRkPXGPMackTnog/KzeMSpzuKDk03QBwE/3O19NrcCn+riiK3d1n/vE2 23tcyu/mCh154y/t4yzNmM9sjV2Y6OvbFwe7DJiQtiZ4ZEQO/jE7kyWSL9VaYkSn9+H5XWjHj3q VbT8CW7lm0XYvh9hsVz6RZmEDr3HNK6ltk= X-Google-Smtp-Source: AGHT+IHWUzm0kIGOR7hOfIL9PToLa2h52UWwzw4DgrUFtgf6oNHQXjHTgzyC665XhgSPRDmeuVZ82g== X-Received: by 2002:a05:690c:4905:b0:788:1a92:4fec with SMTP id 00721157ae682-78c0c1ef4damr80107867b3.69.1764951779472; Fri, 05 Dec 2025 08:22:59 -0800 (PST) Received: from localhost.localdomain (h96-60-249-169.cncrtn.broadband.dynamic.tds.net. [96.60.249.169]) by smtp.gmail.com with UTF8SMTPSA id 00721157ae682-78c2f0aaf83sm3259827b3.32.2025.12.05.08.22.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Dec 2025 08:22:59 -0800 (PST) From: Demi Marie Obenour Date: Fri, 05 Dec 2025 11:22:03 -0500 Subject: [PATCH 3/4] tools/mount-flatpak: Move more code to mount_commit() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20251205-better-mount-flatpak-v1-3-229a81366091@gmail.com> References: <20251205-better-mount-flatpak-v1-0-229a81366091@gmail.com> In-Reply-To: <20251205-better-mount-flatpak-v1-0-229a81366091@gmail.com> To: Spectrum OS Development X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764951720; l=5973; i=demiobenour@gmail.com; s=20250729; h=from:subject:message-id; bh=NP086g5kNEWxWqdguQbgH8sL0q019PBQR6H0Dpfk0kk=; b=YZ8o4MJYnI4JXT0cVF4WWtr3umOywylRW0qYynfYaVLDvqm20thoM2MynR4cq0V0x9ccfzcHs U3/n89bPtmcC6prqAEDMyYV1a0rmPhRxy83OVywdW+BNl6TFCAr3q8/ X-Developer-Key: i=demiobenour@gmail.com; a=ed25519; pk=X57Q4/YQDj9t4SBeKaDwvXYKB6quZJVx/DE2Ly2out0= Message-ID-Hash: LHDWIGQ4U5RTY6QB62IS3M53IKMAVFXJ X-Message-ID-Hash: LHDWIGQ4U5RTY6QB62IS3M53IKMAVFXJ X-MailFrom: demiobenour@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-devel.spectrum-os.org-0; header-match-devel.spectrum-os.org-1; header-match-devel.spectrum-os.org-2; header-match-devel.spectrum-os.org-3; header-match-devel.spectrum-os.org-4; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Demi Marie Obenour , Alyssa Ross X-Mailman-Version: 3.3.9 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Make mount_commit() responsible for not only mounting the commit tree, but also for opening the source subdirectory and creating the destination subdirectory. Signed-off-by: Demi Marie Obenour --- tools/mount-flatpak/src/main.rs | 82 ++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 43 deletions(-) diff --git a/tools/mount-flatpak/src/main.rs b/tools/mount-flatpak/src/main.rs index 68a1f6ea308387a9471682c927d3a71439ab69e4..b40402b1b15729bdd2228025850efe8d87a48e3b 100644 --- a/tools/mount-flatpak/src/main.rs +++ b/tools/mount-flatpak/src/main.rs @@ -43,7 +43,7 @@ mod metadata; use std::borrow::Cow; use std::env::{ArgsOs, args_os}; -use std::ffi::OsStr; +use std::ffi::{OsStr, OsString}; use std::io; use std::os::unix::prelude::*; use std::path::{Path, PathBuf}; @@ -67,12 +67,21 @@ fn open_subdir(root: &Root, path: &Path) -> Result { } fn mount_commit( - source_commit: &dyn AsFd, + source_installation: &Root, + source_path: &Path, target_installation: &Root, - path: &Path, -) -> Result<(), String> { + target_path: &Path, + kind: &str, +) -> Result<(Root, OsString), String> { + let source_commit_parent_dir = open_subdir(source_installation, source_path) + .map_err(|e| format!("opening source {kind} commit parent: {e}"))?; + let commit = source_commit_parent_dir + .readlink("active") + .map_err(|e| format!("reading active {kind} commit: {e}"))?; + let source_root = open_subdir(&source_commit_parent_dir, &commit) + .map_err(|e| format!("opening source {kind} commit: {e}"))?; let source_commit_tree = open_tree( - source_commit, + &source_root, "", OpenTreeFlags::AT_EMPTY_PATH | OpenTreeFlags::OPEN_TREE_CLONE @@ -81,7 +90,7 @@ fn mount_commit( ) .map_err(|e| format!("cloning source commit tree: {e}"))?; let target_commit_dir = target_installation - .mkdir_all(path, &PermissionsExt::from_mode(0o700)) + .mkdir_all(target_path, &PermissionsExt::from_mode(0o700)) .map_err(|e| format!("creating target commit directory: {e}"))?; move_mount( source_commit_tree, @@ -90,7 +99,8 @@ fn mount_commit( "", MoveMountFlags::MOVE_MOUNT_F_EMPTY_PATH | MoveMountFlags::MOVE_MOUNT_T_EMPTY_PATH, ) - .map_err(|e| format!("mounting commit: {e}")) + .map_err(|e| format!("mounting commit: {e}"))?; + Ok((source_root, commit.as_os_str().to_owned())) } fn run(mut args: ArgsOs) -> Result<(), String> { @@ -129,11 +139,13 @@ fn run(mut args: ArgsOs) -> Result<(), String> { let target_installation_dir = Root::from_fd(target_installation_dir).with_resolver_flags(ResolverFlags::NO_SYMLINKS); - let mut full_app_path = installation_path.join("app"); - full_app_path.push(&app); - full_app_path.push("current"); - let arch_and_branch = source_installation_dir - .readlink(&full_app_path) + let mut app_path = PathBuf::new(); + app_path.push("app"); + app_path.push(&app); + let source_app_dir = open_subdir(&source_installation_dir, &app_path) + .map_err(|e| format!("opening source flatpak app: {e}"))?; + let arch_and_branch = source_app_dir + .readlink("current") .map_err(|e| format!("reading current app arch and branch: {e}"))?; let mut components = arch_and_branch.components(); let arch = components.next().unwrap().as_os_str(); @@ -142,21 +154,16 @@ fn run(mut args: ArgsOs) -> Result<(), String> { return Err("can't infer branch from \"current\" link".to_string()); } - full_app_path.pop(); - full_app_path.push(&arch_and_branch); - full_app_path.push("active"); - let commit = source_installation_dir - .readlink(&full_app_path) - .map_err(|e| format!("reading active app commit: {e}"))? - .into_os_string(); - - full_app_path.pop(); - full_app_path.push(&commit); - let source_app_dir = open_subdir(&source_installation_dir, &full_app_path) - .map_err(|e| format!("opening source app directory: {e}"))?; + let (source_commit_dir, commit) = mount_commit( + &source_app_dir, + &app_path.join(&arch_and_branch), + &target_installation_dir, + &arch_and_branch, + "app", + )?; - let metadata = source_installation_dir - .resolve(&full_app_path.join("metadata")) + let metadata = source_commit_dir + .resolve("metadata") .map_err(|e| format!("resolving app metadata: {e}"))?; let metadata_stat = @@ -172,25 +179,14 @@ fn run(mut args: ArgsOs) -> Result<(), String> { let runtime = extract_runtime(metadata).map_err(|e| format!("reading runtime from metadata: {e}"))?; + let runtime_path = Path::new("runtime").join(runtime); - let mut full_runtime_path = installation_path.join("runtime"); - full_runtime_path.push(runtime); - full_runtime_path.push("active"); - let runtime_commit = source_installation_dir - .readlink(&full_runtime_path) - .map_err(|e| format!("reading active runtime commit: {e}"))? - .into_os_string(); - - full_runtime_path.pop(); - full_runtime_path.push(&runtime_commit); - let source_runtime_dir = open_subdir(&source_installation_dir, &full_runtime_path) - .map_err(|e| format!("opening source runtime directory: {e}"))?; - - mount_commit(&source_app_dir, &target_installation_dir, &full_app_path)?; - mount_commit( - &source_runtime_dir, + let (_, runtime_commit) = mount_commit( + &source_installation_dir, + &runtime_path, &target_installation_dir, - &full_runtime_path, + &runtime_path, + "runtime", )?; target_installation_dir -- 2.52.0