Load /proc/self/mountinfo from correct namespace.
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
static struct libmnt_table *new_mountinfo(struct libmnt_context *cxt)
{
- struct libmnt_table *tb = mnt_new_table();
+ struct libmnt_table *tb;
+ struct libmnt_ns *ns_old = mnt_context_switch_target_ns(cxt);
+
+ if (!ns_old)
+ err(MNT_EX_SYSERR, _("failed to switch namespace"));
+
+ tb = mnt_new_table();
if (!tb)
err(MNT_EX_SYSERR, _("libmount table allocation failed"));
tb = NULL;
}
+ if (!mnt_context_switch_ns(cxt, ns_old))
+ err(MNT_EX_SYSERR, _("failed to switch namespace"));
+
return tb;
}