mirror of
git://github.com/lxc/lxc
synced 2025-09-01 00:10:04 +00:00
conf: mount_autodev()
non-functional changes Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
@@ -1035,58 +1035,56 @@ fail:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Just create a path for /dev under $lxcpath/$name and in rootfs If we hit an
|
||||||
* Just create a path for /dev under $lxcpath/$name and in rootfs
|
* error, log it but don't fail yet.
|
||||||
* If we hit an error, log it but don't fail yet.
|
|
||||||
*/
|
*/
|
||||||
static int mount_autodev(const char *name, const struct lxc_rootfs *rootfs, const char *lxcpath)
|
static int mount_autodev(const char *name, const struct lxc_rootfs *rootfs,
|
||||||
|
const char *lxcpath)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
size_t clen;
|
size_t clen;
|
||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
INFO("Mounting container /dev");
|
INFO("Preparing \"/dev\"");
|
||||||
|
|
||||||
/* $(rootfs->mount) + "/dev/pts" + '\0' */
|
/* $(rootfs->mount) + "/dev/pts" + '\0' */
|
||||||
clen = (rootfs->path ? strlen(rootfs->mount) : 0) + 9;
|
clen = (rootfs->path ? strlen(rootfs->mount) : 0) + 9;
|
||||||
path = alloca(clen);
|
path = alloca(clen);
|
||||||
|
|
||||||
ret = snprintf(path, clen, "%s/dev", rootfs->path ? rootfs->mount : "");
|
ret = snprintf(path, clen, "%s/dev", rootfs->path ? rootfs->mount : "");
|
||||||
if (ret < 0 || ret >= clen)
|
if (ret < 0 || (size_t)ret >= clen)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!dir_exists(path)) {
|
if (!dir_exists(path)) {
|
||||||
WARN("No /dev in container.");
|
WARN("\"/dev\" directory does not exist. Proceeding without "
|
||||||
WARN("Proceeding without autodev setup");
|
"autodev being set up");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = safe_mount("none", path, "tmpfs", 0, "size=500000,mode=755",
|
ret = safe_mount("none", path, "tmpfs", 0, "size=500000,mode=755",
|
||||||
rootfs->path ? rootfs->mount : NULL);
|
rootfs->path ? rootfs->mount : NULL);
|
||||||
if (ret != 0) {
|
if (ret < 0) {
|
||||||
SYSERROR("Failed mounting tmpfs onto %s\n", path);
|
SYSERROR("Failed to mount tmpfs on \"%s\"", path);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
INFO("Mounted tmpfs on \"%s\"", path);
|
||||||
INFO("Mounted tmpfs onto %s", path);
|
|
||||||
|
|
||||||
ret = snprintf(path, clen, "%s/dev/pts", rootfs->path ? rootfs->mount : "");
|
ret = snprintf(path, clen, "%s/dev/pts", rootfs->path ? rootfs->mount : "");
|
||||||
if (ret < 0 || ret >= clen)
|
if (ret < 0 || (size_t)ret >= clen)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/*
|
/* 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...
|
||||||
*/
|
*/
|
||||||
if (!dir_exists(path)) {
|
if (!dir_exists(path)) {
|
||||||
ret = mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
|
ret = mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
|
||||||
if (ret) {
|
if (ret < 0) {
|
||||||
SYSERROR("Failed to create /dev/pts in container");
|
SYSERROR("Failed to create directory \"%s\"", path);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO("Mounted container /dev");
|
INFO("Prepared \"/dev\"");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user