summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/os
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts/common/os')
-rw-r--r--usr/src/uts/common/os/core.c6
-rw-r--r--usr/src/uts/common/os/exit.c4
-rw-r--r--usr/src/uts/common/os/fio.c150
-rw-r--r--usr/src/uts/common/os/sysent.c32
4 files changed, 107 insertions, 85 deletions
diff --git a/usr/src/uts/common/os/core.c b/usr/src/uts/common/os/core.c
index ece9d8f0eb..9e04f631a9 100644
--- a/usr/src/uts/common/os/core.c
+++ b/usr/src/uts/common/os/core.c
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
@@ -436,9 +435,6 @@ do_core(char *fp, int sig, enum core_types core_type, struct core_globals *cg)
#if defined(__sparc)
(void) flush_user_windows_to_stack(NULL);
#endif
-#ifdef SUN_SRC_COMPAT
- PTOU(curproc)->u_acflag |= ACORE;
-#endif
if ((eswp = PTOU(curproc)->u_execsw) == NULL ||
(eswp = findexec_by_magic(eswp->exec_magic)) == NULL) {
error = ENOSYS;
diff --git a/usr/src/uts/common/os/exit.c b/usr/src/uts/common/os/exit.c
index 5b9d682ce1..47dcb0b7f0 100644
--- a/usr/src/uts/common/os/exit.c
+++ b/usr/src/uts/common/os/exit.c
@@ -500,10 +500,6 @@ proc_exit(int why, int what)
*/
prbarrier(p);
-#ifdef SUN_SRC_COMPAT
- if (code == CLD_KILLED)
- u.u_acflag |= AXSIG;
-#endif
sigfillset(&p->p_ignore);
sigemptyset(&p->p_siginfo);
sigemptyset(&p->p_sig);
diff --git a/usr/src/uts/common/os/fio.c b/usr/src/uts/common/os/fio.c
index 4ba4ec7560..a014d25c0f 100644
--- a/usr/src/uts/common/os/fio.c
+++ b/usr/src/uts/common/os/fio.c
@@ -75,7 +75,6 @@ static uint32_t afd_wait; /* count of waits on non-zero ref count */
#endif /* DEBUG */
kmem_cache_t *file_cache;
-static int vpsetattr(vnode_t *, vattr_t *, int);
static void port_close_fd(portfd_t *);
@@ -1087,6 +1086,7 @@ falloc(vnode_t *vp, int flag, file_t **fpp, int *fdp)
mutex_enter(&fp->f_tlock);
fp->f_count = 1;
fp->f_flag = (ushort_t)flag;
+ fp->f_flag2 = (flag & (FSEARCH|FEXEC)) >> 16;
fp->f_vnode = vp;
fp->f_offset = 0;
fp->f_audit_data = 0;
@@ -1195,7 +1195,7 @@ f_getfl(int fd, int *flagp)
error = EBADF;
else {
vnode_t *vp = fp->f_vnode;
- int flag = fp->f_flag;
+ int flag = fp->f_flag | (fp->f_flag2 << 16);
/*
* BSD fcntl() FASYNC compatibility.
@@ -1460,85 +1460,107 @@ close_exec(uf_info_t *fip)
}
/*
- * Common routine for modifying attributes of named files.
+ * Utility function called by most of the *at() system call interfaces.
+ *
+ * Generate a starting vnode pointer for an (fd, path) pair where 'fd'
+ * is an open file descriptor for a directory to be used as the starting
+ * point for the lookup of the relative pathname 'path' (or, if path is
+ * NULL, generate a vnode pointer for the direct target of the operation).
+ *
+ * If we successfully return a non-NULL startvp, it has been the target
+ * of VN_HOLD() and the caller must call VN_RELE() on it.
*/
int
-namesetattr(char *fnamep, enum symfollow followlink, vattr_t *vap, int flags)
+fgetstartvp(int fd, char *path, vnode_t **startvpp)
{
- vnode_t *vp;
- int error = 0;
+ vnode_t *startvp;
+ file_t *startfp;
+ char startchar;
- if (error = lookupname(fnamep, UIO_USERSPACE, followlink, NULLVPP, &vp))
- return (set_errno(error));
- if (error = vpsetattr(vp, vap, flags))
- (void) set_errno(error);
- VN_RELE(vp);
- return (error);
-}
+ if (fd == AT_FDCWD && path == NULL)
+ return (EFAULT);
-/*
- * Common routine for modifying attributes of files referenced
- * by descriptor.
- */
-int
-fdsetattr(int fd, vattr_t *vap)
-{
- file_t *fp;
- vnode_t *vp;
- int error = 0;
+ if (fd == AT_FDCWD) {
+ /*
+ * Start from the current working directory.
+ */
+ startvp = NULL;
+ } else {
+ if (path == NULL)
+ startchar = '\0';
+ else if (copyin(path, &startchar, sizeof (char)))
+ return (EFAULT);
- if ((fp = getf(fd)) != NULL) {
- vp = fp->f_vnode;
- if (error = vpsetattr(vp, vap, 0)) {
- (void) set_errno(error);
+ if (startchar == '/') {
+ /*
+ * 'path' is an absolute pathname.
+ */
+ startvp = NULL;
+ } else {
+ /*
+ * 'path' is a relative pathname or we will
+ * be applying the operation to 'fd' itself.
+ */
+ if ((startfp = getf(fd)) == NULL)
+ return (EBADF);
+ startvp = startfp->f_vnode;
+ VN_HOLD(startvp);
+ releasef(fd);
}
- releasef(fd);
- } else
- error = set_errno(EBADF);
- return (error);
+ }
+ *startvpp = startvp;
+ return (0);
}
/*
- * Common routine to set the attributes for the given vnode.
- * If the vnode is a file and the filesize is being manipulated,
- * this makes sure that there are no conflicting non-blocking
- * mandatory locks in that region.
+ * Called from fchownat() and fchmodat() to set ownership and mode.
+ * The contents of *vap must be set before calling here.
*/
-static int
-vpsetattr(vnode_t *vp, vattr_t *vap, int flags)
+int
+fsetattrat(int fd, char *path, int flags, struct vattr *vap)
{
- int error = 0;
- int in_crit = 0;
- u_offset_t begin;
- vattr_t vattr;
- ssize_t length;
+ vnode_t *startvp;
+ vnode_t *vp;
+ int error;
+
+ /*
+ * Since we are never called to set the size of a file, we don't
+ * need to check for non-blocking locks (via nbl_need_check(vp)).
+ */
+ ASSERT(!(vap->va_mask & AT_SIZE));
+
+ if ((error = fgetstartvp(fd, path, &startvp)) != 0)
+ return (error);
+ if (AU_AUDITING() && startvp != NULL)
+ audit_setfsat_path(1);
+
+ /*
+ * Do lookup for fchownat/fchmodat when path not NULL
+ */
+ if (path != NULL) {
+ if (error = lookupnameat(path, UIO_USERSPACE,
+ (flags == AT_SYMLINK_NOFOLLOW) ?
+ NO_FOLLOW : FOLLOW,
+ NULLVPP, &vp, startvp)) {
+ if (startvp != NULL)
+ VN_RELE(startvp);
+ return (error);
+ }
+ } else {
+ vp = startvp;
+ ASSERT(vp);
+ VN_HOLD(vp);
+ }
if (vn_is_readonly(vp)) {
error = EROFS;
+ } else {
+ error = VOP_SETATTR(vp, vap, 0, CRED(), NULL);
}
- if (!error && (vap->va_mask & AT_SIZE) &&
- nbl_need_check(vp)) {
- nbl_start_crit(vp, RW_READER);
- in_crit = 1;
- vattr.va_mask = AT_SIZE;
- if (!(error = VOP_GETATTR(vp, &vattr, 0, CRED(), NULL))) {
- begin = vap->va_size > vattr.va_size ?
- vattr.va_size : vap->va_size;
- length = vattr.va_size > vap->va_size ?
- vattr.va_size - vap->va_size :
- vap->va_size - vattr.va_size;
-
- if (nbl_conflict(vp, NBL_WRITE, begin, length, 0,
- NULL)) {
- error = EACCES;
- }
- }
- }
- if (!error)
- error = VOP_SETATTR(vp, vap, flags, CRED(), NULL);
- if (in_crit)
- nbl_end_crit(vp);
+ if (startvp != NULL)
+ VN_RELE(startvp);
+ VN_RELE(vp);
return (error);
}
diff --git a/usr/src/uts/common/os/sysent.c b/usr/src/uts/common/os/sysent.c
index b956756758..7a40be6d9e 100644
--- a/usr/src/uts/common/os/sysent.c
+++ b/usr/src/uts/common/os/sysent.c
@@ -20,6 +20,7 @@
*/
/* ONC_PLUS EXTRACT START */
+
/*
* Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
*/
@@ -58,6 +59,7 @@ int cladm();
int close();
int exece();
int faccessat();
+int fchmodat();
int fchownat();
int fcntl();
int64_t vfork();
@@ -80,11 +82,13 @@ int ioctl();
int kill();
int labelsys();
int link();
+int linkat();
off32_t lseek32();
off_t lseek64();
int lgrpsys();
int mmapobjsys();
int mknod();
+int mknodat();
int mount();
int nice();
int nullsys();
@@ -139,6 +143,7 @@ ssize_t writev();
int syslwp_park();
int rmdir();
int mkdir();
+int mkdirat();
int getdents32();
int statfs32();
int fstatfs32();
@@ -149,7 +154,9 @@ int putmsg();
int uadmin();
int lstat();
int symlink();
+int symlinkat();
ssize_t readlink();
+ssize_t readlinkat();
int resolvepath();
int setgroups();
int getgroups();
@@ -423,11 +430,11 @@ struct sysent sysent[NSYSCALL] =
/* 4 */ SYSENT_CL("write", write, 3),
/* 5 */ SYSENT_CI("open", open, 3),
/* 6 */ SYSENT_CI("close", close, 1),
- /* 7 */ SYSENT_LOADABLE(), /* (was wait) */
+ /* 7 */ SYSENT_CI("linkat", linkat, 5),
/* 8 */ SYSENT_LOADABLE(), /* (was creat) */
/* 9 */ SYSENT_CI("link", link, 2),
/* 10 */ SYSENT_CI("unlink", unlink, 1),
- /* 11 */ SYSENT_LOADABLE(), /* (was exec) */
+ /* 11 */ SYSENT_CI("symlinkat", symlinkat, 3),
/* 12 */ SYSENT_CI("chdir", chdir, 1),
/* 13 */ SYSENT_CL("time", gtime, 0),
/* 14 */ SYSENT_CI("mknod", mknod, 3),
@@ -440,7 +447,7 @@ struct sysent sysent[NSYSCALL] =
SYSENT_CL("lseek", lseek32, 3)),
/* 20 */ SYSENT_2CI("getpid", getpid, 0),
/* 21 */ SYSENT_AP("mount", mount, 8),
- /* 22 */ SYSENT_LOADABLE(), /* (was umount) */
+ /* 22 */ SYSENT_CL("readlinkat", readlinkat, 4),
/* 23 */ SYSENT_CI("setuid", setuid, 1),
/* 24 */ SYSENT_2CI("getuid", getuid, 0),
/* 25 */ SYSENT_CI("stime", stime, 1),
@@ -470,7 +477,7 @@ struct sysent sysent[NSYSCALL] =
/* 45 */ SYSENT_CI("faccessat", faccessat, 4),
/* 46 */ SYSENT_CI("setgid", setgid, 1),
/* 47 */ SYSENT_2CI("getgid", getgid, 0),
- /* 48 */ SYSENT_LOADABLE(), /* (was ssig) */
+ /* 48 */ SYSENT_CI("mknodat", mknodat, 4),
/* 49 */ SYSENT_LOADABLE(), /* msgsys */
/* 50 */ IF_x86(
SYSENT_CI("sysi86", sysi86, 4),
@@ -533,8 +540,8 @@ struct sysent sysent[NSYSCALL] =
/* 98 */ SYSENT_CI("sigaction", sigaction, 3),
/* 99 */ SYSENT_CI("sigpending", sigpending, 2),
/* 100 */ SYSENT_CI("getsetcontext", getsetcontext, 2),
- /* 101 */ SYSENT_LOADABLE(),
- /* 102 */ SYSENT_LOADABLE(),
+ /* 101 */ SYSENT_CI("fchmodat", fchmodat, 4),
+ /* 102 */ SYSENT_CI("mkdirat", mkdirat, 3),
/* 103 */ SYSENT_CI("statvfs", statvfs, 2),
/* 104 */ SYSENT_CI("fstatvfs", fstatvfs, 2),
/* 105 */ SYSENT_CI("getloadavg", getloadavg, 2),
@@ -754,6 +761,7 @@ extern ssize_t pwrite32();
extern ssize_t readv32();
extern ssize_t writev32();
extern ssize_t readlink32();
+extern ssize_t readlinkat32();
extern int open32();
extern int openat32();
extern int stat32();
@@ -805,11 +813,11 @@ struct sysent sysent32[NSYSCALL] =
/* 4 */ SYSENT_CI("write", write32, 3),
/* 5 */ SYSENT_CI("open", open32, 3),
/* 6 */ SYSENT_CI("close", close, 1),
- /* 7 */ SYSENT_LOADABLE32(), /* (was wait) */
+ /* 7 */ SYSENT_CI("linkat", linkat, 5),
/* 8 */ SYSENT_LOADABLE32(), /* (was creat32) */
/* 9 */ SYSENT_CI("link", link, 2),
/* 10 */ SYSENT_CI("unlink", unlink, 1),
- /* 11 */ SYSENT_LOADABLE32(), /* (was exec) */
+ /* 11 */ SYSENT_CI("symlinkat", symlinkat, 3),
/* 12 */ SYSENT_CI("chdir", chdir, 1),
/* 13 */ SYSENT_CI("time", gtime, 0),
/* 14 */ SYSENT_CI("mknod", mknod, 3),
@@ -820,7 +828,7 @@ struct sysent sysent32[NSYSCALL] =
/* 19 */ SYSENT_CI("lseek", lseek32, 3),
/* 20 */ SYSENT_2CI("getpid", getpid, 0),
/* 21 */ SYSENT_AP("mount", mount, 8),
- /* 22 */ SYSENT_LOADABLE32(), /* (was umount) */
+ /* 22 */ SYSENT_CI("readlinkat", readlinkat32, 4),
/* 23 */ SYSENT_CI("setuid", setuid, 1),
/* 24 */ SYSENT_2CI("getuid", getuid, 0),
/* 25 */ SYSENT_CI("stime", stime32, 1),
@@ -846,7 +854,7 @@ struct sysent sysent32[NSYSCALL] =
/* 45 */ SYSENT_CI("faccessat", faccessat, 4),
/* 46 */ SYSENT_CI("setgid", setgid, 1),
/* 47 */ SYSENT_2CI("getgid", getgid, 0),
- /* 48 */ SYSENT_LOADABLE32(), /* (was ssig) */
+ /* 48 */ SYSENT_CI("mknodat", mknodat, 4),
/* 49 */ SYSENT_LOADABLE32(), /* msgsys */
/* 50 */ IF_386_ABI(
SYSENT_CI("sysi86", sysi86, 4),
@@ -901,8 +909,8 @@ struct sysent sysent32[NSYSCALL] =
/* 98 */ SYSENT_CI("sigaction", sigaction32, 3),
/* 99 */ SYSENT_CI("sigpending", sigpending, 2),
/* 100 */ SYSENT_CI("getsetcontext", getsetcontext32, 2),
- /* 101 */ SYSENT_LOADABLE32(),
- /* 102 */ SYSENT_LOADABLE32(),
+ /* 101 */ SYSENT_CI("fchmodat", fchmodat, 4),
+ /* 102 */ SYSENT_CI("mkdirat", mkdirat, 3),
/* 103 */ SYSENT_CI("statvfs", statvfs32, 2),
/* 104 */ SYSENT_CI("fstatvfs", fstatvfs32, 2),
/* 105 */ SYSENT_CI("getloadavg", getloadavg, 2),