From: Christian Brauner Date: Sun, 27 Mar 2016 16:42:24 +0000 (+0200) Subject: use lxc_mmap() and lxc_munmap() X-Git-Tag: lxc-2.0.0.rc14~1^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aeea34d70951c0b9109fd69e92954e882bcf4d88;p=thirdparty%2Flxc.git use lxc_mmap() and lxc_munmap() Signed-off-by: Christian Brauner --- 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);