tree-wide: s/mntpt_fd/dfd_mnt/g

parent a5a08920
...@@ -1882,13 +1882,13 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops, ...@@ -1882,13 +1882,13 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops,
/* This is really the codepath that we want. */ /* This is really the codepath that we want. */
if (pure_unified_layout(ops)) { if (pure_unified_layout(ops)) {
dfd_mnt_cgroupfs = open_at(rootfs->mntpt_fd, dfd_mnt_cgroupfs = open_at(rootfs->dfd_mnt,
DEFAULT_CGROUP_MOUNTPOINT_RELATIVE, DEFAULT_CGROUP_MOUNTPOINT_RELATIVE,
PROTECT_OPATH_DIRECTORY, PROTECT_OPATH_DIRECTORY,
PROTECT_LOOKUP_BENEATH_XDEV, 0); PROTECT_LOOKUP_BENEATH_XDEV, 0);
if (dfd_mnt_cgroupfs < 0) if (dfd_mnt_cgroupfs < 0)
return log_error_errno(-errno, errno, "Failed to open %d(%s)", return log_error_errno(-errno, errno, "Failed to open %d(%s)",
rootfs->mntpt_fd, DEFAULT_CGROUP_MOUNTPOINT_RELATIVE); rootfs->dfd_mnt, DEFAULT_CGROUP_MOUNTPOINT_RELATIVE);
if (has_cgns && wants_force_mount) { if (has_cgns && wants_force_mount) {
/* /*
...@@ -1907,7 +1907,7 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops, ...@@ -1907,7 +1907,7 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops,
* relying on RESOLVE_BENEATH so we need to skip the leading "/" in the * relying on RESOLVE_BENEATH so we need to skip the leading "/" in the
* DEFAULT_CGROUP_MOUNTPOINT define. * DEFAULT_CGROUP_MOUNTPOINT define.
*/ */
ret = mount_at(rootfs->mntpt_fd, NULL, DEFAULT_CGROUP_MOUNTPOINT_RELATIVE, ret = mount_at(rootfs->dfd_mnt, NULL, DEFAULT_CGROUP_MOUNTPOINT_RELATIVE,
PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_BENEATH_XDEV, PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_BENEATH_XDEV,
"tmpfs", MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_RELATIME, "tmpfs", MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_RELATIME,
"size=10240k,mode=755"); "size=10240k,mode=755");
...@@ -1922,13 +1922,13 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops, ...@@ -1922,13 +1922,13 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops,
return log_error_errno(false, errno, "Failed to mount tmpfs on %s", return log_error_errno(false, errno, "Failed to mount tmpfs on %s",
DEFAULT_CGROUP_MOUNTPOINT_RELATIVE); DEFAULT_CGROUP_MOUNTPOINT_RELATIVE);
dfd_mnt_cgroupfs = open_at(rootfs->mntpt_fd, dfd_mnt_cgroupfs = open_at(rootfs->dfd_mnt,
DEFAULT_CGROUP_MOUNTPOINT_RELATIVE, DEFAULT_CGROUP_MOUNTPOINT_RELATIVE,
PROTECT_OPATH_DIRECTORY, PROTECT_OPATH_DIRECTORY,
PROTECT_LOOKUP_BENEATH_XDEV, 0); PROTECT_LOOKUP_BENEATH_XDEV, 0);
if (dfd_mnt_cgroupfs < 0) if (dfd_mnt_cgroupfs < 0)
return log_error_errno(-errno, errno, "Failed to open %d(%s)", return log_error_errno(-errno, errno, "Failed to open %d(%s)",
rootfs->mntpt_fd, DEFAULT_CGROUP_MOUNTPOINT_RELATIVE); rootfs->dfd_mnt, DEFAULT_CGROUP_MOUNTPOINT_RELATIVE);
for (int i = 0; ops->hierarchies[i]; i++) { for (int i = 0; ops->hierarchies[i]; i++) {
__do_free char *controllerpath = NULL, *path2 = NULL; __do_free char *controllerpath = NULL, *path2 = NULL;
......
...@@ -643,17 +643,17 @@ static int lxc_mount_auto_mounts(struct lxc_conf *conf, int flags, struct lxc_ha ...@@ -643,17 +643,17 @@ static int lxc_mount_auto_mounts(struct lxc_conf *conf, int flags, struct lxc_ha
bool has_cap_net_admin; bool has_cap_net_admin;
if (flags & LXC_AUTO_PROC_MASK) { if (flags & LXC_AUTO_PROC_MASK) {
ret = mkdirat(rootfs->mntpt_fd, "proc" , S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); ret = mkdirat(rootfs->dfd_mnt, "proc" , S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
if (ret < 0 && errno != EEXIST) if (ret < 0 && errno != EEXIST)
return log_error_errno(-errno, errno, return log_error_errno(-errno, errno,
"Failed to create proc mountpoint under %d", rootfs->mntpt_fd); "Failed to create proc mountpoint under %d", rootfs->dfd_mnt);
} }
if (flags & LXC_AUTO_SYS_MASK) { if (flags & LXC_AUTO_SYS_MASK) {
ret = mkdirat(rootfs->mntpt_fd, "sys" , S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); ret = mkdirat(rootfs->dfd_mnt, "sys" , S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
if (ret < 0 && errno != EEXIST) if (ret < 0 && errno != EEXIST)
return log_error_errno(-errno, errno, return log_error_errno(-errno, errno,
"Failed to create sysfs mountpoint under %d", rootfs->mntpt_fd); "Failed to create sysfs mountpoint under %d", rootfs->dfd_mnt);
} }
has_cap_net_admin = lxc_wants_cap(CAP_NET_ADMIN, conf); has_cap_net_admin = lxc_wants_cap(CAP_NET_ADMIN, conf);
...@@ -1071,14 +1071,14 @@ static int mount_autodev(const char *name, const struct lxc_rootfs *rootfs, ...@@ -1071,14 +1071,14 @@ static int mount_autodev(const char *name, const struct lxc_rootfs *rootfs,
DEBUG("Using mount options: %s", mount_options); DEBUG("Using mount options: %s", mount_options);
cur_mask = umask(S_IXUSR | S_IXGRP | S_IXOTH); cur_mask = umask(S_IXUSR | S_IXGRP | S_IXOTH);
ret = mkdirat(rootfs->mntpt_fd, "dev" , S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); ret = mkdirat(rootfs->dfd_mnt, "dev" , S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
if (ret < 0 && errno != EEXIST) { if (ret < 0 && errno != EEXIST) {
SYSERROR("Failed to create \"/dev\" directory"); SYSERROR("Failed to create \"/dev\" directory");
ret = -errno; ret = -errno;
goto reset_umask; goto reset_umask;
} }
ret = safe_mount_beneath_at(rootfs->mntpt_fd, "none", "dev", "tmpfs", 0, mount_options); ret = safe_mount_beneath_at(rootfs->dfd_mnt, "none", "dev", "tmpfs", 0, mount_options);
if (ret < 0) { if (ret < 0) {
__do_free char *fallback_path = NULL; __do_free char *fallback_path = NULL;
...@@ -1103,7 +1103,7 @@ static int mount_autodev(const char *name, const struct lxc_rootfs *rootfs, ...@@ -1103,7 +1103,7 @@ static int mount_autodev(const char *name, const struct lxc_rootfs *rootfs,
/* If we are running on a devtmpfs mapping, dev/pts may already exist. /* If we are running on a devtmpfs mapping, dev/pts may already exist.
* If not, then create it and exit if that fails... * If not, then create it and exit if that fails...
*/ */
ret = mkdirat(rootfs->mntpt_fd, "dev/pts", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); ret = mkdirat(rootfs->dfd_mnt, "dev/pts", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
if (ret < 0 && errno != EEXIST) { if (ret < 0 && errno != EEXIST) {
SYSERROR("Failed to create directory \"%s\"", path); SYSERROR("Failed to create directory \"%s\"", path);
ret = -errno; ret = -errno;
...@@ -1262,8 +1262,8 @@ static int lxc_mount_rootfs(struct lxc_conf *conf) ...@@ -1262,8 +1262,8 @@ static int lxc_mount_rootfs(struct lxc_conf *conf)
if (ret < 0) if (ret < 0)
return log_error_errno(-1, errno, "Failed to recursively turn root mount tree into dependent mount"); return log_error_errno(-1, errno, "Failed to recursively turn root mount tree into dependent mount");
rootfs->mntpt_fd = open_at(-EBADF, "/", PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_ABSOLUTE, 0); rootfs->dfd_mnt = open_at(-EBADF, "/", PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_ABSOLUTE, 0);
if (rootfs->mntpt_fd < 0) if (rootfs->dfd_mnt < 0)
return -errno; return -errno;
return 0; return 0;
...@@ -1291,8 +1291,8 @@ static int lxc_mount_rootfs(struct lxc_conf *conf) ...@@ -1291,8 +1291,8 @@ static int lxc_mount_rootfs(struct lxc_conf *conf)
rootfs->path, rootfs->mount, rootfs->path, rootfs->mount,
rootfs->options ? rootfs->options : "(null)"); rootfs->options ? rootfs->options : "(null)");
rootfs->mntpt_fd = open_at(-EBADF, rootfs->mount, PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_ABSOLUTE_XDEV, 0); rootfs->dfd_mnt = open_at(-EBADF, rootfs->mount, PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_ABSOLUTE_XDEV, 0);
if (rootfs->mntpt_fd < 0) if (rootfs->dfd_mnt < 0)
return -errno; return -errno;
return 0; return 0;
...@@ -1424,7 +1424,7 @@ static int lxc_pivot_root(const struct lxc_rootfs *rootfs) ...@@ -1424,7 +1424,7 @@ static int lxc_pivot_root(const struct lxc_rootfs *rootfs)
return log_error_errno(-1, errno, "Failed to open old root directory"); return log_error_errno(-1, errno, "Failed to open old root directory");
/* change into new root fs */ /* change into new root fs */
ret = fchdir(rootfs->mntpt_fd); ret = fchdir(rootfs->dfd_mnt);
if (ret < 0) if (ret < 0)
return log_error_errno(-errno, errno, "Failed to change into new root directory \"%s\"", rootfs->mount); return log_error_errno(-errno, errno, "Failed to change into new root directory \"%s\"", rootfs->mount);
...@@ -1453,7 +1453,7 @@ static int lxc_pivot_root(const struct lxc_rootfs *rootfs) ...@@ -1453,7 +1453,7 @@ static int lxc_pivot_root(const struct lxc_rootfs *rootfs)
if (ret < 0) if (ret < 0)
return log_error_errno(-errno, errno, "Failed to detach old root directory"); return log_error_errno(-errno, errno, "Failed to detach old root directory");
ret = fchdir(rootfs->mntpt_fd); ret = fchdir(rootfs->dfd_mnt);
if (ret < 0) if (ret < 0)
return log_error_errno(-errno, errno, "Failed to re-enter new root directory \"%s\"", rootfs->mount); return log_error_errno(-errno, errno, "Failed to re-enter new root directory \"%s\"", rootfs->mount);
...@@ -2633,7 +2633,7 @@ struct lxc_conf *lxc_conf_init(void) ...@@ -2633,7 +2633,7 @@ struct lxc_conf *lxc_conf_init(void)
return NULL; return NULL;
} }
new->rootfs.managed = true; new->rootfs.managed = true;
new->rootfs.mntpt_fd = -EBADF; new->rootfs.dfd_mnt = -EBADF;
new->rootfs.dfd_dev = -EBADF; new->rootfs.dfd_dev = -EBADF;
new->rootfs.dfd_root_host = -EBADF; new->rootfs.dfd_root_host = -EBADF;
new->logfd = -1; new->logfd = -1;
...@@ -2984,11 +2984,11 @@ static int lxc_transient_proc(struct lxc_rootfs *rootfs) ...@@ -2984,11 +2984,11 @@ static int lxc_transient_proc(struct lxc_rootfs *rootfs)
int link_to_pid, link_len, pid_self, ret; int link_to_pid, link_len, pid_self, ret;
char link[INTTYPE_TO_STRLEN(pid_t) + 1]; char link[INTTYPE_TO_STRLEN(pid_t) + 1];
link_len = readlinkat(rootfs->mntpt_fd, "proc/self", link, sizeof(link)); link_len = readlinkat(rootfs->dfd_mnt, "proc/self", link, sizeof(link));
if (link_len < 0) { if (link_len < 0) {
ret = mkdirat(rootfs->mntpt_fd, "proc", 0000); ret = mkdirat(rootfs->dfd_mnt, "proc", 0000);
if (ret < 0 && errno != EEXIST) if (ret < 0 && errno != EEXIST)
return log_error_errno(-errno, errno, "Failed to create %d(proc)", rootfs->mntpt_fd); return log_error_errno(-errno, errno, "Failed to create %d(proc)", rootfs->dfd_mnt);
goto domount; goto domount;
} else if (link_len >= sizeof(link)) { } else if (link_len >= sizeof(link)) {
...@@ -3007,7 +3007,7 @@ static int lxc_transient_proc(struct lxc_rootfs *rootfs) ...@@ -3007,7 +3007,7 @@ static int lxc_transient_proc(struct lxc_rootfs *rootfs)
if (link_to_pid == pid_self) if (link_to_pid == pid_self)
return log_trace(0, "Correct procfs instance mounted"); return log_trace(0, "Correct procfs instance mounted");
fd_proc = open_at(rootfs->mntpt_fd, "proc", PROTECT_OPATH_DIRECTORY, fd_proc = open_at(rootfs->dfd_mnt, "proc", PROTECT_OPATH_DIRECTORY,
PROTECT_LOOKUP_BENEATH_XDEV, 0); PROTECT_LOOKUP_BENEATH_XDEV, 0);
if (fd_proc < 0) if (fd_proc < 0)
return log_error_errno(-errno, errno, "Failed to open transient procfs mountpoint"); return log_error_errno(-errno, errno, "Failed to open transient procfs mountpoint");
...@@ -3025,7 +3025,7 @@ domount: ...@@ -3025,7 +3025,7 @@ domount:
if (!rootfs->path) { if (!rootfs->path) {
ret = mount("proc", rootfs->buf, "proc", 0, NULL); ret = mount("proc", rootfs->buf, "proc", 0, NULL);
} else { } else {
ret = safe_mount_beneath_at(rootfs->mntpt_fd, "none", "proc", "proc", 0, NULL); ret = safe_mount_beneath_at(rootfs->dfd_mnt, "none", "proc", "proc", 0, NULL);
if (ret < 0) { if (ret < 0) {
ret = snprintf(rootfs->buf, sizeof(rootfs->buf), "%s/proc", rootfs->path ? rootfs->mount : ""); ret = snprintf(rootfs->buf, sizeof(rootfs->buf), "%s/proc", rootfs->path ? rootfs->mount : "");
if (ret < 0 || (size_t)ret >= sizeof(rootfs->buf)) if (ret < 0 || (size_t)ret >= sizeof(rootfs->buf))
...@@ -3222,8 +3222,8 @@ int lxc_setup_rootfs_prepare_root(struct lxc_conf *conf, const char *name, ...@@ -3222,8 +3222,8 @@ int lxc_setup_rootfs_prepare_root(struct lxc_conf *conf, const char *name,
if (ret < 0) if (ret < 0)
return log_error(-1, "Failed to bind mount container / onto itself"); return log_error(-1, "Failed to bind mount container / onto itself");
conf->rootfs.mntpt_fd = openat(-EBADF, path, O_RDONLY | O_CLOEXEC | O_DIRECTORY | O_PATH | O_NOCTTY); conf->rootfs.dfd_mnt = openat(-EBADF, path, O_RDONLY | O_CLOEXEC | O_DIRECTORY | O_PATH | O_NOCTTY);
if (conf->rootfs.mntpt_fd < 0) if (conf->rootfs.dfd_mnt < 0)
return log_error_errno(-errno, errno, "Failed to open file descriptor for container rootfs"); return log_error_errno(-errno, errno, "Failed to open file descriptor for container rootfs");
return log_trace(0, "Bind mounted container / onto itself"); return log_trace(0, "Bind mounted container / onto itself");
...@@ -3415,7 +3415,7 @@ int lxc_setup(struct lxc_handler *handler) ...@@ -3415,7 +3415,7 @@ int lxc_setup(struct lxc_handler *handler)
return log_error(-1, "Failed to mount \"/dev\""); return log_error(-1, "Failed to mount \"/dev\"");
} }
lxc_conf->rootfs.dfd_dev = open_at(lxc_conf->rootfs.mntpt_fd, "dev", lxc_conf->rootfs.dfd_dev = open_at(lxc_conf->rootfs.dfd_mnt, "dev",
PROTECT_OPATH_DIRECTORY, PROTECT_OPATH_DIRECTORY,
PROTECT_LOOKUP_BENEATH_XDEV, 0); PROTECT_LOOKUP_BENEATH_XDEV, 0);
if (lxc_conf->rootfs.dfd_dev < 0 && errno != ENOENT) if (lxc_conf->rootfs.dfd_dev < 0 && errno != ENOENT)
...@@ -3540,7 +3540,7 @@ int lxc_setup(struct lxc_handler *handler) ...@@ -3540,7 +3540,7 @@ int lxc_setup(struct lxc_handler *handler)
return log_error(-1, "Failed to drop capabilities"); return log_error(-1, "Failed to drop capabilities");
} }
close_prot_errno_disarm(lxc_conf->rootfs.mntpt_fd) close_prot_errno_disarm(lxc_conf->rootfs.dfd_mnt)
close_prot_errno_disarm(lxc_conf->rootfs.dfd_dev) close_prot_errno_disarm(lxc_conf->rootfs.dfd_dev)
close_prot_errno_disarm(lxc_conf->rootfs.dfd_root_host) close_prot_errno_disarm(lxc_conf->rootfs.dfd_root_host)
NOTICE("The container \"%s\" is set up", name); NOTICE("The container \"%s\" is set up", name);
...@@ -3906,7 +3906,7 @@ void lxc_conf_free(struct lxc_conf *conf) ...@@ -3906,7 +3906,7 @@ void lxc_conf_free(struct lxc_conf *conf)
free(conf->rootfs.options); free(conf->rootfs.options);
free(conf->rootfs.path); free(conf->rootfs.path);
free(conf->rootfs.data); free(conf->rootfs.data);
close_prot_errno_disarm(conf->rootfs.mntpt_fd); close_prot_errno_disarm(conf->rootfs.dfd_mnt);
close_prot_errno_disarm(conf->rootfs.dfd_dev); close_prot_errno_disarm(conf->rootfs.dfd_dev);
close_prot_errno_disarm(conf->rootfs.dfd_root_host); close_prot_errno_disarm(conf->rootfs.dfd_root_host);
free(conf->logfile); free(conf->logfile);
......
...@@ -190,12 +190,12 @@ struct lxc_tty_info { ...@@ -190,12 +190,12 @@ struct lxc_tty_info {
* @mountflags : the portion of @options that are flags * @mountflags : the portion of @options that are flags
* @data : the portion of @options that are not flags * @data : the portion of @options that are not flags
* @managed : whether it is managed by LXC * @managed : whether it is managed by LXC
* @mntpt_fd : fd for @mount * @dfd_mnt : fd for @mount
* @dfd_dev : fd for /dev of the container * @dfd_dev : fd for /dev of the container
*/ */
struct lxc_rootfs { struct lxc_rootfs {
int dfd_root_host; int dfd_root_host;
int mntpt_fd; int dfd_mnt;
int dfd_dev; int dfd_dev;
char *path; char *path;
char *mount; char *mount;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment