]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: mount_autodev()
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 1 Aug 2017 20:54:09 +0000 (22:54 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 15 Aug 2017 20:36:28 +0000 (16:36 -0400)
non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c

index f5fdb5ea7b3e3e7a9b60bf8648d43aade5237b77..87d761f6e96a749d067081a0686281a629a2aebd 100644 (file)
@@ -976,58 +976,56 @@ fail:
        return -1;
 }
 
-/*
- * Just create a path for /dev under $lxcpath/$name and in rootfs
- * If we hit an error, log it but don't fail yet.
+/* Just create a path for /dev under $lxcpath/$name and in rootfs 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;
        size_t clen;
        char *path;
 
-       INFO("Mounting container /dev");
+       INFO("Preparing \"/dev\"");
 
        /* $(rootfs->mount) + "/dev/pts" + '\0' */
        clen = (rootfs->path ? strlen(rootfs->mount) : 0) + 9;
        path = alloca(clen);
 
        ret = snprintf(path, clen, "%s/dev", rootfs->path ? rootfs->mount : "");
-       if (ret < 0 || ret >= clen)
+       if (ret < 0 || (size_t)ret >= clen)
                return -1;
 
        if (!dir_exists(path)) {
-               WARN("No /dev in container.");
-               WARN("Proceeding without autodev setup");
+               WARN("\"/dev\" directory does not exist. Proceeding without "
+                    "autodev being set up");
                return 0;
        }
 
        ret = safe_mount("none", path, "tmpfs", 0, "size=500000,mode=755",
-                       rootfs->path ? rootfs->mount : NULL);
-       if (ret != 0) {
-               SYSERROR("Failed mounting tmpfs onto %s\n", path);
+                        rootfs->path ? rootfs->mount : NULL);
+       if (ret < 0) {
+               SYSERROR("Failed to mount tmpfs on \"%s\"", path);
                return -1;
        }
-
-       INFO("Mounted tmpfs onto %s",  path);
+       INFO("Mounted tmpfs on \"%s\"", path);
 
        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;
 
-       /*
-        * 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 (!dir_exists(path)) {
                ret = mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
-               if (ret) {
-                       SYSERROR("Failed to create /dev/pts in container");
+               if (ret < 0) {
+                       SYSERROR("Failed to create directory \"%s\"", path);
                        return -1;
                }
        }
 
-       INFO("Mounted container /dev");
+       INFO("Prepared \"/dev\"");
        return 0;
 }