From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id D6A50B3DEC for ; Wed, 29 Nov 2023 16:00:49 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C01779FA1 for ; Wed, 29 Nov 2023 16:00:49 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 29 Nov 2023 16:00:48 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9228C40E11 for ; Wed, 29 Nov 2023 16:00:48 +0100 (CET) Date: Wed, 29 Nov 2023 16:00:47 +0100 (CET) From: Christian Ebner To: Proxmox Backup Server development discussion , Lukas Wagner , Markus Frank Message-ID: <1171440086.1149.1701270047293@webmail.proxmox.com> In-Reply-To: <7854aa5a-9d94-418a-bbf8-43182235b023@proxmox.com> References: <20231129140838.133066-1-m.frank@proxmox.com> <7854aa5a-9d94-418a-bbf8-43182235b023@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.6-Rev55 X-Originating-Client: open-xchange-appsuite X-SPAM-LEVEL: Spam detection results: 0 AWL 0.050 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: Re: [pbs-devel] [PATCH proxmox-backup] api: enhance directory existence check X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Nov 2023 15:00:49 -0000 > On 29.11.2023 15:51 CET Lukas Wagner wrote: > > > > But that does not detect if another (empty) filesystem is already > mounted at that directory, right? To add to Lukas response, you could compare the `st_dev` of parent and mountpoint to check if there already if a different filesystem mounted, something like: use std::os::linux::fs::MetadataExt; ... match std::fs::metadata(&default_path) { Err(_) => {} // path does not exist Ok(stat) => { let basedir_dev = std::fs::metadata(BASE_MOUNT_DIR)?.st_dev(); if stat.st_dev != basedir_dev { bail!("path {default_path:?} already exists and is mountpoint"); } ... } }