This adds a KeyLock struct and related functions trying to keep the same
semantic of DirLock.
KeyLock is a lock for a specific key. The lock file is created inside a
directory using the key name.
This is useful when multiple processes want to take a lock but cannot use
FileLock as they don't have a well defined file on the filesystem.
For example it's needed for image file locking and in future for download locking
This patch renames DirLock to FileLock (where a file can be a regular file or a
directory), adds a new LockType type to specify if the lock must be on a
directory or on a regular file and checks if the file is valid for the
requested type.
In creating a more general interface to the container dirs a method for
unlocking a DirLock without closing it became necessary.
This should have been added when lock.NewLock() became public.
This also restores atomic lock conversions
* Discard DirLock interface
* Convert private lock struct into public DirLock
* Convert private newLock function to public NewLock
* Introduce receiver-based analogs of all acquisition functions
* Convert existing open+acquire functions to use the public receiver-based
acquistion functions.
This moves to a very basic DirLock interface (which represents only an
active lock), and functions to create the respective lock types
(TryExclusiveLock, TrySharedLock, ...) instead of methods.
Add a simple package to facilitate placing an flock on directories. This
will be use to coordinate state between running containers and rkt
status/gc tools.