Add rich errors to the API

Add a rich Error type to the libcontainer package and use it in the API so
that callers can:

  * Check for a specific error without depending on an error string,
  * Obtain the stack trace of the function or method which detected the error.

The Error type provides a typed error code and a stack trace. The error code
identifies the error and enables the caller to test for it without being
sensitive to changes in the error text. The stack trace identifies the point
at which the error was detected. The combination of error code and stack trace
will enable errors to be diagnosed much more easily and with less guesswork
than when raw string-based errors are used.

The Error type conforms to the error interface and its Error method prints a
short error message. The Detail method provides a verbose error message
including the stack trace.

Notes:

1. There is an unfortunate precedent in the Go standard library which uses
variables to define errors. Checking for a specific error involves a string
comparison and assumes the corresponding variable has not been updated. It is
more robust and efficient to identify errors with integer-based types and
associated constants, although errors should still include a string
description for ease of use by humans.

2. It is not feasible to assign distinct types to Factory and Container
error codes because common errors such as SystemError cannot be declared in
two places and the names of the error codes then need to be decorated. This is
less readable.

Signed-off-by: Steve Powell <spowell@pivotal.io>
Unify the errors ProcessConfigInvalid and ConfigInvalid to avoid caller confusion.

There is no check that these are being confused since they are both in the same type.

Signed-off-by: Steve Powell <spowell@pivotal.io>
Cache cgroup root mount location.

We calculate this on every cgroup call. It comprised of 30%+ of the CPU
usage in cAdvisor.

Docker-DCO-1.1-Signed-off-by: Victor Marmol <vmarmol@google.com> (github: vmarmol)
Merge pull request #189 from vmarmol/cache-mounts

Cache cgroup root mount location.
Merge pull request #185 from cf-guardian/typed_errors

Add rich errors to the API
netlink: Cache native endianness during init

Signed-off-by: Jonathan Rudenberg <jonathan@titanous.com>
netlink: Extract message checks into reusable method

Signed-off-by: Jonathan Rudenberg <jonathan@titanous.com>
netlink: Cleanup veth pair created during tests

Signed-off-by: Jonathan Rudenberg <jonathan@titanous.com>
Merge pull request #190 from titanous/netlink-cleanup

Netlink cleanup
netlink: Add uint32Attr helper

Signed-off-by: Jonathan Rudenberg <jonathan@titanous.com>
Merge pull request #192 from titanous/netlink-cleanup

netlink: Add uint32Attr helper
netlink: Add NetworkSetMacAddress

Signed-off-by: Lewis Marshall <lewis@lmars.net>
Merge pull request #194 from lmars/netlink-set-mac-addr

netlink: Add NetworkSetMacAddress
Refactored and added more tests.Cleaned up netlink.

I've added more tests. We now have almost 55% coverage.
I've also reorganized netlink_linux codebase and moved
the non-RTNETLINK functions at the bottom. I've also
added some comments to some functions.

Docker-DCO-1.1-Signed-off-by: Milos Gajdos <milosgajdos83@gmail.com> (github: milosgajdos83)
Fixing Travis builds by allowing short tests.

Docker-DCO-1.1-Signed-off-by: Milos Gajdos <milosgajdos83@gmail.com> (github: milosgajdos83)
Merge pull request #197 from milosgajdos83/netlink-tests

Refactored and added more tests.Cleaned up netlink a bit.
Add RootFs field to configuration options in libcontainer's Config

Since currently the container.json file does not include the pathname
to a container's root filesystem, we need to parse /proc/mounts which
is slow and error-prone.  This patch addresses this issue by adding a
new RootFs field.

Signed-off-by: Saied Kazemi <saied@google.com>
Add RootFs field to configuration options in libcontainer's Config

Since currently the container.json file does not include the pathname
to a container's root filesystem, we need to parse /proc/mounts which
is slow and error-prone.  This patch addresses this issue by adding a
new RootFs field.

Signed-off-by: Saied Kazemi <saied@google.com>
Merge branch 'rootfs' of https://github.com/SaiedKazemi/libcontainer into rootfs

Conflicts:
	namespaces/exec.go
Merge pull request #199 from SaiedKazemi/rootfs

Add RootFs field to configuration options in libcontainer's Config