]> git.proxmox.com Git - mirror_lxc.git/commitdiff
conf: mount_autodev()
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 1 Aug 2017 20:54:09 +0000 (22:54 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 1 Aug 2017 23:37:02 +0000 (01:37 +0200)
non-functional changes

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

index eb427baf7c94d9dd5053bf2f3ca0487670299dbe..eca5cf7944da35714c0489856cbc139176f23fcf 100644 (file)
@@ -1035,58 +1035,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;
 }