aboutsummaryrefslogtreecommitdiffstats
path: root/ports/unix/guts/fchmod.c
blob: 4d2d127969ede679ae2070fb5f87d435839f8956 (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
/* 
 * Copyright (c) 2008-2010, 2012, 2013 Wind River Systems; see
 * guts/COPYRIGHT for information.
 *
 * SPDX-License-Identifier: LGPL-2.1-only
 *
 * static int
 * wrap_fchmod(int fd, mode_t mode) {
 *	int rc = -1;
 */
	PSEUDO_STATBUF buf;
	int save_errno = errno;

	if (base_fstat(fd, &buf) == -1) {
		/* can't stat it, can't chmod it */
		return -1;
	}
	buf.st_mode = (buf.st_mode & ~07777) | (mode & 07777);
	pseudo_client_op(OP_FCHMOD, 0, fd, -1, 0, &buf);
	real_fchmod(fd, PSEUDO_FS_MODE(mode, S_ISDIR(buf.st_mode)));
        /* just pretend we worked */
        errno = save_errno;
        rc = 0;

/*	return rc;
 * }
 */