xref: /titanic_50/usr/src/lib/libc/port/sys/chmod.c (revision 6a634c9dca3093f3922e4b7ab826d7bdf17bf78e)
1*794f0adbSRoger A. Faulkner /*
2*794f0adbSRoger A. Faulkner  * CDDL HEADER START
3*794f0adbSRoger A. Faulkner  *
4*794f0adbSRoger A. Faulkner  * The contents of this file are subject to the terms of the
5*794f0adbSRoger A. Faulkner  * Common Development and Distribution License (the "License").
6*794f0adbSRoger A. Faulkner  * You may not use this file except in compliance with the License.
7*794f0adbSRoger A. Faulkner  *
8*794f0adbSRoger A. Faulkner  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*794f0adbSRoger A. Faulkner  * or http://www.opensolaris.org/os/licensing.
10*794f0adbSRoger A. Faulkner  * See the License for the specific language governing permissions
11*794f0adbSRoger A. Faulkner  * and limitations under the License.
12*794f0adbSRoger A. Faulkner  *
13*794f0adbSRoger A. Faulkner  * When distributing Covered Code, include this CDDL HEADER in each
14*794f0adbSRoger A. Faulkner  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*794f0adbSRoger A. Faulkner  * If applicable, add the following below this CDDL HEADER, with the
16*794f0adbSRoger A. Faulkner  * fields enclosed by brackets "[]" replaced with your own identifying
17*794f0adbSRoger A. Faulkner  * information: Portions Copyright [yyyy] [name of copyright owner]
18*794f0adbSRoger A. Faulkner  *
19*794f0adbSRoger A. Faulkner  * CDDL HEADER END
20*794f0adbSRoger A. Faulkner  */
21*794f0adbSRoger A. Faulkner 
22*794f0adbSRoger A. Faulkner /*
23*794f0adbSRoger A. Faulkner  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24*794f0adbSRoger A. Faulkner  */
25*794f0adbSRoger A. Faulkner 
26*794f0adbSRoger A. Faulkner #include "lint.h"
27*794f0adbSRoger A. Faulkner #include <stdio.h>
28*794f0adbSRoger A. Faulkner #include <unistd.h>
29*794f0adbSRoger A. Faulkner #include <sys/types.h>
30*794f0adbSRoger A. Faulkner #include <sys/stat.h>
31*794f0adbSRoger A. Faulkner #include <sys/syscall.h>
32*794f0adbSRoger A. Faulkner #include <sys/fcntl.h>
33*794f0adbSRoger A. Faulkner 
34*794f0adbSRoger A. Faulkner int
fchmodat(int fd,const char * path,mode_t mode,int flag)35*794f0adbSRoger A. Faulkner fchmodat(int fd, const char *path, mode_t mode, int flag)
36*794f0adbSRoger A. Faulkner {
37*794f0adbSRoger A. Faulkner 	return (syscall(SYS_fchmodat, fd, path, mode, flag));
38*794f0adbSRoger A. Faulkner }
39*794f0adbSRoger A. Faulkner 
40*794f0adbSRoger A. Faulkner #pragma weak _chmod = chmod
41*794f0adbSRoger A. Faulkner int
chmod(const char * path,mode_t mode)42*794f0adbSRoger A. Faulkner chmod(const char *path, mode_t mode)
43*794f0adbSRoger A. Faulkner {
44*794f0adbSRoger A. Faulkner #if defined(_RETAIN_OLD_SYSCALLS)
45*794f0adbSRoger A. Faulkner 	return (syscall(SYS_chmod, path, mode));
46*794f0adbSRoger A. Faulkner #else
47*794f0adbSRoger A. Faulkner 	return (fchmodat(AT_FDCWD, path, mode, 0));
48*794f0adbSRoger A. Faulkner #endif
49*794f0adbSRoger A. Faulkner }
50*794f0adbSRoger A. Faulkner 
51*794f0adbSRoger A. Faulkner #pragma weak _fchmod = fchmod
52*794f0adbSRoger A. Faulkner int
fchmod(int fd,mode_t mode)53*794f0adbSRoger A. Faulkner fchmod(int fd, mode_t mode)
54*794f0adbSRoger A. Faulkner {
55*794f0adbSRoger A. Faulkner #if defined(_RETAIN_OLD_SYSCALLS)
56*794f0adbSRoger A. Faulkner 	return (syscall(SYS_fchmod, fd, mode));
57*794f0adbSRoger A. Faulkner #else
58*794f0adbSRoger A. Faulkner 	return (fchmodat(fd, NULL, mode, 0));
59*794f0adbSRoger A. Faulkner #endif
60*794f0adbSRoger A. Faulkner }
61