[lxc-devel] [lxc/lxc] 1adbd0: add funs to mmap() files to \0-terminated strings

GitHub noreply at github.com
Tue Mar 29 16:11:39 UTC 2016


  Branch: refs/heads/master
  Home:   https://github.com/lxc/lxc
  Commit: 1adbd02064e10645cdd05a813e23cce2ccb1a4de
      https://github.com/lxc/lxc/commit/1adbd02064e10645cdd05a813e23cce2ccb1a4de
  Author: Christian Brauner <christian.brauner at mailbox.org>
  Date:   2016-03-29 (Tue, 29 Mar 2016)

  Changed paths:
    M src/lxc/utils.c
    M src/lxc/utils.h

  Log Message:
  -----------
  add funs to mmap() files to \0-terminated strings

In order to do this we make use of the MAP_FIXED flag of mmap(). MAP_FIXED
should be safe to use when it replaces an already existing mapping. To this
end, we establish an anonymous mapping that is one byte larger than the
underlying file. The pages handed to us are zero filled.  Now we establish a
fixed-address mapping starting at the address we received from our anonymous
mapping and replace all bytes excluding the additional \0-byte with the file.
This allows us to use normal string-handling function. The idea implemented
here is similar to how shared libraries are mapped.

Signed-off-by: Christian Brauner <christian.brauner at mailbox.org>


  Commit: aeea34d70951c0b9109fd69e92954e882bcf4d88
      https://github.com/lxc/lxc/commit/aeea34d70951c0b9109fd69e92954e882bcf4d88
  Author: Christian Brauner <christian.brauner at mailbox.org>
  Date:   2016-03-29 (Tue, 29 Mar 2016)

  Changed paths:
    M src/lxc/lxccontainer.c

  Log Message:
  -----------
  use lxc_mmap() and lxc_munmap()

Signed-off-by: Christian Brauner <christian.brauner at mailbox.org>


  Commit: 25086a5fe4f4b8a000e4ca2d184efd3ed7810c65
      https://github.com/lxc/lxc/commit/25086a5fe4f4b8a000e4ca2d184efd3ed7810c65
  Author: Christian Brauner <christian.brauner at mailbox.org>
  Date:   2016-03-29 (Tue, 29 Mar 2016)

  Changed paths:
    M src/lxc/lxccontainer.c
    M src/lxc/utils.c
    M src/lxc/utils.h

  Log Message:
  -----------
  better naming for mmap helpers

Rename lxc_mmap()/lxc_munmap() to lxc_strmmap()/lxc_strmunmap().

Signed-off-by: Christian Brauner <christian.brauner at mailbox.org>


  Commit: 03faa6217081e762b19e462878e814c25cc36398
      https://github.com/lxc/lxc/commit/03faa6217081e762b19e462878e814c25cc36398
  Author: Serge Hallyn <serge at hallyn.com>
  Date:   2016-03-29 (Tue, 29 Mar 2016)

  Changed paths:
    M src/lxc/lxccontainer.c
    M src/lxc/utils.c
    M src/lxc/utils.h

  Log Message:
  -----------
  Merge pull request #926 from brauner/2016-03-27/mmap_file_to_str

add funs to mmap() files to \0-terminated strings


Compare: https://github.com/lxc/lxc/compare/bc41134fc6a5...03faa6217081


More information about the lxc-devel mailing list