}
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);
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);