]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxccontainer: create_partial()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 24 Feb 2018 14:10:33 +0000 (15:10 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 23 Aug 2018 20:26:34 +0000 (22:26 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/lxccontainer.c

index 165c44107b0b8c561a0346ef08daf2cd218f162b..5884a7a7c3781a456e9b52c11552276df6bef4d2 100644 (file)
@@ -173,27 +173,30 @@ static int ongoing_create(struct lxc_container *c)
 
 static int create_partial(struct lxc_container *c)
 {
-       // $lxcpath + '/' + $name + '/partial' + \0
-       int len = strlen(c->config_path) + strlen(c->name) + 10;
-       char *path = alloca(len);
        int fd, ret;
+       size_t len;
+       char *path;
        struct flock lk;
 
+       /* $lxcpath + '/' + $name + '/partial' + \0 */
+       len = strlen(c->config_path) + strlen(c->name) + 10;
+       path = alloca(len);
        ret = snprintf(path, len, "%s/%s/partial", c->config_path, c->name);
-       if (ret < 0 || ret >= len) {
-               ERROR("Error writing partial pathname");
+       if (ret < 0 || (size_t)ret >= len)
                return -1;
-       }
-       if ((fd=open(path, O_RDWR | O_CREAT | O_EXCL, 0755)) < 0) {
-               SYSERROR("Error creating partial file");
+
+       fd = open(path, O_RDWR | O_CREAT | O_EXCL, 0755);
+       if (fd < 0)
                return -1;
-       }
+
        lk.l_type = F_WRLCK;
        lk.l_whence = SEEK_SET;
        lk.l_start = 0;
        lk.l_len = 0;
-       if (fcntl(fd, F_SETLKW, &lk) < 0) {
-               SYSERROR("Error locking partial file %s", path);
+
+       ret = fcntl(fd, F_SETLKW, &lk);
+       if (ret < 0) {
+               SYSERROR("Failed to lock partial file %s", path);
                close(fd);
                return -1;
        }