Add better ".git" detection and use

This way, packagers can set GIT_DIR appropriately if they'd prefer to not have ".git" inside their working directory.

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
devmapper: Fix shutdown warnings

Shutdown contains debug warnings like:

[debug] deviceset.go:699 [deviceset docker-0:33-17945897] waitRemove(/dev/mapper/docker-0:33-17945897-pool)
[debug] deviceset.go:380 libdevmapper(3): libdm-common.c:552 (-1) Device /dev/mapper/docker-0:33-17945897-pool not found

This is because shutdown is using removeDeviceAndWait() to remove the pool device and the
wait part fails because the pool is gone.

We fix this by adding a pool specific removal function which avoids all the trickiness of the
normal remove.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
devmapper: Remove byHash hack

We no longer pass "pool" anywhere that uses byHash() per the last
commit, so we can now remove this hack.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Ensure docker cp stream is closes properly
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
add error to docekr build --rm

Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)
disallow tcp:// from defaulting to 127.0.0.1:4243

This stops docker from accepting tcp:// as a valid bind address.

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
Merge pull request #4073 from crosbymichael/fix-docker-cp-close

Ensure docker cp stream is closed properly
Merge pull request #4056 from alexlarsson/fix-devmapper-test

devicemapper: Fix tests on fedora
Merge pull request #4043 from tianon/hack-git-detection-and-use

Add better ".git" detection and use
Merge pull request #4096 from alexlarsson/fix-devmapper-race-2

Avoid extra mount/unmount during build
remove unneeded sysctl changes in sysvinit-redhat init script

Docker-DCO-1.1-Signed-off-by: Adam Miller <admiller@redhat.com> (github: maxamillion)
Merge pull request #4103 from vieux/add_error_build-rm

add error to docker build --rm
Merge pull request #4062 from alexlarsson/clean-shutdown

devmapper: Fix shutdown warnings
Merge pull request #4108 from unclejack/remove_default_tcp_bind_address

disallow tcp:// from defaulting to 127.0.0.1:4243
Merge pull request #4125 from maxamillion/maxamillion/add_redhat_sysvinit

Remove unneeded sysctl changes in sysvinit-redhat init script
Move EofReader to utils

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Add overlayfs graph backend

This backend uses the overlayfs union filesystem for containers
plus hard link file sharing for images.

Each container/image can have a "root" subdirectory which is a plain
filesystem hierarchy, or they can use overlayfs.

If they use overlayfs there is a "rw" directory and a "rw-parent"
file, as well as an "overlay" directory. The "rw" directory has the
upper layer of the overlay, and "rw-parent" contains the id of the
parent whose "root" directory shal be used as the lower layer in the
overlay. The overlay itself is mounted in the "overlay" directory.

When a overlay layer is created there are two cases, either the
parent has a "root" dir, then we start out with a empty "rw"
directory overlaid on the parents root. This is typically the
case with the $container-init layer which is based on an image.
If there is no "root" in the parent, we inherit the rw-root from
the parent and start by making a copy if the parents "rw" dir.
This is typically the case for a container layer which copies
its parent -init rw layer.

Additionally we also have a custom implementation of ApplyLayer
which makes a recursive copy of the parent "root" layer using
hardlinks to share file data, and then applies the layer on top
of that. This means all images share file (but not directory)
data.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)