summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/exec_elf64.c2
-rw-r--r--sys/kern/kern_cred.c19
-rw-r--r--sys/kern/kern_descrip.c2
-rw-r--r--sys/kern/kern_exit.c16
-rw-r--r--sys/kern/kern_syscall.c1
-rw-r--r--sys/kern/vfs_lookup.c4
-rw-r--r--sys/kern/vfs_subr.c6
-rw-r--r--sys/kern/vfs_syscalls.c2
8 files changed, 45 insertions, 7 deletions
diff --git a/sys/kern/exec_elf64.c b/sys/kern/exec_elf64.c
index 9706e77..8dc87dc 100644
--- a/sys/kern/exec_elf64.c
+++ b/sys/kern/exec_elf64.c
@@ -112,7 +112,7 @@ elf_get_file(const char *pathname, struct elf_file *res)
getattr_args.res = &vattr;
getattr_args.vp = vp;
- status = vfs_vop_getattr(vp, &getattr_args);
+ status = vfs_vop_getattr(&getattr_args);
if (status != 0)
goto done;
diff --git a/sys/kern/kern_cred.c b/sys/kern/kern_cred.c
index e1202fc..017b22a 100644
--- a/sys/kern/kern_cred.c
+++ b/sys/kern/kern_cred.c
@@ -56,6 +56,19 @@ setuid(uid_t new)
return 0;
}
+uid_t
+getuid(void)
+{
+ struct proc *td;
+
+ td = this_td();
+ if (td == NULL) {
+ return -1;
+ }
+
+ return td->cred.ruid;
+}
+
/*
* setuid() syscall
*
@@ -66,3 +79,9 @@ sys_setuid(struct syscall_args *scargs)
{
return setuid(scargs->arg0);
}
+
+scret_t
+sys_getuid(struct syscall_args *scargs)
+{
+ return getuid();
+}
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 0fb026f..b5ff144 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -351,7 +351,7 @@ fd_seek(int fildes, off_t offset, int whence)
getattr_args.vp = tmp->vp;
getattr_args.res = &attr;
- if ((vfs_vop_getattr(tmp->vp, &getattr_args)) < 0) {
+ if ((vfs_vop_getattr(&getattr_args)) < 0) {
return -EPIPE;
}
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index a4bf0f9..b1bd9ba 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -31,6 +31,8 @@
#include <sys/sched.h>
#include <sys/syslog.h>
#include <sys/panic.h>
+#include <sys/filedesc.h>
+#include <sys/vnode.h>
#include <vm/physmem.h>
#include <vm/dynalloc.h>
#include <vm/vm.h>
@@ -83,9 +85,23 @@ void
proc_reap(struct proc *td)
{
struct pcb *pcbp;
+ struct filedesc *fdp;
vaddr_t stack_va;
paddr_t stack_pa;
+ /* Clear out all fds */
+ for (size_t i = 4; i < PROC_MAX_FILEDES; ++i) {
+ fdp = td->fds[i];
+ if (fdp == NULL) {
+ continue;
+ }
+ if (fdp->refcnt == 1) {
+ vfs_release_vnode(fdp->vp);
+ dynfree(fdp);
+ fdp = NULL;
+ }
+ }
+
pcbp = &td->pcb;
unload_td(td);
diff --git a/sys/kern/kern_syscall.c b/sys/kern/kern_syscall.c
index 276c7c7..a28d2dd 100644
--- a/sys/kern/kern_syscall.c
+++ b/sys/kern/kern_syscall.c
@@ -58,6 +58,7 @@ scret_t(*g_sctab[])(struct syscall_args *) = {
sys_getpid, /* SYS_getpid */
sys_getppid, /* SYS_getppid */
sys_setuid, /* SYS_setuid */
+ sys_getuid, /* SYS_getuid */
};
const size_t MAX_SYSCALLS = NELEM(g_sctab);
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
index d88c447..7320102 100644
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -181,7 +181,7 @@ namei_mp_search(struct mount *mp, const char *path, struct nameidata *ndp)
lookup_args.dirvp = vp;
lookup_args.vpp = &vp;
- status = vfs_vop_lookup(vp, &lookup_args);
+ status = vfs_vop_lookup(&lookup_args);
dynfree(name);
if (status != 0) {
@@ -234,7 +234,7 @@ namei(struct nameidata *ndp)
lookup_args.name = path;
lookup_args.dirvp = g_root_vnode;
lookup_args.vpp = &vp;
- status = vfs_vop_lookup(lookup_args.dirvp, &lookup_args);
+ status = vfs_vop_lookup(&lookup_args);
/* Did we find it in the root */
if (status == 0) {
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index da0a4f9..69417d0 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -141,8 +141,9 @@ vfs_release_vnode(struct vnode *vp)
}
int
-vfs_vop_lookup(struct vnode *vp, struct vop_lookup_args *args)
+vfs_vop_lookup(struct vop_lookup_args *args)
{
+ const struct vnode *vp = args->dirvp;
const struct vops *vops = vp->vops;
if (vops == NULL)
@@ -180,8 +181,9 @@ vfs_vop_write(struct vnode *vp, struct sio_txn *sio)
}
int
-vfs_vop_getattr(struct vnode *vp, struct vop_getattr_args *args)
+vfs_vop_getattr(struct vop_getattr_args *args)
{
+ const struct vnode *vp = args->vp;
const struct vops *vops = vp->vops;
if (vops == NULL)
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 0d51331..d15ecf1 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -68,7 +68,7 @@ vfs_dostat(const char *path, struct stat *sbuf)
vp = nd.vp;
gattr.vp = vp;
gattr.res = &attr;
- error = vfs_vop_getattr(vp, &gattr);
+ error = vfs_vop_getattr(&gattr);
if (error != 0) {
return error;