18fd04b83SRoger A. Faulkner /*
28fd04b83SRoger A. Faulkner  * CDDL HEADER START
38fd04b83SRoger A. Faulkner  *
48fd04b83SRoger A. Faulkner  * The contents of this file are subject to the terms of the
58fd04b83SRoger A. Faulkner  * Common Development and Distribution License (the "License").
68fd04b83SRoger A. Faulkner  * You may not use this file except in compliance with the License.
78fd04b83SRoger A. Faulkner  *
88fd04b83SRoger A. Faulkner  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
98fd04b83SRoger A. Faulkner  * or http://www.opensolaris.org/os/licensing.
108fd04b83SRoger A. Faulkner  * See the License for the specific language governing permissions
118fd04b83SRoger A. Faulkner  * and limitations under the License.
128fd04b83SRoger A. Faulkner  *
138fd04b83SRoger A. Faulkner  * When distributing Covered Code, include this CDDL HEADER in each
148fd04b83SRoger A. Faulkner  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
158fd04b83SRoger A. Faulkner  * If applicable, add the following below this CDDL HEADER, with the
168fd04b83SRoger A. Faulkner  * fields enclosed by brackets "[]" replaced with your own identifying
178fd04b83SRoger A. Faulkner  * information: Portions Copyright [yyyy] [name of copyright owner]
188fd04b83SRoger A. Faulkner  *
198fd04b83SRoger A. Faulkner  * CDDL HEADER END
208fd04b83SRoger A. Faulkner  */
218fd04b83SRoger A. Faulkner 
228fd04b83SRoger A. Faulkner /*
2380e2ca85S  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
248fd04b83SRoger A. Faulkner  */
258fd04b83SRoger A. Faulkner 
268fd04b83SRoger A. Faulkner #include <stdio.h>
278fd04b83SRoger A. Faulkner #include <stdlib.h>
288fd04b83SRoger A. Faulkner #include <unistd.h>
298fd04b83SRoger A. Faulkner #include <fcntl.h>
308fd04b83SRoger A. Faulkner #include <utime.h>
318fd04b83SRoger A. Faulkner #include <errno.h>
328fd04b83SRoger A. Faulkner #include <sys/types.h>
338fd04b83SRoger A. Faulkner #include <sys/stat.h>
348fd04b83SRoger A. Faulkner #include <sys/time.h>
358fd04b83SRoger A. Faulkner #include <sys/poll.h>
368fd04b83SRoger A. Faulkner #include <sys/file.h>
378fd04b83SRoger A. Faulkner #include <sys/syscall.h>
388fd04b83SRoger A. Faulkner 
398fd04b83SRoger A. Faulkner #include <s10_brand.h>
4080e2ca85S #include <brand_misc.h>
418fd04b83SRoger A. Faulkner #include <s10_misc.h>
428fd04b83SRoger A. Faulkner 
438fd04b83SRoger A. Faulkner /*
448fd04b83SRoger A. Faulkner  * This file contains the emulation functions for all of the
458fd04b83SRoger A. Faulkner  * obsolete system call traps that existed in Solaris 10 but
468fd04b83SRoger A. Faulkner  * that have been deleted in the current version of Solaris.
478fd04b83SRoger A. Faulkner  */
488fd04b83SRoger A. Faulkner 
498fd04b83SRoger A. Faulkner static int
s10_fstatat(sysret_t * rval,int fd,const char * path,struct stat * sb,int flags)508fd04b83SRoger A. Faulkner s10_fstatat(sysret_t *rval,
518fd04b83SRoger A. Faulkner     int fd, const char *path, struct stat *sb, int flags)
528fd04b83SRoger A. Faulkner {
538fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_fstatat + 1024,
548fd04b83SRoger A. Faulkner 	    fd, path, sb, flags));
558fd04b83SRoger A. Faulkner }
568fd04b83SRoger A. Faulkner 
578fd04b83SRoger A. Faulkner int
s10_stat(sysret_t * rval,const char * path,struct stat * sb)588fd04b83SRoger A. Faulkner s10_stat(sysret_t *rval, const char *path, struct stat *sb)
598fd04b83SRoger A. Faulkner {
608fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_fstatat + 1024,
618fd04b83SRoger A. Faulkner 	    AT_FDCWD, path, sb, 0));
628fd04b83SRoger A. Faulkner }
638fd04b83SRoger A. Faulkner 
648fd04b83SRoger A. Faulkner int
s10_lstat(sysret_t * rval,const char * path,struct stat * sb)658fd04b83SRoger A. Faulkner s10_lstat(sysret_t *rval, const char *path, struct stat *sb)
668fd04b83SRoger A. Faulkner {
678fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_fstatat + 1024,
688fd04b83SRoger A. Faulkner 	    AT_FDCWD, path, sb, AT_SYMLINK_NOFOLLOW));
698fd04b83SRoger A. Faulkner }
708fd04b83SRoger A. Faulkner 
718fd04b83SRoger A. Faulkner int
s10_fstat(sysret_t * rval,int filedes,struct stat * sb)728fd04b83SRoger A. Faulkner s10_fstat(sysret_t *rval, int filedes, struct stat *sb)
738fd04b83SRoger A. Faulkner {
748fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_fstatat + 1024,
758fd04b83SRoger A. Faulkner 	    filedes, NULL, sb, 0));
768fd04b83SRoger A. Faulkner }
778fd04b83SRoger A. Faulkner 
788fd04b83SRoger A. Faulkner #if !defined(_LP64)
798fd04b83SRoger A. Faulkner 
808fd04b83SRoger A. Faulkner static int
s10_fstatat64(sysret_t * rval,int fd,const char * path,struct stat64 * sb,int flags)818fd04b83SRoger A. Faulkner s10_fstatat64(sysret_t *rval,
828fd04b83SRoger A. Faulkner     int fd, const char *path, struct stat64 *sb, int flags)
838fd04b83SRoger A. Faulkner {
848fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_fstatat64 + 1024,
858fd04b83SRoger A. Faulkner 	    fd, path, sb, flags));
868fd04b83SRoger A. Faulkner }
878fd04b83SRoger A. Faulkner 
888fd04b83SRoger A. Faulkner int
s10_stat64(sysret_t * rval,const char * path,struct stat64 * sb)898fd04b83SRoger A. Faulkner s10_stat64(sysret_t *rval, const char *path, struct stat64 *sb)
908fd04b83SRoger A. Faulkner {
918fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_fstatat64 + 1024,
928fd04b83SRoger A. Faulkner 	    AT_FDCWD, path, sb, 0));
938fd04b83SRoger A. Faulkner }
948fd04b83SRoger A. Faulkner 
958fd04b83SRoger A. Faulkner int
s10_lstat64(sysret_t * rval,const char * path,struct stat64 * sb)968fd04b83SRoger A. Faulkner s10_lstat64(sysret_t *rval, const char *path, struct stat64 *sb)
978fd04b83SRoger A. Faulkner {
988fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_fstatat64 + 1024,
998fd04b83SRoger A. Faulkner 	    AT_FDCWD, path, sb, AT_SYMLINK_NOFOLLOW));
1008fd04b83SRoger A. Faulkner }
1018fd04b83SRoger A. Faulkner 
1028fd04b83SRoger A. Faulkner int
s10_fstat64(sysret_t * rval,int filedes,struct stat64 * sb)1038fd04b83SRoger A. Faulkner s10_fstat64(sysret_t *rval, int filedes, struct stat64 *sb)
1048fd04b83SRoger A. Faulkner {
1058fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_fstatat64 + 1024,
1068fd04b83SRoger A. Faulkner 	    filedes, NULL, sb, 0));
1078fd04b83SRoger A. Faulkner }
1088fd04b83SRoger A. Faulkner 
1098fd04b83SRoger A. Faulkner #endif	/* !_LP64 */
1108fd04b83SRoger A. Faulkner 
1118fd04b83SRoger A. Faulkner static int
s10_openat(sysret_t * rval,int fd,const char * path,int oflag,mode_t mode)1128fd04b83SRoger A. Faulkner s10_openat(sysret_t *rval, int fd, const char *path, int oflag, mode_t mode)
1138fd04b83SRoger A. Faulkner {
1148fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_openat + 1024,
1158fd04b83SRoger A. Faulkner 	    fd, path, oflag, mode));
1168fd04b83SRoger A. Faulkner }
1178fd04b83SRoger A. Faulkner 
1188fd04b83SRoger A. Faulkner int
s10_open(sysret_t * rval,char * path,int oflag,mode_t mode)1198fd04b83SRoger A. Faulkner s10_open(sysret_t *rval, char *path, int oflag, mode_t mode)
1208fd04b83SRoger A. Faulkner {
1218fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_openat + 1024,
1228fd04b83SRoger A. Faulkner 	    AT_FDCWD, path, oflag, mode));
1238fd04b83SRoger A. Faulkner }
1248fd04b83SRoger A. Faulkner 
1258fd04b83SRoger A. Faulkner int
s10_creat(sysret_t * rval,char * path,mode_t mode)1268fd04b83SRoger A. Faulkner s10_creat(sysret_t *rval, char *path, mode_t mode)
1278fd04b83SRoger A. Faulkner {
1288fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_openat + 1024,
1298fd04b83SRoger A. Faulkner 	    AT_FDCWD, path, O_WRONLY | O_CREAT | O_TRUNC, mode));
1308fd04b83SRoger A. Faulkner }
1318fd04b83SRoger A. Faulkner 
1328fd04b83SRoger A. Faulkner #if !defined(_LP64)
1338fd04b83SRoger A. Faulkner 
1348fd04b83SRoger A. Faulkner static int
s10_openat64(sysret_t * rval,int fd,const char * path,int oflag,mode_t mode)1358fd04b83SRoger A. Faulkner s10_openat64(sysret_t *rval, int fd, const char *path, int oflag, mode_t mode)
1368fd04b83SRoger A. Faulkner {
1378fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_openat64 + 1024,
1388fd04b83SRoger A. Faulkner 	    fd, path, oflag, mode));
1398fd04b83SRoger A. Faulkner }
1408fd04b83SRoger A. Faulkner 
1418fd04b83SRoger A. Faulkner int
s10_open64(sysret_t * rval,char * path,int oflag,mode_t mode)1428fd04b83SRoger A. Faulkner s10_open64(sysret_t *rval, char *path, int oflag, mode_t mode)
1438fd04b83SRoger A. Faulkner {
1448fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_openat64 + 1024,
1458fd04b83SRoger A. Faulkner 	    AT_FDCWD, path, oflag, mode));
1468fd04b83SRoger A. Faulkner }
1478fd04b83SRoger A. Faulkner 
1488fd04b83SRoger A. Faulkner int
s10_creat64(sysret_t * rval,char * path,mode_t mode)1498fd04b83SRoger A. Faulkner s10_creat64(sysret_t *rval, char *path, mode_t mode)
1508fd04b83SRoger A. Faulkner {
1518fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_openat64 + 1024,
1528fd04b83SRoger A. Faulkner 	    AT_FDCWD, path, O_WRONLY | O_CREAT | O_TRUNC, mode));
1538fd04b83SRoger A. Faulkner }
1548fd04b83SRoger A. Faulkner 
1558fd04b83SRoger A. Faulkner #endif	/* !_LP64 */
1568fd04b83SRoger A. Faulkner 
1578fd04b83SRoger A. Faulkner int
s10_fork1(sysret_t * rval)1588fd04b83SRoger A. Faulkner s10_fork1(sysret_t *rval)
1598fd04b83SRoger A. Faulkner {
1608fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_forksys + 1024, 0, 0));
1618fd04b83SRoger A. Faulkner }
1628fd04b83SRoger A. Faulkner 
1638fd04b83SRoger A. Faulkner int
s10_forkall(sysret_t * rval)1648fd04b83SRoger A. Faulkner s10_forkall(sysret_t *rval)
1658fd04b83SRoger A. Faulkner {
1668fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_forksys + 1024, 1, 0));
1678fd04b83SRoger A. Faulkner }
1688fd04b83SRoger A. Faulkner 
1698fd04b83SRoger A. Faulkner int
s10_dup(sysret_t * rval,int fd)1708fd04b83SRoger A. Faulkner s10_dup(sysret_t *rval, int fd)
1718fd04b83SRoger A. Faulkner {
1728fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_fcntl + 1024, fd, F_DUPFD, 0));
1738fd04b83SRoger A. Faulkner }
1748fd04b83SRoger A. Faulkner 
1758fd04b83SRoger A. Faulkner int
s10_poll(sysret_t * rval,struct pollfd * fds,nfds_t nfd,int timeout)1768fd04b83SRoger A. Faulkner s10_poll(sysret_t *rval, struct pollfd *fds, nfds_t nfd, int timeout)
1778fd04b83SRoger A. Faulkner {
1788fd04b83SRoger A. Faulkner 	timespec_t ts;
1798fd04b83SRoger A. Faulkner 	timespec_t *tsp;
1808fd04b83SRoger A. Faulkner 
1818fd04b83SRoger A. Faulkner 	if (timeout < 0)
1828fd04b83SRoger A. Faulkner 		tsp = NULL;
1838fd04b83SRoger A. Faulkner 	else {
1848fd04b83SRoger A. Faulkner 		ts.tv_sec = timeout / MILLISEC;
1858fd04b83SRoger A. Faulkner 		ts.tv_nsec = (timeout % MILLISEC) * MICROSEC;
1868fd04b83SRoger A. Faulkner 		tsp = &ts;
1878fd04b83SRoger A. Faulkner 	}
1888fd04b83SRoger A. Faulkner 
1898fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_pollsys + 1024,
1908fd04b83SRoger A. Faulkner 	    fds, nfd, tsp, NULL));
1918fd04b83SRoger A. Faulkner }
1928fd04b83SRoger A. Faulkner 
1938fd04b83SRoger A. Faulkner int
s10_lwp_mutex_lock(sysret_t * rval,void * mp)1948fd04b83SRoger A. Faulkner s10_lwp_mutex_lock(sysret_t *rval, void *mp)
1958fd04b83SRoger A. Faulkner {
1968fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_lwp_mutex_timedlock + 1024,
1978fd04b83SRoger A. Faulkner 	    mp, NULL, 0));
1988fd04b83SRoger A. Faulkner }
1998fd04b83SRoger A. Faulkner 
2008fd04b83SRoger A. Faulkner int
s10_lwp_sema_wait(sysret_t * rval,void * sp)2018fd04b83SRoger A. Faulkner s10_lwp_sema_wait(sysret_t *rval, void *sp)
2028fd04b83SRoger A. Faulkner {
2038fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_lwp_sema_timedwait + 1024,
2048fd04b83SRoger A. Faulkner 	    sp, NULL, 0));
2058fd04b83SRoger A. Faulkner }
2068fd04b83SRoger A. Faulkner 
207*794f0adbSRoger A. Faulkner int
s10_chmod(sysret_t * rval,const char * name,mode_t mode)208*794f0adbSRoger A. Faulkner s10_chmod(sysret_t *rval, const char *name, mode_t mode)
209*794f0adbSRoger A. Faulkner {
210*794f0adbSRoger A. Faulkner 	return (__systemcall(rval, SYS_fchmodat + 1024,
211*794f0adbSRoger A. Faulkner 	    AT_FDCWD, name, mode, 0));
212*794f0adbSRoger A. Faulkner }
213*794f0adbSRoger A. Faulkner 
214*794f0adbSRoger A. Faulkner int
s10_fchmod(sysret_t * rval,int filedes,mode_t mode)215*794f0adbSRoger A. Faulkner s10_fchmod(sysret_t *rval, int filedes, mode_t mode)
216*794f0adbSRoger A. Faulkner {
217*794f0adbSRoger A. Faulkner 	return (__systemcall(rval, SYS_fchmodat + 1024,
218*794f0adbSRoger A. Faulkner 	    filedes, NULL, mode, 0));
219*794f0adbSRoger A. Faulkner }
220*794f0adbSRoger A. Faulkner 
2218fd04b83SRoger A. Faulkner static int
s10_fchownat(sysret_t * rval,int fd,const char * name,uid_t uid,gid_t gid,int flag)2228fd04b83SRoger A. Faulkner s10_fchownat(sysret_t *rval,
223*794f0adbSRoger A. Faulkner     int fd, const char *name, uid_t uid, gid_t gid, int flag)
2248fd04b83SRoger A. Faulkner {
2258fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_fchownat + 1024,
226*794f0adbSRoger A. Faulkner 	    fd, name, uid, gid, flag));
2278fd04b83SRoger A. Faulkner }
2288fd04b83SRoger A. Faulkner 
2298fd04b83SRoger A. Faulkner int
s10_chown(sysret_t * rval,const char * name,uid_t uid,gid_t gid)2308fd04b83SRoger A. Faulkner s10_chown(sysret_t *rval, const char *name, uid_t uid, gid_t gid)
2318fd04b83SRoger A. Faulkner {
2328fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_fchownat + 1024,
2338fd04b83SRoger A. Faulkner 	    AT_FDCWD, name, uid, gid, 0));
2348fd04b83SRoger A. Faulkner }
2358fd04b83SRoger A. Faulkner 
2368fd04b83SRoger A. Faulkner int
s10_lchown(sysret_t * rval,const char * name,uid_t uid,gid_t gid)2378fd04b83SRoger A. Faulkner s10_lchown(sysret_t *rval, const char *name, uid_t uid, gid_t gid)
2388fd04b83SRoger A. Faulkner {
2398fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_fchownat + 1024,
2408fd04b83SRoger A. Faulkner 	    AT_FDCWD, name, uid, gid, AT_SYMLINK_NOFOLLOW));
2418fd04b83SRoger A. Faulkner }
2428fd04b83SRoger A. Faulkner 
2438fd04b83SRoger A. Faulkner int
s10_fchown(sysret_t * rval,int filedes,uid_t uid,gid_t gid)2448fd04b83SRoger A. Faulkner s10_fchown(sysret_t *rval, int filedes, uid_t uid, gid_t gid)
2458fd04b83SRoger A. Faulkner {
2468fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_fchownat + 1024,
2478fd04b83SRoger A. Faulkner 	    filedes, NULL, uid, gid, 0));
2488fd04b83SRoger A. Faulkner }
2498fd04b83SRoger A. Faulkner 
250*794f0adbSRoger A. Faulkner int
s10_mkdir(sysret_t * rval,const char * dname,int dmode)251*794f0adbSRoger A. Faulkner s10_mkdir(sysret_t *rval, const char *dname, int dmode)
252*794f0adbSRoger A. Faulkner {
253*794f0adbSRoger A. Faulkner 	return (__systemcall(rval, SYS_mkdirat + 1024,
254*794f0adbSRoger A. Faulkner 	    AT_FDCWD, dname, dmode));
255*794f0adbSRoger A. Faulkner }
256*794f0adbSRoger A. Faulkner 
257*794f0adbSRoger A. Faulkner int
s10_mknod(sysret_t * rval,const char * fname,int fmode,dev_t dev)258*794f0adbSRoger A. Faulkner s10_mknod(sysret_t *rval, const char *fname, int fmode, dev_t dev)
259*794f0adbSRoger A. Faulkner {
260*794f0adbSRoger A. Faulkner 	return (__systemcall(rval, SYS_mknodat + 1024,
261*794f0adbSRoger A. Faulkner 	    AT_FDCWD, fname, fmode, dev));
262*794f0adbSRoger A. Faulkner }
263*794f0adbSRoger A. Faulkner 
264*794f0adbSRoger A. Faulkner int
s10_link(sysret_t * rval,const char * path1,const char * path2)265*794f0adbSRoger A. Faulkner s10_link(sysret_t *rval, const char *path1, const char *path2)
266*794f0adbSRoger A. Faulkner {
267*794f0adbSRoger A. Faulkner 	return (__systemcall(rval, SYS_linkat + 1024,
268*794f0adbSRoger A. Faulkner 	    AT_FDCWD, path1, AT_FDCWD, path2, 0));
269*794f0adbSRoger A. Faulkner }
270*794f0adbSRoger A. Faulkner 
2718fd04b83SRoger A. Faulkner static int
s10_unlinkat(sysret_t * rval,int fd,const char * name,int flags)2728fd04b83SRoger A. Faulkner s10_unlinkat(sysret_t *rval, int fd, const char *name, int flags)
2738fd04b83SRoger A. Faulkner {
2748fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_unlinkat + 1024,
2758fd04b83SRoger A. Faulkner 	    fd, name, flags));
2768fd04b83SRoger A. Faulkner }
2778fd04b83SRoger A. Faulkner 
2788fd04b83SRoger A. Faulkner int
s10_unlink(sysret_t * rval,const char * name)2798fd04b83SRoger A. Faulkner s10_unlink(sysret_t *rval, const char *name)
2808fd04b83SRoger A. Faulkner {
2818fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_unlinkat + 1024,
2828fd04b83SRoger A. Faulkner 	    AT_FDCWD, name, 0));
2838fd04b83SRoger A. Faulkner }
2848fd04b83SRoger A. Faulkner 
2858fd04b83SRoger A. Faulkner int
s10_rmdir(sysret_t * rval,const char * name)2868fd04b83SRoger A. Faulkner s10_rmdir(sysret_t *rval, const char *name)
2878fd04b83SRoger A. Faulkner {
2888fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_unlinkat + 1024,
2898fd04b83SRoger A. Faulkner 	    AT_FDCWD, name, AT_REMOVEDIR));
2908fd04b83SRoger A. Faulkner }
2918fd04b83SRoger A. Faulkner 
2928fd04b83SRoger A. Faulkner static int
s10_renameat(sysret_t * rval,int oldfd,const char * oldname,int newfd,const char * newname)2938fd04b83SRoger A. Faulkner s10_renameat(sysret_t *rval,
2948fd04b83SRoger A. Faulkner     int oldfd, const char *oldname, int newfd, const char *newname)
2958fd04b83SRoger A. Faulkner {
2968fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_renameat + 1024,
2978fd04b83SRoger A. Faulkner 	    oldfd, oldname, newfd, newname));
2988fd04b83SRoger A. Faulkner }
2998fd04b83SRoger A. Faulkner 
3008fd04b83SRoger A. Faulkner int
s10_rename(sysret_t * rval,const char * oldname,const char * newname)3018fd04b83SRoger A. Faulkner s10_rename(sysret_t *rval, const char *oldname, const char *newname)
3028fd04b83SRoger A. Faulkner {
3038fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_renameat + 1024,
3048fd04b83SRoger A. Faulkner 	    AT_FDCWD, oldname, AT_FDCWD, newname));
3058fd04b83SRoger A. Faulkner }
3068fd04b83SRoger A. Faulkner 
307*794f0adbSRoger A. Faulkner int
s10_symlink(sysret_t * rval,const char * path1,const char * path2)308*794f0adbSRoger A. Faulkner s10_symlink(sysret_t *rval, const char *path1, const char *path2)
309*794f0adbSRoger A. Faulkner {
310*794f0adbSRoger A. Faulkner 	return (__systemcall(rval, SYS_symlinkat +  1024,
311*794f0adbSRoger A. Faulkner 	    path1, AT_FDCWD, path2));
312*794f0adbSRoger A. Faulkner }
313*794f0adbSRoger A. Faulkner 
314*794f0adbSRoger A. Faulkner int
s10_readlink(sysret_t * rval,const char * path,char * buf,size_t bufsize)315*794f0adbSRoger A. Faulkner s10_readlink(sysret_t *rval, const char *path, char *buf, size_t bufsize)
316*794f0adbSRoger A. Faulkner {
317*794f0adbSRoger A. Faulkner 	return (__systemcall(rval, SYS_readlinkat +  1024,
318*794f0adbSRoger A. Faulkner 	    AT_FDCWD, path, buf, bufsize));
319*794f0adbSRoger A. Faulkner }
320*794f0adbSRoger A. Faulkner 
3218fd04b83SRoger A. Faulkner static int
s10_faccessat(sysret_t * rval,int fd,const char * fname,int amode,int flag)3228fd04b83SRoger A. Faulkner s10_faccessat(sysret_t *rval, int fd, const char *fname, int amode, int flag)
3238fd04b83SRoger A. Faulkner {
3248fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_faccessat + 1024,
3258fd04b83SRoger A. Faulkner 	    fd, fname, amode, flag));
3268fd04b83SRoger A. Faulkner }
3278fd04b83SRoger A. Faulkner 
3288fd04b83SRoger A. Faulkner int
s10_access(sysret_t * rval,const char * fname,int amode)3298fd04b83SRoger A. Faulkner s10_access(sysret_t *rval, const char *fname, int amode)
3308fd04b83SRoger A. Faulkner {
3318fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_faccessat + 1024,
3328fd04b83SRoger A. Faulkner 	    AT_FDCWD, fname, amode, 0));
3338fd04b83SRoger A. Faulkner }
3348fd04b83SRoger A. Faulkner 
3358fd04b83SRoger A. Faulkner int
s10_utime(sysret_t * rval,const char * path,const struct utimbuf * times)3368fd04b83SRoger A. Faulkner s10_utime(sysret_t *rval, const char *path, const struct utimbuf *times)
3378fd04b83SRoger A. Faulkner {
3388fd04b83SRoger A. Faulkner 	struct utimbuf ltimes;
3398fd04b83SRoger A. Faulkner 	timespec_t ts[2];
3408fd04b83SRoger A. Faulkner 	timespec_t *tsp;
3418fd04b83SRoger A. Faulkner 
3428fd04b83SRoger A. Faulkner 	if (times == NULL) {
3438fd04b83SRoger A. Faulkner 		tsp = NULL;
3448fd04b83SRoger A. Faulkner 	} else {
34580e2ca85S 		if (brand_uucopy(times, &ltimes, sizeof (ltimes)) != 0)
3468fd04b83SRoger A. Faulkner 			return (EFAULT);
3478fd04b83SRoger A. Faulkner 		ts[0].tv_sec = ltimes.actime;
3488fd04b83SRoger A. Faulkner 		ts[0].tv_nsec = 0;
3498fd04b83SRoger A. Faulkner 		ts[1].tv_sec = ltimes.modtime;
3508fd04b83SRoger A. Faulkner 		ts[1].tv_nsec = 0;
3518fd04b83SRoger A. Faulkner 		tsp = ts;
3528fd04b83SRoger A. Faulkner 	}
3538fd04b83SRoger A. Faulkner 
3548fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_utimesys + 1024, 1,
3558fd04b83SRoger A. Faulkner 	    AT_FDCWD, path, tsp, 0));
3568fd04b83SRoger A. Faulkner }
3578fd04b83SRoger A. Faulkner 
3588fd04b83SRoger A. Faulkner int
s10_utimes(sysret_t * rval,const char * path,const struct timeval times[2])3598fd04b83SRoger A. Faulkner s10_utimes(sysret_t *rval, const char *path, const struct timeval times[2])
3608fd04b83SRoger A. Faulkner {
3618fd04b83SRoger A. Faulkner 	struct timeval ltimes[2];
3628fd04b83SRoger A. Faulkner 	timespec_t ts[2];
3638fd04b83SRoger A. Faulkner 	timespec_t *tsp;
3648fd04b83SRoger A. Faulkner 
3658fd04b83SRoger A. Faulkner 	if (times == NULL) {
3668fd04b83SRoger A. Faulkner 		tsp = NULL;
3678fd04b83SRoger A. Faulkner 	} else {
36880e2ca85S 		if (brand_uucopy(times, ltimes, sizeof (ltimes)) != 0)
3698fd04b83SRoger A. Faulkner 			return (EFAULT);
3708fd04b83SRoger A. Faulkner 		ts[0].tv_sec = ltimes[0].tv_sec;
3718fd04b83SRoger A. Faulkner 		ts[0].tv_nsec = ltimes[0].tv_usec * 1000;
3728fd04b83SRoger A. Faulkner 		ts[1].tv_sec = ltimes[1].tv_sec;
3738fd04b83SRoger A. Faulkner 		ts[1].tv_nsec = ltimes[1].tv_usec * 1000;
3748fd04b83SRoger A. Faulkner 		tsp = ts;
3758fd04b83SRoger A. Faulkner 	}
3768fd04b83SRoger A. Faulkner 
3778fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_utimesys + 1024, 1,
3788fd04b83SRoger A. Faulkner 	    AT_FDCWD, path, tsp, 0));
3798fd04b83SRoger A. Faulkner }
3808fd04b83SRoger A. Faulkner 
3818fd04b83SRoger A. Faulkner static int
s10_futimesat(sysret_t * rval,int fd,const char * path,const struct timeval times[2])3828fd04b83SRoger A. Faulkner s10_futimesat(sysret_t *rval,
3838fd04b83SRoger A. Faulkner     int fd, const char *path, const struct timeval times[2])
3848fd04b83SRoger A. Faulkner {
3858fd04b83SRoger A. Faulkner 	struct timeval ltimes[2];
3868fd04b83SRoger A. Faulkner 	timespec_t ts[2];
3878fd04b83SRoger A. Faulkner 	timespec_t *tsp;
3888fd04b83SRoger A. Faulkner 
3898fd04b83SRoger A. Faulkner 	if (times == NULL) {
3908fd04b83SRoger A. Faulkner 		tsp = NULL;
3918fd04b83SRoger A. Faulkner 	} else {
39280e2ca85S 		if (brand_uucopy(times, ltimes, sizeof (ltimes)) != 0)
3938fd04b83SRoger A. Faulkner 			return (EFAULT);
3948fd04b83SRoger A. Faulkner 		ts[0].tv_sec = ltimes[0].tv_sec;
3958fd04b83SRoger A. Faulkner 		ts[0].tv_nsec = ltimes[0].tv_usec * 1000;
3968fd04b83SRoger A. Faulkner 		ts[1].tv_sec = ltimes[1].tv_sec;
3978fd04b83SRoger A. Faulkner 		ts[1].tv_nsec = ltimes[1].tv_usec * 1000;
3988fd04b83SRoger A. Faulkner 		tsp = ts;
3998fd04b83SRoger A. Faulkner 	}
4008fd04b83SRoger A. Faulkner 
4018fd04b83SRoger A. Faulkner 	if (path == NULL)
4028fd04b83SRoger A. Faulkner 		return (__systemcall(rval, SYS_utimesys + 1024, 0, fd, tsp));
4038fd04b83SRoger A. Faulkner 
4048fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_utimesys + 1024, 1, fd, path, tsp, 0));
4058fd04b83SRoger A. Faulkner }
4068fd04b83SRoger A. Faulkner 
4078fd04b83SRoger A. Faulkner #if defined(__x86)
4088fd04b83SRoger A. Faulkner 
4098fd04b83SRoger A. Faulkner /* ARGSUSED */
4108fd04b83SRoger A. Faulkner int
s10_xstat(sysret_t * rval,int version,const char * path,struct stat * statb)4118fd04b83SRoger A. Faulkner s10_xstat(sysret_t *rval, int version, const char *path, struct stat *statb)
4128fd04b83SRoger A. Faulkner {
4138fd04b83SRoger A. Faulkner #if defined(__amd64)
4148fd04b83SRoger A. Faulkner 	return (EINVAL);
4158fd04b83SRoger A. Faulkner #else
4168fd04b83SRoger A. Faulkner 	if (version != _STAT_VER)
4178fd04b83SRoger A. Faulkner 		return (EINVAL);
4188fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_fstatat + 1024,
4198fd04b83SRoger A. Faulkner 	    AT_FDCWD, path, statb, 0));
4208fd04b83SRoger A. Faulkner #endif
4218fd04b83SRoger A. Faulkner }
4228fd04b83SRoger A. Faulkner 
4238fd04b83SRoger A. Faulkner /* ARGSUSED */
4248fd04b83SRoger A. Faulkner int
s10_lxstat(sysret_t * rval,int version,const char * path,struct stat * statb)4258fd04b83SRoger A. Faulkner s10_lxstat(sysret_t *rval, int version, const char *path, struct stat *statb)
4268fd04b83SRoger A. Faulkner {
4278fd04b83SRoger A. Faulkner #if defined(__amd64)
4288fd04b83SRoger A. Faulkner 	return (EINVAL);
4298fd04b83SRoger A. Faulkner #else
4308fd04b83SRoger A. Faulkner 	if (version != _STAT_VER)
4318fd04b83SRoger A. Faulkner 		return (EINVAL);
4328fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_fstatat + 1024,
4338fd04b83SRoger A. Faulkner 	    AT_FDCWD, path, statb, AT_SYMLINK_NOFOLLOW));
4348fd04b83SRoger A. Faulkner #endif
4358fd04b83SRoger A. Faulkner }
4368fd04b83SRoger A. Faulkner 
4378fd04b83SRoger A. Faulkner /* ARGSUSED */
4388fd04b83SRoger A. Faulkner int
s10_fxstat(sysret_t * rval,int version,int fd,struct stat * statb)4398fd04b83SRoger A. Faulkner s10_fxstat(sysret_t *rval, int version, int fd, struct stat *statb)
4408fd04b83SRoger A. Faulkner {
4418fd04b83SRoger A. Faulkner #if defined(__amd64)
4428fd04b83SRoger A. Faulkner 	return (EINVAL);
4438fd04b83SRoger A. Faulkner #else
4448fd04b83SRoger A. Faulkner 	if (version != _STAT_VER)
4458fd04b83SRoger A. Faulkner 		return (EINVAL);
4468fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_fstatat + 1024,
4478fd04b83SRoger A. Faulkner 	    fd, NULL, statb, 0));
4488fd04b83SRoger A. Faulkner #endif
4498fd04b83SRoger A. Faulkner }
4508fd04b83SRoger A. Faulkner 
4518fd04b83SRoger A. Faulkner /* ARGSUSED */
4528fd04b83SRoger A. Faulkner int
s10_xmknod(sysret_t * rval,int version,const char * path,mode_t mode,dev_t dev)4538fd04b83SRoger A. Faulkner s10_xmknod(sysret_t *rval, int version, const char *path,
4548fd04b83SRoger A. Faulkner     mode_t mode, dev_t dev)
4558fd04b83SRoger A. Faulkner {
4568fd04b83SRoger A. Faulkner #if defined(__amd64)
4578fd04b83SRoger A. Faulkner 	return (EINVAL);
4588fd04b83SRoger A. Faulkner #else
4598fd04b83SRoger A. Faulkner 	if (version != _MKNOD_VER)
4608fd04b83SRoger A. Faulkner 		return (EINVAL);
461*794f0adbSRoger A. Faulkner 	return (__systemcall(rval, SYS_mknodat + 1024,
462*794f0adbSRoger A. Faulkner 	    AT_FDCWD, path, mode, dev));
4638fd04b83SRoger A. Faulkner #endif
4648fd04b83SRoger A. Faulkner }
4658fd04b83SRoger A. Faulkner 
4668fd04b83SRoger A. Faulkner #endif	/* __x86 */
4678fd04b83SRoger A. Faulkner 
4688fd04b83SRoger A. Faulkner /*
4698fd04b83SRoger A. Faulkner  * This is the fsat() system call trap in s10.
4708fd04b83SRoger A. Faulkner  * It has been removed in the current system.
4718fd04b83SRoger A. Faulkner  */
4728fd04b83SRoger A. Faulkner int
s10_fsat(sysret_t * rval,int code,uintptr_t arg1,uintptr_t arg2,uintptr_t arg3,uintptr_t arg4,uintptr_t arg5)4738fd04b83SRoger A. Faulkner s10_fsat(sysret_t *rval,
4748fd04b83SRoger A. Faulkner     int code, uintptr_t arg1, uintptr_t arg2,
4758fd04b83SRoger A. Faulkner     uintptr_t arg3, uintptr_t arg4, uintptr_t arg5)
4768fd04b83SRoger A. Faulkner {
4778fd04b83SRoger A. Faulkner 	switch (code) {
4788fd04b83SRoger A. Faulkner 	case 0:		/* openat */
4798fd04b83SRoger A. Faulkner 		return (s10_openat(rval, (int)arg1,
4808fd04b83SRoger A. Faulkner 		    (const char *)arg2, (int)arg3, (mode_t)arg4));
4818fd04b83SRoger A. Faulkner 	case 1:		/* openat64 */
4828fd04b83SRoger A. Faulkner #if defined(_LP64)
4838fd04b83SRoger A. Faulkner 		return (EINVAL);
4848fd04b83SRoger A. Faulkner #else
4858fd04b83SRoger A. Faulkner 		return (s10_openat64(rval, (int)arg1,
4868fd04b83SRoger A. Faulkner 		    (const char *)arg2, (int)arg3, (mode_t)arg4));
4878fd04b83SRoger A. Faulkner #endif
4888fd04b83SRoger A. Faulkner 	case 2:		/* fstatat64 */
4898fd04b83SRoger A. Faulkner #if defined(_LP64)
4908fd04b83SRoger A. Faulkner 		return (EINVAL);
4918fd04b83SRoger A. Faulkner #else
4928fd04b83SRoger A. Faulkner 		return (s10_fstatat64(rval, (int)arg1,
4938fd04b83SRoger A. Faulkner 		    (const char *)arg2, (struct stat64 *)arg3, (int)arg4));
4948fd04b83SRoger A. Faulkner #endif
4958fd04b83SRoger A. Faulkner 	case 3:		/* fstatat */
4968fd04b83SRoger A. Faulkner 		return (s10_fstatat(rval, (int)arg1,
4978fd04b83SRoger A. Faulkner 		    (const char *)arg2, (struct stat *)arg3, (int)arg4));
4988fd04b83SRoger A. Faulkner 	case 4:		/* fchownat */
4998fd04b83SRoger A. Faulkner 		return (s10_fchownat(rval, (int)arg1, (char *)arg2,
5008fd04b83SRoger A. Faulkner 		    (uid_t)arg3, (gid_t)arg4, (int)arg5));
5018fd04b83SRoger A. Faulkner 	case 5:		/* unlinkat */
5028fd04b83SRoger A. Faulkner 		return (s10_unlinkat(rval, (int)arg1, (char *)arg2,
5038fd04b83SRoger A. Faulkner 		    (int)arg3));
5048fd04b83SRoger A. Faulkner 	case 6:		/* futimesat */
5058fd04b83SRoger A. Faulkner 		return (s10_futimesat(rval, (int)arg1,
5068fd04b83SRoger A. Faulkner 		    (const char *)arg2, (const struct timeval *)arg3));
5078fd04b83SRoger A. Faulkner 	case 7:		/* renameat */
5088fd04b83SRoger A. Faulkner 		return (s10_renameat(rval, (int)arg1, (char *)arg2,
5098fd04b83SRoger A. Faulkner 		    (int)arg3, (char *)arg4));
5108fd04b83SRoger A. Faulkner 	case 8:		/* faccessat */
5118fd04b83SRoger A. Faulkner 		return (s10_faccessat(rval, (int)arg1, (char *)arg2,
5128fd04b83SRoger A. Faulkner 		    (int)arg3, (int)arg4));
5138fd04b83SRoger A. Faulkner 	case 9:		/* openattrdirat */
5148fd04b83SRoger A. Faulkner 		return (s10_openat(rval, (int)arg1,
5158fd04b83SRoger A. Faulkner 		    (const char *)arg2, FXATTRDIROPEN, 0));
5168fd04b83SRoger A. Faulkner 	}
5178fd04b83SRoger A. Faulkner 	return (EINVAL);
5188fd04b83SRoger A. Faulkner }
5198fd04b83SRoger A. Faulkner 
5208fd04b83SRoger A. Faulkner /*
5218fd04b83SRoger A. Faulkner  * Interposition upon SYS_umount
5228fd04b83SRoger A. Faulkner  */
5238fd04b83SRoger A. Faulkner int
s10_umount(sysret_t * rval,const char * path)5248fd04b83SRoger A. Faulkner s10_umount(sysret_t *rval, const char *path)
5258fd04b83SRoger A. Faulkner {
5268fd04b83SRoger A. Faulkner 	return (__systemcall(rval, SYS_umount2 + 1024, path, 0));
5278fd04b83SRoger A. Faulkner }