1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/vendor/github.com/opencontainers/selinux/pkg/pwalk
Sebastiaan van Stijn ab06bb3ec0
vendor: opencontainers/selinux v1.7.0
full diff: https://github.com/opencontainers/selinux/compare/v1.6.0...v1.7.0

- Implement get_default_context_with_level() from libselinux
- Wrap some syscalls (lgetattr, lsetattr, fstatfs, statfs) to retry on EINTR.
- Improve code quality by turning fixing many problems found by linters
- Use bufio.Scanner for parsing labels and policy confilabelg
- Cache the value for SELinux policy directory
- test on ppc64le and go 1.15

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-12-22 13:57:09 +01:00
..
pwalk.go vendor: opencontainers/selinux v1.7.0 2020-12-22 13:57:09 +01:00
README.md vendor: opencontainers/selinux v1.5.1 2020-05-05 20:33:06 +02:00

pwalk: parallel implementation of filepath.Walk

This is a wrapper for filepath.Walk which may speed it up by calling multiple callback functions (WalkFunc) in parallel, utilizing goroutines.

By default, it utilizes 2*runtime.NumCPU() goroutines for callbacks. This can be changed by using WalkN function which has the additional parameter, specifying the number of goroutines (concurrency).

Caveats

Please note the following limitations of this code:

  • Unlike filepath.Walk, the order of calls is non-deterministic;

  • Only primitive error handling is supported:

    • filepath.SkipDir is not supported;

    • no errors are ever passed to WalkFunc;

    • once any error is returned from any WalkFunc instance, no more new calls to WalkFunc are made, and the error is returned to the caller of Walk;

    • if more than one walkFunc instance will return an error, only one of such errors will be propagated and returned by Walk, others will be silently discarded.

Documentation

For the official documentation, see https://pkg.go.dev/github.com/opencontainers/selinux/pkg/pwalk?tab=doc

Benchmarks

For a WalkFunc that consists solely of the return statement, this implementation is about 10% slower than the standard library's filepath.Walk.

Otherwise (if a WalkFunc is doing something) this is usually faster, except when the WalkN(..., 1) is used.