libmount: mnt_table_over_fs() make child optional
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
667c87c50c
commit
1c81dfff1a
|
@ -710,7 +710,7 @@ int mnt_table_next_child_fs(struct libmnt_table *tb, struct libmnt_iter *itr,
|
||||||
* mnt_table_over_fs:
|
* mnt_table_over_fs:
|
||||||
* @tb: tab pointer
|
* @tb: tab pointer
|
||||||
* @parent: pointer to parental FS
|
* @parent: pointer to parental FS
|
||||||
* @child: returns pointer to FS which over-mounting parent
|
* @child: returns pointer to FS which over-mounting parent (optional)
|
||||||
*
|
*
|
||||||
* This function returns by @child the first filesystenm which is over-mounted
|
* This function returns by @child the first filesystenm which is over-mounted
|
||||||
* on @parent. It means the mountpoint of @child is the same as for @parent and
|
* on @parent. It means the mountpoint of @child is the same as for @parent and
|
||||||
|
@ -735,23 +735,29 @@ int mnt_table_over_fs(struct libmnt_table *tb, struct libmnt_fs *parent,
|
||||||
struct libmnt_fs **child)
|
struct libmnt_fs **child)
|
||||||
{
|
{
|
||||||
struct libmnt_iter itr;
|
struct libmnt_iter itr;
|
||||||
|
struct libmnt_fs *fs = NULL;
|
||||||
int id;
|
int id;
|
||||||
const char *tgt;
|
const char *tgt;
|
||||||
|
|
||||||
if (!tb || !parent || !is_mountinfo(tb))
|
if (!tb || !parent || !is_mountinfo(tb))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (child)
|
||||||
|
*child = NULL;
|
||||||
|
|
||||||
mnt_reset_iter(&itr, MNT_ITER_FORWARD);
|
mnt_reset_iter(&itr, MNT_ITER_FORWARD);
|
||||||
id = mnt_fs_get_id(parent);
|
id = mnt_fs_get_id(parent);
|
||||||
tgt = mnt_fs_get_target(parent);
|
tgt = mnt_fs_get_target(parent);
|
||||||
|
|
||||||
while (mnt_table_next_fs(tb, &itr, child) == 0) {
|
while (mnt_table_next_fs(tb, &itr, &fs) == 0) {
|
||||||
if (mnt_fs_get_parent_id(*child) == id &&
|
if (mnt_fs_get_parent_id(fs) == id &&
|
||||||
mnt_fs_streq_target(*child, tgt) == 1)
|
mnt_fs_streq_target(fs, tgt) == 1) {
|
||||||
|
if (child)
|
||||||
|
*child = fs;
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*child = NULL;
|
|
||||||
return 1; /* nothing */
|
return 1; /* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue