aboutsummaryrefslogtreecommitdiffstats
path: root/guts/unlinkat.c
blob: cfa71e73fd042b9ad8f3446a0658a5abaaa14bc5 (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
41
42
43
44
/* 
 * static int
 * wrap_unlinkat(int dirfd, const char *path, int flags) {
 *	int rc = -1;
 */
#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
	if (dirfd != AT_FDCWD) {
		errno = ENOSYS;
		return -1;
	}
	if (flags) {
		/* the only supported flag is AT_REMOVEDIR.  We'd never call
		 * with that flag unless the real AT functions exist, so 
		 * something must have gone horribly wrong....
		 */
		pseudo_diag("wrap_unlinkat called with flags (0x%x), path '%s'\n",
			flags, path ? path : "<nil>");
		errno = ENOSYS;
		return -1;
	}
#endif

 	struct stat64 buf;

#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
	rc = real___lxstat64(_STAT_VER, path, &buf);
#else
	rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, AT_SYMLINK_NOFOLLOW);
#endif
	if (rc == -1) {
		return rc;
	}
#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
	rc = real_unlink(path);
#else
	rc = real_unlinkat(dirfd, path, flags);
#endif
	if (rc != -1) {
		pseudo_client_op(OP_UNLINK, AT_SYMLINK_NOFOLLOW, -1, dirfd, path, &buf);
	}

/*	return rc;
 * }
 */