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 9E1621D888; Fri, 05 Dec 2025 16:23:11 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id C7BFD1D7B4; Fri, 05 Dec 2025 16:23:02 +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-yx1-xb131.google.com (mail-yx1-xb131.google.com [IPv6:2607:f8b0:4864:20::b131]) by atuin.qyliss.net (Postfix) with ESMTPS id 4F2A51D80E for ; Fri, 05 Dec 2025 16:23:01 +0000 (UTC) Received: by mail-yx1-xb131.google.com with SMTP id 956f58d0204a3-6430834244aso1856784d50.2 for ; Fri, 05 Dec 2025 08:22:59 -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=OZ2upGR8iPIrZ0Vm2GQ3jFik5WEzmssEg3XwCHVLBMs=; b=N/osE9ZXVtq5cg7oaQNlPnHE4N27wqQBQlMGPz9GHE43JOc1bK9KWSRLKOwtEPhbWf a6k7JiUknlxrhUOF2UrDA6Xx6g5t7EWbyICSlD1tcMFU6JtIS/lNu02M6vRE7uaf9th8 /SlL9WXTicEX7DrCOl0gubbAkLR7H6cZVGXfA3FHqvj0HVybaxQx7ZZxoM4uMlfsBC3P GtyxjCl/QvFO7DKBGc/o5XAORfEbnVvwoiRGCqpFXnlfA8l9IJbet8GtqG7EV8S/HmCr C5LvnOIzIgUcGkWe7UiPdppVdsflhrL18AzVwGwcI7OvIEarxJbUAe96/b605As4y6Ay rVaw== 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=OZ2upGR8iPIrZ0Vm2GQ3jFik5WEzmssEg3XwCHVLBMs=; b=aFFMkviyEzMrJgBGqPExlj5EqCDS+XB3RjFlR3dG2TaaJ/14wIsgRdUDghq86WplLd 8AzCqxN1b+FP62iKsg3XEdDq9BGyYLlIhybioUiV6TZ2BeMe9PoPSxzxvokJ4Z+ezhY8 G1AEf1pyQt/huhdNACgqnb+XJKzw6l4zEvOhKG+CFUDV9U1dNaAyNE3DgSEp+SF8Laq3 +6v8k8dDS4Pt//0POqeO+I/QhRxrFxJha1SU9AutYeM0Ha2Xw1BRzFuPhT6kDHSMYjli n801Zx/trb0ZX8lbAERvMi6Cs5re8nH1urnFL2iyuV1DwceQUjO9NPLzpdHXAPsF952e QKkA== X-Gm-Message-State: AOJu0Yy4ShWtYCYoAHGym9DupWU4eKaqJErmASFA+f2/CK290y6iP8HV o0jt74vxe1Wy17YJVPrGTsscalWqhhnpchASStQe780m5q1PdtoYABpYP0NOrQ== X-Gm-Gg: ASbGncsHkMQlgQhirAquo88sxKVBi+LYYQrHKdFn/a2ryBSr8m9ll5Vru5QM0hRFvfp mZHCDlufMVsTpRRThJrKnx/E79zm+DxqgmzLug4v9toBXzTogYEA4CVR7oitRywt9kVkylQBsHE R6D5ioUUV/oc1SpL+sl9abCu2zuoYiATlpP24piv1w11oEKn8jtm7qzXJ6bmPUNQvBQ7kliSZoT ZbTT5aSpBqO1y1fpptYsoBeJ/hYu8RxdV2Lgnn9hCkmixxNq+PNLt6kDNw0w8yoxSAjeaAns+xC bkskdtsK4uJ0V5CySfEvCsWfi/TJVzXxok71dWhJQ11HCWPVuKeNa16EghJ9R/wmqZdKmrbpoE8 xVumxER8FVMSHDZlg8E1Sz/b2J3Ah75kGFkT4eXjx4kScpTL9fcx9jZRh8ixW0Ni/kJQ5RIbHLp 5i07qC4gZx5aVtvR+LAf+VrKlO3b6XEXKXyJA2kfxElesCQLaaKvBMq7aDHJkHUAL4Z/t6GnCin RtxNyhXQvbMqJWWlnLc8E5OGxkY+ZwL3qE= X-Google-Smtp-Source: AGHT+IHqDVk6qy6Ex7yUE6CNmIebaHLqF6tKikdcs1XQkGtHvkVJQ5stlu6l6Xl02I5pu1PTUJAFHg== X-Received: by 2002:a05:690e:1582:20b0:641:f5bc:68cd with SMTP id 956f58d0204a3-6443d95be81mr4443911d50.74.1764951778628; Fri, 05 Dec 2025 08:22:58 -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-78c1b7902e7sm18155217b3.46.2025.12.05.08.22.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Dec 2025 08:22:58 -0800 (PST) From: Demi Marie Obenour Date: Fri, 05 Dec 2025 11:22:02 -0500 Subject: [PATCH 2/4] tools/mount-flatpak: Create utility function to open a subdirectory MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20251205-better-mount-flatpak-v1-2-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=3103; i=demiobenour@gmail.com; s=20250729; h=from:subject:message-id; bh=bBPAOM2OEBp1kyKiRPb8ima22NFk/82JvFrw0aqO4AQ=; b=pG+ySg9JmIxk+3p4c1BgRPQ5p6NzgdUNGuau924u4F18HGUU/IzOJfdI6oBLwZPFbsX+F8gR3 1suAeLo9nrmALhYvQusv4gqfoZx2+UO3zEwua4d3+UxiQ4v4HIABnt1 X-Developer-Key: i=demiobenour@gmail.com; a=ed25519; pk=X57Q4/YQDj9t4SBeKaDwvXYKB6quZJVx/DE2Ly2out0= Message-ID-Hash: 5KH5US7URNZR5AX5ZJHUW7E4DSGBFZEQ X-Message-ID-Hash: 5KH5US7URNZR5AX5ZJHUW7E4DSGBFZEQ 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: This rejects non-directories where a directory is expected. Signed-off-by: Demi Marie Obenour --- tools/mount-flatpak/src/main.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/mount-flatpak/src/main.rs b/tools/mount-flatpak/src/main.rs index dca42e5007e52b24c9a4b6940d5667f770a64bd0..68a1f6ea308387a9471682c927d3a71439ab69e4 100644 --- a/tools/mount-flatpak/src/main.rs +++ b/tools/mount-flatpak/src/main.rs @@ -49,8 +49,8 @@ use std::os::unix::prelude::*; use std::path::{Path, PathBuf}; use std::process::exit; -use pathrs::Root; use pathrs::flags::{OpenFlags, ResolverFlags}; +use pathrs::{Root, error::Error}; use rustix::fs::{CWD, FileType, fstat}; use rustix::mount::{MoveMountFlags, OpenTreeFlags, move_mount, open_tree}; @@ -61,6 +61,11 @@ fn ex_usage() -> ! { exit(1); } +fn open_subdir(root: &Root, path: &Path) -> Result { + root.open_subpath(path, OpenFlags::O_PATH | OpenFlags::O_DIRECTORY) + .map(|f| Root::from_fd(f).with_resolver_flags(ResolverFlags::NO_SYMLINKS)) +} + fn mount_commit( source_commit: &dyn AsFd, target_installation: &Root, @@ -106,11 +111,8 @@ fn run(mut args: ArgsOs) -> Result<(), String> { .map_err(|e| format!("opening user data partition: {e}"))? .with_resolver_flags(ResolverFlags::NO_SYMLINKS); - let source_installation_dir = user_data - .open_subpath(&installation_path, OpenFlags::O_PATH) - .map(Root::from_fd) - .map_err(|e| format!("opening source flatpak installation: {e}"))? - .with_resolver_flags(ResolverFlags::NO_SYMLINKS); + let source_installation_dir = open_subdir(&user_data, &installation_path) + .map_err(|e| format!("opening source flatpak installation: {e}"))?; std::fs::create_dir("flatpak") .map_err(|e| format!("creating target flatpak installation: {e}"))?; @@ -150,12 +152,11 @@ fn run(mut args: ArgsOs) -> Result<(), String> { full_app_path.pop(); full_app_path.push(&commit); - let source_app_dir = source_installation_dir - .resolve(&full_app_path) + let source_app_dir = open_subdir(&source_installation_dir, &full_app_path) .map_err(|e| format!("opening source app directory: {e}"))?; let metadata = source_installation_dir - .resolve(full_app_path.join("metadata")) + .resolve(&full_app_path.join("metadata")) .map_err(|e| format!("resolving app metadata: {e}"))?; let metadata_stat = @@ -182,8 +183,7 @@ fn run(mut args: ArgsOs) -> Result<(), String> { full_runtime_path.pop(); full_runtime_path.push(&runtime_commit); - let source_runtime_dir = source_installation_dir - .resolve(&full_runtime_path) + 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)?; -- 2.52.0