[lxc-devel] [PATCH] New approach to remove container entry from lxc_snapshots (v2)
Christian Brauner
christianvanbrauner at gmail.com
Wed Sep 9 19:48:02 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
pwrite() a single terminating \0-byte after the end of 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 container 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 (v2) Use pwrite() to
write terminating \0-byte
src/lxc/lxccontainer.c | 85 ++++++++++++++++++++++++++------------------------
1 file changed, 44 insertions(+), 41 deletions(-)
--
2.5.1
More information about the lxc-devel
mailing list