[lxc-devel] [PATCH] New approach to remove container entry from lxc_snapshots
Christian Brauner
christianvanbrauner at gmail.com
Wed Sep 9 19:22:31 UTC 2015
I want to avoid having to use the GNU-extension memmem() when removing the
container entry. As mmap() does not guarantee us a \0-terminated string we
lseek() to the end of the file and write() a single terminating \0-byte to the
file and the mmap() the file. The terminating \0-byte will then be removed when
we ftruncate() the file after we have removed the entry. This allows us to use
standard string-handling functions like strstr(). We wrap strstr() in a while
loop to remove duplicate entries.
This patch is unnecessary if using memmem() does not bother anyone but me.
(Someone should also please check if my calculations for memmove() and
ftruncate() are correct.)
Christian Brauner (1):
Ensure that mmap()ed memory is \0-terminated lseek() to end of
file and write() terminating \0-byte
src/lxc/lxccontainer.c | 88 +++++++++++++++++++++++++++-----------------------
1 file changed, 48 insertions(+), 40 deletions(-)
--
2.5.1
More information about the lxc-devel
mailing list