summaryrefslogtreecommitdiffstats
path: root/sys-utils/umount.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys-utils/umount.c')
-rw-r--r--sys-utils/umount.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/sys-utils/umount.c b/sys-utils/umount.c
index 244080598..5478c55b8 100644
--- a/sys-utils/umount.c
+++ b/sys-utils/umount.c
@@ -219,7 +219,13 @@ static int umount_one(struct libmnt_context *cxt, const char *spec)
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"));
@@ -232,6 +238,9 @@ static struct libmnt_table *new_mountinfo(struct libmnt_context *cxt)
tb = NULL;
}
+ if (!mnt_context_switch_ns(cxt, ns_old))
+ err(MNT_EX_SYSERR, _("failed to switch namespace"));
+
return tb;
}