aboutsummaryrefslogtreecommitdiffstats
path: root/ports/unix/guts/opendir.c
blob: c8a78f8fb96c1d98bafde6f06982196360bcc93d (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
/* 
 * Copyright (c) 2010, 2012 Wind River Systems; see
 * guts/COPYRIGHT for information.
 *
 * static DIR *
 * wrap_opendir(const char *path) {
 *	DIR * rc = NULL;
 */
 	PSEUDO_STATBUF buf;
	int save_errno;

	rc = real_opendir(path);
	if (rc) {
		int fd;
		save_errno = errno;
		fd = dirfd(rc);
		if (base_fstat(fd, &buf) == -1) {
			pseudo_debug(PDBGF_CONSISTENCY, "diropen (fd %d) succeeded, but fstat failed (%s).\n",
				fd, strerror(errno));
			pseudo_client_op(OP_OPEN, PSA_READ, fd, -1, path, 0);
		} else {
			pseudo_client_op(OP_OPEN, PSA_READ, fd, -1, path, &buf);
		}


		errno = save_errno;
	}

/*	return rc;
 * }
 */