]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
use lxc_mmap() and lxc_munmap()
authorChristian Brauner <christian.brauner@mailbox.org>
Sun, 27 Mar 2016 16:42:24 +0000 (18:42 +0200)
committerChristian Brauner <christian.brauner@mailbox.org>
Tue, 29 Mar 2016 06:48:27 +0000 (08:48 +0200)
Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
src/lxc/lxccontainer.c

index ab48fb586874df9675d7330a648fcdb8590554c3..8e2f41356b7a088160d8fdcee0aa040a838a9724 100644 (file)
@@ -2163,13 +2163,8 @@ static bool mod_rdep(struct lxc_container *c0, struct lxc_container *c, bool inc
                        }
 
                        if (fbuf.st_size != 0) {
-                               /* write terminating \0-byte to file */
-                               if (pwrite(fd, "", 1, fbuf.st_size) <= 0) {
-                                       close(fd);
-                                       goto out;
-                               }
 
-                               buf = mmap(NULL, fbuf.st_size + 1, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+                               buf = lxc_mmap(NULL, fbuf.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
                                if (buf == MAP_FAILED) {
                                        SYSERROR("Failed to create mapping %s", path);
                                        close(fd);
@@ -2182,7 +2177,7 @@ static bool mod_rdep(struct lxc_container *c0, struct lxc_container *c, bool inc
                                        bytes += len;
                                }
 
-                               munmap(buf, fbuf.st_size + 1);
+                               lxc_munmap(buf, fbuf.st_size);
                                if (ftruncate(fd, fbuf.st_size - bytes) < 0) {
                                        SYSERROR("Failed to truncate file %s", path);
                                        close(fd);