[pbs-devel] [PATCH proxmox-backup] api: enhance directory existence check
Christian Ebner
c.ebner at proxmox.com
Wed Nov 29 16:00:47 CET 2023
> On 29.11.2023 15:51 CET Lukas Wagner <l.wagner at 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");
}
...
}
}
More information about the pbs-devel
mailing list