create_hardlink_dir(): fix wrong owner/perms case

In case CPT_HARDLINK_DIR exists, is a directory, but its
ownership and/or permissions are wrong, the best course
of action is not to remove it, but just fix what's wrong.
This is what this patch does.

In addition:

* mark create_hardlink_dir() as static (as it should be)
* report and return a potential error from stat() syscall,
  (as it should not happen and if it is, it's probably fatal)

This is an addition to commit 09e974f, also fixing bug #3222.

Reported-by: Pavel Odintsov <pavel.odintsov@gmail.com>
Reported-by: John Edel <john@jetfirenetworks.com>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
2 files changed