crtools: bump up the getopt return values to outside the ascii range

The return values were getting dangerously close to the range of meaningful
values, in particular the next candidate 63 is equal to '?' which is the
typical return value in case of error.

The return values for long options may be any integer, so bump them up to
outside the ascii range, start above 1000. For ease of review this patch, keep
the existing range (41-62) and increment each value by 1000.

Tested:
- Ran "criu --help", works fine.
- Manual dump and restore with some of the options, worked fine.
- Ran the zdtm test suite, tests passed.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cgroups: don't take into account a leading / for the "/" parent

Without this patch, we dump somethin like this:
{
	cnames: "hugetlb"
	dirs: 	{
		dir_name: ""
		children: 		{
			dir_name: "ewroot"
			children: <empty>
			properties: <empty>
		}

		properties: <empty>
	}

}

It's obvious, that dir_name should be newroot.

The problem is reproduced, if a task leaves in "/" and has a subgroup.
This issue was caught by a chance. The cgroup02 test doesn't clean up
controllers and leaves the "newroot" there. So when we executed a cgroup
test after cgroup02, we could find many directories like "ewroot",
"wroot", etc. This patch fixes this issue.

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cgroup: call fin_cgroup() on error paths

fini_cgroup umounts a cgyard directory, which is mounted
in prepare_cgroup().

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: fix compile errors of zdtm_ct

When "make test" is executed, CFLAGS is exported from the root Makefile.
These flags define _GNU_SOURCE, so we don't need to define it in the
souce file.

In addition unistd.h isn't included, so a few functions are shown as undeclared.

make zdtm_ns
make[3]: Entering directory `/root/criu/test'
gcc  -O2 -Wall -Werror -DCONFIG_X86_64 -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE    zdtm_ct.c   -o zdtm_ct
zdtm_ct.c:1:0: error: "_GNU_SOURCE" redefined [-Werror]
 #define _GNU_SOURCE
 ^
<command-line>:0:0: note: this is the location of the previous definition
zdtm_ct.c: In function ‘main’:
zdtm_ct.c:21:2: error: implicit declaration of function ‘fork’ [-Werror=implicit-function-declaration]
  pid = fork();
  ^
zdtm_ct.c:23:3: error: implicit declaration of function ‘setsid’ [-Werror=implicit-function-declaration]
   if (setsid() == -1) {
   ^
zdtm_ct.c:49:3: error: implicit declaration of function ‘execv’ [-Werror=implicit-function-declaration]
   execv(argv[1], argv + 1);
   ^
zdtm_ct.c:62:3: error: implicit declaration of function ‘getpid’ [-Werror=implicit-function-declaration]
   kill(getpid(), WTERMSIG(status));
   ^
cc1: all warnings being treated as errors

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Tested-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
test/cgroup02: Clean newroot dir from all controllers in hooks

From avagin@:
  And here is one more problem. the newroot directory is created for all
  controllers, but currently test cleans up it only for the zdtmtst
  controller. We need to find a way to clean up all other conntrollers.
   Tests are executed on a node, which is rebooted only for updating
  kernel, so if we will not clean up all other controllers, we can eat all
  memory.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Tested-by: Andrew Vagin <avagin@openvz.org>