aboutsummaryrefslogtreecommitdiffstats
path: root/libmount/src/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmount/src/utils.c')
-rw-r--r--libmount/src/utils.c73
1 files changed, 0 insertions, 73 deletions
diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index 5693cf8adf..26c5aef7b1 100644
--- a/libmount/src/utils.c
+++ b/libmount/src/utils.c
@@ -1240,79 +1240,6 @@ done:
return 1;
}
-/*
- * Initialize MNT_PATH_TMPTGT; mkdir, create a new namespace and
- * mark (bind mount) the directory as private.
- */
-int mnt_tmptgt_unshare(int *old_ns_fd)
-{
-#ifdef USE_LIBMOUNT_SUPPORT_NAMESPACES
- int rc = 0, fd = -1;
-
- assert(old_ns_fd);
-
- *old_ns_fd = -1;
-
- /* remember the current namespace */
- fd = open("/proc/self/ns/mnt", O_RDONLY | O_CLOEXEC);
- if (fd < 0)
- goto fail;
-
- /* create new namespace */
- if (unshare(CLONE_NEWNS) != 0)
- goto fail;
-
- /* create directory */
- rc = ul_mkdir_p(MNT_PATH_TMPTGT, S_IRWXU);
- if (rc)
- goto fail;
-
- /* try to set top-level directory as private, this is possible if
- * MNT_RUNTIME_TOPDIR (/run) is a separated filesystem. */
- if (mount("none", MNT_RUNTIME_TOPDIR, NULL, MS_PRIVATE, NULL) != 0) {
-
- /* failed; create a mountpoint from MNT_PATH_TMPTGT */
- if (mount(MNT_PATH_TMPTGT, MNT_PATH_TMPTGT, "none", MS_BIND, NULL) != 0)
- goto fail;
- if (mount("none", MNT_PATH_TMPTGT, NULL, MS_PRIVATE, NULL) != 0)
- goto fail;
- }
-
- DBG(UTILS, ul_debug(MNT_PATH_TMPTGT " unshared"));
- *old_ns_fd = fd;
- return 0;
-fail:
- if (rc == 0)
- rc = errno ? -errno : -EINVAL;
-
- mnt_tmptgt_cleanup(fd);
- DBG(UTILS, ul_debug(MNT_PATH_TMPTGT " unshare failed"));
- return rc;
-#else
- return -ENOSYS;
-#endif
-}
-
-/*
- * Clean up MNT_PATH_TMPTGT; umount and switch back to old namespace
- */
-int mnt_tmptgt_cleanup(int old_ns_fd)
-{
-#ifdef USE_LIBMOUNT_SUPPORT_NAMESPACES
- umount(MNT_PATH_TMPTGT);
-
- if (old_ns_fd >= 0) {
- setns(old_ns_fd, CLONE_NEWNS);
- close(old_ns_fd);
- }
-
- DBG(UTILS, ul_debug(MNT_PATH_TMPTGT " cleanup done"));
- return 0;
-#else
- return -ENOSYS;
-#endif
-}
-
#ifdef TEST_PROGRAM
static int test_match_fstype(struct libmnt_test *ts, int argc, char *argv[])
{