aboutsummaryrefslogtreecommitdiffstats
path: root/ports/unix/guts/mkdirat.c
blob: e0b6af9981143205dabd00ef88a42a0376593a13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* 
 * Copyright (c) 2008-2010, 2012 Wind River Systems; see
 * guts/COPYRIGHT for information.
 *
 * static int
 * wrap_mkdirat(int dirfd, const char *path, mode_t mode) {
 *	int rc = -1;
 */
	/* mask out mode bits appropriately */
	mode = mode & ~pseudo_umask;
#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
	if (dirfd != AT_FDCWD) {
		errno = ENOSYS;
		return -1;
	}

	rc = real_mkdir(path, PSEUDO_FS_MODE(mode, 1));
#else
	rc = real_mkdirat(dirfd, path, PSEUDO_FS_MODE(mode, 1));
#endif
	if (rc != -1) {
		PSEUDO_STATBUF buf;
		int stat_rc;

#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
		stat_rc = base_lstat(path, &buf);
#else
		stat_rc = base_fstatat(dirfd, path, &buf, AT_SYMLINK_NOFOLLOW);
#endif
		if (stat_rc != -1) {
			pseudo_client_op(OP_MKDIR, 0, -1, dirfd, path, &buf);
		} else {
			pseudo_debug(1, "mkdir of %s succeeded, but stat failed: %s\n",
				path, strerror(errno));
		}
	}

/*	return rc;
 * }
 */