lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
macro.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
mainloop.c mainloop.h \
memory_utils.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
lxclock.c lxclock.h \
mainloop.c mainloop.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
mainloop.c mainloop.h \
memory_utils.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
mainloop.c mainloop.h \
memory_utils.h \
monitor.c monitor.h \
+ mount_utils.c mount_utils.h \
namespace.c namespace.h \
network.c network.h \
nl.c nl.h \
#include "macro.h"
#include "mainloop.h"
#include "memory_utils.h"
+#include "mount_utils.h"
#include "storage/storage.h"
#include "syscall_wrappers.h"
#include "utils.h"
mnt_attributes_old(attr_flags, &old_flags);
return mount("none", path, fs_name, old_flags, NULL);
}
+
+int mount_at(int dfd,
+ const char *src_under_dfd,
+ const char *dst_under_dfd,
+ __u64 o_flags,
+ __u64 resolve_flags,
+ const char *fstype,
+ unsigned int mnt_flags,
+ const void *data)
+{
+ __do_close int source_fd = -EBADF, target_fd = -EBADF;
+ struct lxc_open_how how = {
+ .flags = o_flags,
+ .resolve = resolve_flags,
+ };
+ int ret;
+ char src_buf[LXC_PROC_PID_FD_LEN], dst_buf[LXC_PROC_PID_FD_LEN];
+
+ if (dfd < 0)
+ return ret_errno(EINVAL);
+
+ if (!is_empty_string(src_buf) && *src_buf == '/')
+ return log_error_errno(-EINVAL, EINVAL, "Absolute path specified");
+
+ if (!is_empty_string(src_under_dfd)) {
+ source_fd = openat2(dfd, src_under_dfd, &how, sizeof(how));
+ if (source_fd < 0)
+ return -errno;
+
+ ret = snprintf(src_buf, sizeof(src_buf), "/proc/self/fd/%d", source_fd);
+ if (ret < 0 || ret >= sizeof(src_buf))
+ return -EIO;
+ }
+
+ if (!is_empty_string(dst_under_dfd)) {
+ target_fd = openat2(dfd, dst_under_dfd, &how, sizeof(how));
+ if (target_fd < 0)
+ return log_error_errno(-errno, errno, "Failed to open %d(%s)", dfd, dst_under_dfd);
+
+ TRACE("Mounting %d(%s) through /proc/self/fd/%d", target_fd, dst_under_dfd, target_fd);
+ ret = snprintf(dst_buf, sizeof(dst_buf), "/proc/self/fd/%d", target_fd);
+ } else {
+ TRACE("Mounting %d through /proc/self/fd/%d", dfd, dfd);
+ ret = snprintf(dst_buf, sizeof(dst_buf), "/proc/self/fd/%d", dfd);
+ }
+ if (ret < 0 || ret >= sizeof(dst_buf))
+ return -EIO;
+
+ if (!is_empty_string(src_buf))
+ ret = mount(src_buf, dst_buf, fstype, mnt_flags, data);
+ else
+ ret = mount(NULL, dst_buf, fstype, mnt_flags, data);
+
+ return ret;
+}
+
+int mount_from_at(int dfd_from, const char *path_from,
+ __u64 o_flags_from,
+ __u64 resolve_flags_from,
+ int dfd_to, const char *path_to,
+ __u64 o_flags_to,
+ __u64 resolve_flags_to,
+ const char *fstype, unsigned int mnt_flags, const void *data)
+{
+ __do_close int fd_from = -EBADF, fd_to = -EBADF;
+ struct lxc_open_how how = {};
+ int ret;
+ char src_buf[LXC_PROC_PID_FD_LEN], dst_buf[LXC_PROC_PID_FD_LEN];
+
+ if (is_empty_string(path_from)) {
+ ret = snprintf(src_buf, sizeof(src_buf), "/proc/self/fd/%d", dfd_from);
+ } else {
+ how.flags = o_flags_from;
+ how.resolve = resolve_flags_from;
+ fd_from = openat2(dfd_from, path_from, &how, sizeof(how));
+ if (fd_from < 0)
+ return -errno;
+
+ ret = snprintf(src_buf, sizeof(src_buf), "/proc/self/fd/%d", fd_from);
+ }
+ if (ret < 0 || ret >= sizeof(src_buf))
+ return -EIO;
+
+ if (is_empty_string(path_to)) {
+ ret = snprintf(dst_buf, sizeof(dst_buf), "/proc/self/fd/%d", dfd_to);
+ } else {
+ how.flags = o_flags_to;
+ how.resolve = resolve_flags_to;
+ fd_to = openat2(dfd_to, path_to, &how, sizeof(how));
+ if (fd_to < 0)
+ return -errno;
+
+ ret = snprintf(dst_buf, sizeof(dst_buf), "/proc/self/fd/%d", fd_to);
+ }
+ if (ret < 0 || ret >= sizeof(src_buf))
+ return -EIO;
+
+ if (is_empty_string(src_buf))
+ ret = mount(NULL, dst_buf, fstype, mnt_flags, data);
+ else
+ ret = mount(src_buf, dst_buf, fstype, mnt_flags, data);
+
+ return ret;
+}
#ifndef __LXC_MOUNT_UTILS_H
#define __LXC_MOUNT_UTILS_H
+#include <linux/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mount.h>
__hidden extern int mount_filesystem(const char *fs_name, const char *path, unsigned int attr_flags);
+__hidden extern int mount_at(int dfd, const char *src_under_dfd,
+ const char *dst_under_dfd, __u64 o_flags,
+ __u64 resolve_flags, const char *fstype,
+ unsigned int mnt_flags, const void *data);
+
+__hidden extern int mount_from_at(int dfd_from, const char *path_from,
+ __u64 o_flags_from, __u64 resolve_flags_from,
+ int dfd_to, const char *path_to,
+ __u64 o_flags_to, __u64 resolve_flags_to,
+ const char *fstype, unsigned int mnt_flags,
+ const void *data);
+
#endif /* __LXC_MOUNT_UTILS_H */
return 0;
}
-int mount_at(int dfd,
- const char *src_under_dfd,
- const char *dst_under_dfd,
- __u64 o_flags,
- __u64 resolve_flags,
- const char *fstype,
- unsigned int mnt_flags,
- const void *data)
-{
- __do_close int source_fd = -EBADF, target_fd = -EBADF;
- struct lxc_open_how how = {
- .flags = o_flags,
- .resolve = resolve_flags,
- };
- int ret;
- char src_buf[LXC_PROC_PID_FD_LEN], dst_buf[LXC_PROC_PID_FD_LEN];
-
- if (dfd < 0)
- return ret_errno(EINVAL);
-
- if (!is_empty_string(src_buf) && *src_buf == '/')
- return log_error_errno(-EINVAL, EINVAL, "Absolute path specified");
-
- if (!is_empty_string(src_under_dfd)) {
- source_fd = openat2(dfd, src_under_dfd, &how, sizeof(how));
- if (source_fd < 0)
- return -errno;
-
- ret = snprintf(src_buf, sizeof(src_buf), "/proc/self/fd/%d", source_fd);
- if (ret < 0 || ret >= sizeof(src_buf))
- return -EIO;
- }
-
- if (!is_empty_string(dst_under_dfd)) {
- target_fd = openat2(dfd, dst_under_dfd, &how, sizeof(how));
- if (target_fd < 0)
- return log_error_errno(-errno, errno, "Failed to open %d(%s)", dfd, dst_under_dfd);
-
- TRACE("Mounting %d(%s) through /proc/self/fd/%d", target_fd, dst_under_dfd, target_fd);
- ret = snprintf(dst_buf, sizeof(dst_buf), "/proc/self/fd/%d", target_fd);
- } else {
- TRACE("Mounting %d through /proc/self/fd/%d", dfd, dfd);
- ret = snprintf(dst_buf, sizeof(dst_buf), "/proc/self/fd/%d", dfd);
- }
- if (ret < 0 || ret >= sizeof(dst_buf))
- return -EIO;
-
- if (!is_empty_string(src_buf))
- ret = mount(src_buf, dst_buf, fstype, mnt_flags, data);
- else
- ret = mount(NULL, dst_buf, fstype, mnt_flags, data);
-
- return ret;
-}
-
-int mount_from_at(int dfd_from, const char *path_from,
- __u64 o_flags_from,
- __u64 resolve_flags_from,
- int dfd_to, const char *path_to,
- __u64 o_flags_to,
- __u64 resolve_flags_to,
- const char *fstype, unsigned int mnt_flags, const void *data)
-{
- __do_close int fd_from = -EBADF, fd_to = -EBADF;
- struct lxc_open_how how = {};
- int ret;
- char src_buf[LXC_PROC_PID_FD_LEN], dst_buf[LXC_PROC_PID_FD_LEN];
-
- if (is_empty_string(path_from)) {
- ret = snprintf(src_buf, sizeof(src_buf), "/proc/self/fd/%d", dfd_from);
- } else {
- how.flags = o_flags_from;
- how.resolve = resolve_flags_from;
- fd_from = openat2(dfd_from, path_from, &how, sizeof(how));
- if (fd_from < 0)
- return -errno;
-
- ret = snprintf(src_buf, sizeof(src_buf), "/proc/self/fd/%d", fd_from);
- }
- if (ret < 0 || ret >= sizeof(src_buf))
- return -EIO;
-
- if (is_empty_string(path_to)) {
- ret = snprintf(dst_buf, sizeof(dst_buf), "/proc/self/fd/%d", dfd_to);
- } else {
- how.flags = o_flags_to;
- how.resolve = resolve_flags_to;
- fd_to = openat2(dfd_to, path_to, &how, sizeof(how));
- if (fd_to < 0)
- return -errno;
-
- ret = snprintf(dst_buf, sizeof(dst_buf), "/proc/self/fd/%d", fd_to);
- }
- if (ret < 0 || ret >= sizeof(src_buf))
- return -EIO;
-
- if (is_empty_string(src_buf))
- ret = mount(NULL, dst_buf, fstype, mnt_flags, data);
- else
- ret = mount(src_buf, dst_buf, fstype, mnt_flags, data);
-
- return ret;
-}
-
int open_devnull(void)
{
int fd = open("/dev/null", O_RDWR);
const char *fstype, unsigned int flags, const void *data);
__hidden extern int safe_mount_beneath_at(int beneat_fd, const char *src, const char *dst,
const char *fstype, unsigned int flags, const void *data);
-__hidden extern int mount_at(int dfd, const char *src_under_dfd,
- const char *dst_under_dfd, __u64 o_flags,
- __u64 resolve_flags, const char *fstype,
- unsigned int mnt_flags, const void *data);
-__hidden extern int mount_from_at(int dfd_from, const char *path_from,
- __u64 o_flags_from, __u64 resolve_flags_from,
- int dfd_to, const char *path_to,
- __u64 o_flags_to, __u64 resolve_flags_to,
- const char *fstype, unsigned int mnt_flags,
- const void *data);
#endif /* __LXC_UTILS_H */
../lxc/lxclock.c ../lxc/lxclock.h \
../lxc/mainloop.c ../lxc/mainloop.h \
../lxc/monitor.c ../lxc/monitor.h \
+ ../lxc/mount_utils.c ../lxc/mount_utils.h \
../lxc/namespace.c ../lxc/namespace.h \
../lxc/network.c ../lxc/network.h \
../lxc/nl.c ../lxc/nl.h \
../lxc/lxclock.c ../lxc/lxclock.h \
../lxc/mainloop.c ../lxc/mainloop.h \
../lxc/monitor.c ../lxc/monitor.h \
+ ../lxc/mount_utils.c ../lxc/mount_utils.h \
../lxc/namespace.c ../lxc/namespace.h \
../lxc/network.c ../lxc/network.h \
../lxc/nl.c ../lxc/nl.h \
../lxc/lxclock.c ../lxc/lxclock.h \
../lxc/mainloop.c ../lxc/mainloop.h \
../lxc/monitor.c ../lxc/monitor.h \
+ ../lxc/mount_utils.c ../lxc/mount_utils.h \
../lxc/namespace.c ../lxc/namespace.h \
../lxc/network.c ../lxc/network.h \
../lxc/nl.c ../lxc/nl.h \
../lxc/lxclock.c ../lxc/lxclock.h \
../lxc/mainloop.c ../lxc/mainloop.h \
../lxc/monitor.c ../lxc/monitor.h \
+ ../lxc/mount_utils.c ../lxc/mount_utils.h \
../lxc/namespace.c ../lxc/namespace.h \
../lxc/network.c ../lxc/network.h \
../lxc/nl.c ../lxc/nl.h \
../lxc/lxclock.c ../lxc/lxclock.h \
../lxc/mainloop.c ../lxc/mainloop.h \
../lxc/monitor.c ../lxc/monitor.h \
+ ../lxc/mount_utils.c ../lxc/mount_utils.h \
../lxc/namespace.c ../lxc/namespace.h \
../lxc/network.c ../lxc/network.h \
../lxc/nl.c ../lxc/nl.h \
../lxc/lxclock.c ../lxc/lxclock.h \
../lxc/mainloop.c ../lxc/mainloop.h \
../lxc/monitor.c ../lxc/monitor.h \
+ ../lxc/mount_utils.c ../lxc/mount_utils.h \
../lxc/namespace.c ../lxc/namespace.h \
../lxc/network.c ../lxc/network.h \
../lxc/nl.c ../lxc/nl.h \
../lxc/lxclock.c ../lxc/lxclock.h \
../lxc/mainloop.c ../lxc/mainloop.h \
../lxc/monitor.c ../lxc/monitor.h \
+ ../lxc/mount_utils.c ../lxc/mount_utils.h \
../lxc/namespace.c ../lxc/namespace.h \
../lxc/network.c ../lxc/network.h \
../lxc/nl.c ../lxc/nl.h \
../lxc/lxclock.c ../lxc/lxclock.h \
../lxc/mainloop.c ../lxc/mainloop.h \
../lxc/monitor.c ../lxc/monitor.h \
+ ../lxc/mount_utils.c ../lxc/mount_utils.h \
../lxc/namespace.c ../lxc/namespace.h \
../lxc/network.c ../lxc/network.h \
../lxc/nl.c ../lxc/nl.h \
../lxc/lxclock.c ../lxc/lxclock.h \
../lxc/mainloop.c ../lxc/mainloop.h \
../lxc/monitor.c ../lxc/monitor.h \
+ ../lxc/mount_utils.c ../lxc/mount_utils.h \
../lxc/namespace.c ../lxc/namespace.h \
../lxc/network.c ../lxc/network.h \
../lxc/nl.c ../lxc/nl.h \
../lxc/lxclock.c ../lxc/lxclock.h \
../lxc/mainloop.c ../lxc/mainloop.h \
../lxc/monitor.c ../lxc/monitor.h \
+ ../lxc/mount_utils.c ../lxc/mount_utils.h \
../lxc/namespace.c ../lxc/namespace.h \
../lxc/network.c ../lxc/network.h \
../lxc/nl.c ../lxc/nl.h \
../lxc/lxclock.c ../lxc/lxclock.h \
../lxc/mainloop.c ../lxc/mainloop.h \
../lxc/monitor.c ../lxc/monitor.h \
+ ../lxc/mount_utils.c ../lxc/mount_utils.h \
../lxc/namespace.c ../lxc/namespace.h \
../lxc/network.c ../lxc/network.h \
../lxc/nl.c ../lxc/nl.h \
../lxc/lxclock.c ../lxc/lxclock.h \
../lxc/mainloop.c ../lxc/mainloop.h \
../lxc/monitor.c ../lxc/monitor.h \
+ ../lxc/mount_utils.c ../lxc/mount_utils.h \
../lxc/namespace.c ../lxc/namespace.h \
../lxc/network.c ../lxc/network.h \
../lxc/nl.c ../lxc/nl.h \