public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: Proxmox Backup Server development discussion
	<pbs-devel@lists.proxmox.com>,
	 Lukas Wagner <l.wagner@proxmox.com>,
	Markus Frank <m.frank@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup] api: enhance directory existence check
Date: Wed, 29 Nov 2023 16:00:47 +0100 (CET)	[thread overview]
Message-ID: <1171440086.1149.1701270047293@webmail.proxmox.com> (raw)
In-Reply-To: <7854aa5a-9d94-418a-bbf8-43182235b023@proxmox.com>

> On 29.11.2023 15:51 CET Lukas Wagner <l.wagner@proxmox.com> 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");
         }
         ...
    }
}




      reply	other threads:[~2023-11-29 15:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-29 14:08 Markus Frank
2023-11-29 14:51 ` Lukas Wagner
2023-11-29 15:00   ` Christian Ebner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1171440086.1149.1701270047293@webmail.proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=l.wagner@proxmox.com \
    --cc=m.frank@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal