employ gnu99 style of GCC

This patch lets sheepdog employ gnu99 (C99 + gnu extensions) style of
GCC. The main benefit of gnu99 is allowing interleaved statements and
declarations. sheepdog source tree has many functions with lots of
local variable declarations on their head part. They are harmful from
the perspective of readability. Basically, variable declarations
should be delayed until they are actually required. With gnu99, we can
write interleaved statements and declarations, so this can improve the
readability of sheepdog.

The RB_ROOT constant is not friendly with gnu99, so this patch also
add a minor change to it. In addition, RB_ROOT cannot be used in
statements (not declarations). This patch also prepares a new macro
INIT_RB_ROOT() for such usecases.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: implement a correct mutex of a base directory

Current lockf() usage in lock_base_dir() is invalid bacause sheep
calls daemon(3) after the lockf(). daemon(3) forks internally and a
parent process exits immediately. In a case of sheep, daemon() must be
called after locking base dir so the lock owner, parent process, exits
and the lock will be released even though the child process is
running. This is the reason current lock_base_dir() doesn't work
well. And it causes writing logs to sheep.log from multiple
sheeps. This phenomenon is very confusing and should be avoided.

This patch implement custom function for daemonizing,
lock_and_daemon(). And mutex of base directory is done in
it. lock_and_daemon() does mutex between fork() and closing fd 0, 1,
and 2, so it can report the failure of mutexing base directory to
stderr.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>