]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgfsng: convert_devpath()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 17 Feb 2018 18:46:44 +0000 (19:46 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 21 Feb 2018 14:48:48 +0000 (15:48 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c

index b292c59a74de483a81c12e366e81e13e15d9d6d5..aa6ca129cb7f7cfbe09214fbc9a2d05dec35681c 100644 (file)
@@ -2582,41 +2582,43 @@ static int cgfsng_set(const char *filename, const char *value, const char *name,
        return ret;
 }
 
-/*
- * take devices cgroup line
+/* take devices cgroup line
  *    /dev/foo rwx
  * and convert it to a valid
  *    type major:minor mode
- * line.  Return <0 on error.  Dest is a preallocated buffer
- * long enough to hold the output.
+ * line. Return <0 on error. Dest is a preallocated buffer long enough to hold
+ * the output.
  */
 static int convert_devpath(const char *invalue, char *dest)
 {
        int n_parts;
        char *p, *path, type;
-       struct stat sb;
        unsigned long minor, major;
+       struct stat sb;
        int ret = -EINVAL;
        char *mode = NULL;
 
        path = must_copy_string(invalue);
 
-       /*
-        * read path followed by mode;  ignore any trailing text.
-        * A '    # comment' would be legal.  Technically other text
-        * is not legal, we could check for that if we cared to
+       /* Read path followed by mode. Ignore any trailing text.
+        * A '    # comment' would be legal. Technically other text is not
+        * legal, we could check for that if we cared to.
         */
        for (n_parts = 1, p = path; *p && n_parts < 3; p++) {
                if (*p != ' ')
                        continue;
                *p = '\0';
+
                if (n_parts != 1)
                        break;
                p++;
                n_parts++;
+
                while (*p == ' ')
                        p++;
+
                mode = p;
+
                if (*p == '\0')
                        goto out;
        }
@@ -2637,7 +2639,7 @@ static int convert_devpath(const char *invalue, char *dest)
                type = 'c';
                break;
        default:
-               ERROR("Unsupported device type %i for %s", m, path);
+               ERROR("Unsupported device type %i for \"%s\"", m, path);
                ret = -EINVAL;
                goto out;
        }