void create_empty_dir_as_root(const char *dir, mode_t mode) {
	assert(dir);
	mode &= 07777;
	struct stat s;

	if (stat(dir, &s)) {
		if (arg_debug)
			printf("Creating empty %s directory\n", dir);
		/* coverity[toctou] */
		// don't fail if directory already exists. This can be the case in a race
		// condition, when two jails launch at the same time. See #1013
		mode_t tmp = umask(~mode); // let's avoid an extra chmod race
		int rv = mkdir(dir, mode);
		umask(tmp);
		if (rv < 0 && errno != EEXIST)
			errExit("mkdir");
	}

	ASSERT_PERMS(dir, 0, 0, mode);
}
void create_empty_dir_as_root(const char *dir, mode_t mode) {
	assert(dir);
	mode &= 07777;
	struct stat s;

	if (stat(dir, &s)) {
		if (arg_debug)
			printf("Creating empty %s directory\n", dir);
		 
		 
		 
		mode_t tmp = umask(~mode);  
		int rv = mkdir(dir, mode);
		umask(tmp);
		if (rv < 0 && errno != EEXIST)
			errExit("mkdir");
	}

	ASSERT_PERMS(dir, 0, 0, mode);
}