|
|
05ad79 |
diff -up util-linux-2.23.2/libmount/src/tab.c.kzak util-linux-2.23.2/libmount/src/tab.c
|
|
|
05ad79 |
--- util-linux-2.23.2/libmount/src/tab.c.kzak 2013-07-30 10:39:26.218738358 +0200
|
|
|
05ad79 |
+++ util-linux-2.23.2/libmount/src/tab.c 2014-09-25 10:53:43.525269554 +0200
|
|
|
05ad79 |
@@ -47,6 +47,8 @@
|
|
|
05ad79 |
#include "strutils.h"
|
|
|
05ad79 |
#include "loopdev.h"
|
|
|
05ad79 |
|
|
|
05ad79 |
+static int is_mountinfo(struct libmnt_table *tb);
|
|
|
05ad79 |
+
|
|
|
05ad79 |
/**
|
|
|
05ad79 |
* mnt_new_table:
|
|
|
05ad79 |
*
|
|
|
05ad79 |
@@ -233,7 +235,7 @@ int mnt_table_get_root_fs(struct libmnt_
|
|
|
05ad79 |
assert(tb);
|
|
|
05ad79 |
assert(root);
|
|
|
05ad79 |
|
|
|
05ad79 |
- if (!tb || !root)
|
|
|
05ad79 |
+ if (!tb || !root || !is_mountinfo(tb))
|
|
|
05ad79 |
return -EINVAL;
|
|
|
05ad79 |
|
|
|
05ad79 |
DBG(TAB, mnt_debug_h(tb, "lookup root fs"));
|
|
|
05ad79 |
@@ -241,8 +243,6 @@ int mnt_table_get_root_fs(struct libmnt_
|
|
|
05ad79 |
mnt_reset_iter(&itr, MNT_ITER_FORWARD);
|
|
|
05ad79 |
while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
|
|
|
05ad79 |
int id = mnt_fs_get_parent_id(fs);
|
|
|
05ad79 |
- if (!id)
|
|
|
05ad79 |
- break; /* @tab is not mountinfo file? */
|
|
|
05ad79 |
|
|
|
05ad79 |
if (!*root || id < root_id) {
|
|
|
05ad79 |
*root = fs;
|
|
|
05ad79 |
@@ -250,7 +250,7 @@ int mnt_table_get_root_fs(struct libmnt_
|
|
|
05ad79 |
}
|
|
|
05ad79 |
}
|
|
|
05ad79 |
|
|
|
05ad79 |
- return root_id ? 0 : -EINVAL;
|
|
|
05ad79 |
+ return *root ? 0 : -EINVAL;
|
|
|
05ad79 |
}
|
|
|
05ad79 |
|
|
|
05ad79 |
/**
|
|
|
05ad79 |
@@ -271,15 +271,13 @@ int mnt_table_next_child_fs(struct libmn
|
|
|
05ad79 |
struct libmnt_fs *fs;
|
|
|
05ad79 |
int parent_id, lastchld_id = 0, chld_id = 0;
|
|
|
05ad79 |
|
|
|
05ad79 |
- if (!tb || !itr || !parent)
|
|
|
05ad79 |
+ if (!tb || !itr || !parent || !is_mountinfo(tb))
|
|
|
05ad79 |
return -EINVAL;
|
|
|
05ad79 |
|
|
|
05ad79 |
DBG(TAB, mnt_debug_h(tb, "lookup next child of '%s'",
|
|
|
05ad79 |
mnt_fs_get_target(parent)));
|
|
|
05ad79 |
|
|
|
05ad79 |
parent_id = mnt_fs_get_id(parent);
|
|
|
05ad79 |
- if (!parent_id)
|
|
|
05ad79 |
- return -EINVAL;
|
|
|
05ad79 |
|
|
|
05ad79 |
/* get ID of the previously returned child */
|
|
|
05ad79 |
if (itr->head && itr->p != itr->head) {
|
|
|
05ad79 |
@@ -310,7 +308,7 @@ int mnt_table_next_child_fs(struct libmn
|
|
|
05ad79 |
}
|
|
|
05ad79 |
}
|
|
|
05ad79 |
|
|
|
05ad79 |
- if (!chld_id)
|
|
|
05ad79 |
+ if (!*chld)
|
|
|
05ad79 |
return 1; /* end of iterator */
|
|
|
05ad79 |
|
|
|
05ad79 |
/* set the iterator to the @chld for the next call */
|
|
|
05ad79 |
diff -up util-linux-2.23.2/misc-utils/findmnt.c.kzak util-linux-2.23.2/misc-utils/findmnt.c
|
|
|
05ad79 |
--- util-linux-2.23.2/misc-utils/findmnt.c.kzak 2013-07-30 11:07:35.138395654 +0200
|
|
|
05ad79 |
+++ util-linux-2.23.2/misc-utils/findmnt.c 2014-09-25 10:49:50.953050560 +0200
|
|
|
05ad79 |
@@ -826,8 +826,9 @@ static int tab_is_tree(struct libmnt_tab
|
|
|
05ad79 |
if (!itr)
|
|
|
05ad79 |
return 0;
|
|
|
05ad79 |
|
|
|
05ad79 |
- if (mnt_table_next_fs(tb, itr, &fs) == 0)
|
|
|
05ad79 |
- rc = mnt_fs_get_id(fs) > 0 && mnt_fs_get_parent_id(fs) > 0;
|
|
|
05ad79 |
+ rc = (mnt_table_next_fs(tb, itr, &fs) == 0 &&
|
|
|
05ad79 |
+ mnt_fs_is_kernel(fs) &&
|
|
|
05ad79 |
+ mnt_fs_get_root(fs));
|
|
|
05ad79 |
|
|
|
05ad79 |
mnt_free_iter(itr);
|
|
|
05ad79 |
return rc;
|