From e54ad19a06824e697e40b6fabc51c9079b825ac8 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Wed, 4 Dec 2013 19:15:12 +0400 Subject: [PATCH] mount: Add phys_stat_dev_match helper This helper serves to hide fs specifics (in particular btrfs) thus the caller won't need the details. Signed-off-by: Cyrill Gorcunov Signed-off-by: Pavel Emelyanov --- include/mount.h | 2 ++ mount.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/mount.h b/include/mount.h index 76f4fed00..3e4508715 100644 --- a/include/mount.h +++ b/include/mount.h @@ -22,4 +22,6 @@ extern struct mount_info *lookup_mnt_sdev(unsigned int s_dev); extern struct ns_desc mnt_ns_desc; +extern bool phys_stat_dev_match(dev_t st_dev, dev_t phys_dev); + #endif /* __CR_MOUNT_H__ */ diff --git a/mount.c b/mount.c index 5a1a85d59..22b838303 100644 --- a/mount.c +++ b/mount.c @@ -18,6 +18,7 @@ #include "util-pie.h" #include "log.h" #include "mount.h" +#include "mount-btrfs.h" #include "pstree.h" #include "proc_parse.h" #include "image.h" @@ -97,6 +98,19 @@ struct mount_info *lookup_mnt_sdev(unsigned int s_dev) return NULL; } +bool phys_stat_dev_match(dev_t st_dev, dev_t phys_dev) +{ + if (st_dev == phys_dev) + return true; + + /* + * BTRFS returns subvolume dev-id instead of + * superblock dev-id so we might need additional + * tests here. + */ + return is_btrfs_subvol(phys_dev, st_dev); +} + /* * Comparer two mounts. Return true if only mount points are differ. * Don't care about root and mountpoints, if bind is true.