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
41
42
43
44
45
46
47
48
49
50
51
52
|
/*
* Copyright (c) 2008-2010 Wind River Systems; see
* guts/COPYRIGHT for information.
*
* static int
* wrap_symlinkat(const char *oldname, int dirfd, const char *newpath) {
* int rc = -1;
*/
struct stat64 buf;
char *roldname = 0;
if (oldname[0] == '/' && pseudo_chroot_len && !pseudo_nosymlinkexp) {
size_t len = pseudo_chroot_len + strlen(oldname) + 1;
roldname = malloc(len);
snprintf(roldname, len, "%s%s", pseudo_chroot, oldname);
}
#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
if (dirfd != AT_FDCWD) {
errno = ENOSYS;
return -1;
}
rc = real_symlink(roldname ? roldname : oldname, newpath);
#else
rc = real_symlinkat(roldname ? roldname : oldname, dirfd, newpath);
#endif
if (rc == -1) {
free(roldname);
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;
free(roldname);
return rc;
}
/* just record the entry */
pseudo_client_op(OP_SYMLINK, 0, -1, dirfd, newpath, &buf);
free(roldname);
/* return rc;
* }
*/
|