aboutsummaryrefslogtreecommitdiffstats
path: root/guts/symlinkat.c
blob: 5f1cc59a7b8cade08bd76bcd582551fd6bae6a1b (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
/* 
 * static int
 * wrap_symlinkat(const char *oldpath, int dirfd, const char *newpath) {
 *	int rc = -1;
 */
 	struct stat64 buf;

#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
	if (dirfd != AT_FDCWD) {
		errno = ENOSYS;
		return -1;
	}
	rc = real_symlink(oldpath, newpath);
#else
	rc = real_symlinkat(oldpath, dirfd, newpath);
#endif

	if (rc == -1) {
		return rc;
	}
#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
	rc = real___lxstat64(_STAT_VER, newpath, &buf);
#else
	rc = real___fxstatat64(_STAT_VER, dirfd, newpath, &buf, AT_SYMLINK_NOFOLLOW);
#endif
	if (rc == -1) {
		int save_errno = errno;
		pseudo_diag("symlinkat: couldn't stat '%s' even though symlink creation succeeded (%s).\n",
			newpath, strerror(errno));
		errno = save_errno;
		return rc;
	}
	/* just record the entry */
	pseudo_client_op(OP_SYMLINK, AT_SYMLINK_NOFOLLOW, -1, dirfd, newpath, &buf);

/*	return rc;
 * }
 */