From aeea34d70951c0b9109fd69e92954e882bcf4d88 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Sun, 27 Mar 2016 18:42:24 +0200 Subject: [PATCH] use lxc_mmap() and lxc_munmap() Signed-off-by: Christian Brauner --- src/lxc/lxccontainer.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index ab48fb586..8e2f41356 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -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);