Commit aeea34d7 by Christian Brauner

use lxc_mmap() and lxc_munmap()

parent 1adbd020
...@@ -2163,13 +2163,8 @@ static bool mod_rdep(struct lxc_container *c0, struct lxc_container *c, bool inc ...@@ -2163,13 +2163,8 @@ static bool mod_rdep(struct lxc_container *c0, struct lxc_container *c, bool inc
} }
if (fbuf.st_size != 0) { 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) { if (buf == MAP_FAILED) {
SYSERROR("Failed to create mapping %s", path); SYSERROR("Failed to create mapping %s", path);
close(fd); close(fd);
...@@ -2182,7 +2177,7 @@ static bool mod_rdep(struct lxc_container *c0, struct lxc_container *c, bool inc ...@@ -2182,7 +2177,7 @@ static bool mod_rdep(struct lxc_container *c0, struct lxc_container *c, bool inc
bytes += len; bytes += len;
} }
munmap(buf, fbuf.st_size + 1); lxc_munmap(buf, fbuf.st_size);
if (ftruncate(fd, fbuf.st_size - bytes) < 0) { if (ftruncate(fd, fbuf.st_size - bytes) < 0) {
SYSERROR("Failed to truncate file %s", path); SYSERROR("Failed to truncate file %s", path);
close(fd); close(fd);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment