aboutsummaryrefslogtreecommitdiffstats
path: root/ports/unix/guts/access.c
blob: 1cc8d5858c587e0c0aaf608a1d71d763b98c5aff (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
/* 
 * Copyright (c) 2010, 2012 Wind River Systems; see
 * guts/COPYRIGHT for information.
 *
 * SPDX-License-Identifier: LGPL-2.1-only
 *
 * static int
 * wrap_access(const char *path, int mode) {
 *	int rc = -1;
 */
	PSEUDO_STATBUF buf;

	/* note:  no attempt to handle the case where user isn't
	 * root.
	 */
	rc = base_stat(path, &buf);
	if (rc == -1)
		return rc;

	if (mode & X_OK) {
		if (buf.st_mode & 0111) {
			return 0;
		} else {
			errno = EPERM;
			return -1;
		}
	} else {
		return 0;
	}

/*	return rc;
 * }
 */