xref: /illumos-gate/usr/src/lib/libc/port/sys/chmod.c (revision 6a634c9d)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
59a70fc3bSMark J. Nelson  * Common Development and Distribution License (the "License").
69a70fc3bSMark J. Nelson  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*794f0adbSRoger A. Faulkner  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
247c478bd9Sstevel@tonic-gate  */
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 }