summaryrefslogtreecommitdiffstats
path: root/libmount/src/tab.c
diff options
context:
space:
mode:
authorKarel Zak2013-07-08 14:21:03 +0200
committerKarel Zak2013-07-08 14:24:31 +0200
commitd828dfdfb258367c58819411b2f226da6533b92d (patch)
tree70dffd7feef089b545c08e6b9f02a30e84278ff8 /libmount/src/tab.c
parentlsblk: use devno to get mountpoint (diff)
downloadkernel-qcow2-util-linux-d828dfdfb258367c58819411b2f226da6533b92d.tar.gz
kernel-qcow2-util-linux-d828dfdfb258367c58819411b2f226da6533b92d.tar.xz
kernel-qcow2-util-linux-d828dfdfb258367c58819411b2f226da6533b92d.zip
lsblk: use devno to check if the filesystem is mounted
The device (for example LVM logical volume) could be renamed and then the device name from /proc/self/mountinfo does not match with reality. So, we also need to check devno. Unfortunately we cannot completely rely on devno, because for example btrfs uses psudo device numbers. References: https://bugzilla.redhat.com/show_bug.cgi?id=980463 Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/tab.c')
-rw-r--r--libmount/src/tab.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/libmount/src/tab.c b/libmount/src/tab.c
index 5ac252ce1..20028a641 100644
--- a/libmount/src/tab.c
+++ b/libmount/src/tab.c
@@ -1117,6 +1117,7 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
const char *src = NULL, *tgt = NULL;
char *xtgt = NULL;
int rc = 0;
+ dev_t devno = 0;
assert(tb);
assert(fstab_fs);
@@ -1148,6 +1149,14 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
if (src && tb->cache && !mnt_fs_is_pseudofs(fstab_fs))
src = mnt_resolve_spec(src, tb->cache);
+ if (src && root) {
+ struct stat st;
+
+ devno = mnt_fs_get_devno(fstab_fs);
+ if (!devno && stat(src, &st) == 0 && S_ISBLK(st.st_mode))
+ devno = st.st_rdev;
+ }
+
tgt = mnt_fs_get_target(fstab_fs);
if (!tgt || !src) {
@@ -1158,7 +1167,12 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
while (mnt_table_next_fs(tb, &itr, &fs) == 0) {
- if (!mnt_fs_streq_srcpath(fs, src)) {
+ int eq = mnt_fs_streq_srcpath(fs, src);
+
+ if (!eq && devno && mnt_fs_get_devno(fs) == devno)
+ eq = 1;
+
+ if (!eq) {
/* The source does not match. Maybe the source is a loop
* device backing file.
*/