Make tmpfs write fail when process file size limit is reached.

This commit is contained in:
njoly 2009-10-17 22:20:56 +00:00
parent eea7b3ade4
commit 6a42e0741e
1 changed files with 12 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: tmpfs_vnops.c,v 1.63 2009/10/06 00:17:24 rmind Exp $ */
/* $NetBSD: tmpfs_vnops.c,v 1.64 2009/10/17 22:20:56 njoly Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.63 2009/10/06 00:17:24 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.64 2009/10/17 22:20:56 njoly Exp $");
#include <sys/param.h>
#include <sys/dirent.h>
@ -594,6 +594,7 @@ tmpfs_write(void *v)
bool extended;
int error;
off_t oldsize;
struct proc *p = curproc;
struct tmpfs_node *node;
struct uvm_object *uobj;
@ -612,6 +613,15 @@ tmpfs_write(void *v)
goto out;
}
if (((uio->uio_offset + uio->uio_resid) >
p->p_rlimit[RLIMIT_FSIZE].rlim_cur)) {
mutex_enter(proc_lock);
psignal(p, SIGXFSZ);
mutex_exit(proc_lock);
error = EFBIG;
goto out;
}
if (ioflag & IO_APPEND)
uio->uio_offset = node->tn_size;