Commit Graph

3 Commits

Author SHA1 Message Date
Nalin Dahyabhai 1dbf430563 copier: add GetOptions.NoCrossDevice
Add a NoCrossDevice flag to GetOptions, telling it to ignore
subdirectories on devices different than the top reference directory
that we start from, i.e., ignore the contents of mounted filesystems.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-04-14 10:19:19 -04:00
Nalin Dahyabhai 348665657c copier: add Mkdir()
Add a function for doing Mkdir-possibly-in-a-chroot, for ensuring that a
directory exists without having to possibly create it directly from
outside of a chroot.

Make use of filepath.ToSlash() and filepath.FromSlash() where it's
appropriate.

Add more unit tests.

Address some review comments:

* Check for ERANGE instead of E2BIG errors from llistxattr() and
  lgetxattr() as indicators that the buffer we passed to them is too
  small.
* Factor an `isRelevantXattr` helper out of Lgetxattrs() and
  Lsetxattrs().
* Drop our getcwd() function in favor of using os.Getwd().
* Adjust the comment describing the GetOptions.KeepDirectoryNames field.
* Clean hdr.Name before attempting to compute where an item being
  extracted should go.
* When writing items to the filesystem, create with 0?00 permissions,
  set ownership, then set the correct permissions.
* Merge StatResponse.Error, GetResponse.Error, and PutResponse.Error
  into Response.Error.
* When reading items from the filesystem, if a glob matches multiple
  items, and one of the items is excluded, continue checking the other
  items.
* Make sure we always Wait() on a child process if we spawned one.
* Clean up the cleanup logic for pipes that we use to communicate with a
  child process.
* Clean up the kill-the-child-process logic we call when we encounter an
  error communicating with the child process.
* Drop the separate Options structure, use helper methods to simplify
  pulling out the right ID maps and exclusions list for the request.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-08-20 13:33:42 -04:00
Nalin Dahyabhai 36f4b8f7fa Add the "copier" package
Add new primitives for reading and writing data, represented as tar
streams, from and to possibly-chrooted directories via subprocesses.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-07-20 23:08:57 -04:00