Module Name:    src
Committed By:   njoly
Date:           Sat Oct 17 22:20:56 UTC 2009

Modified Files:
        src/sys/fs/tmpfs: tmpfs_vnops.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/fs/tmpfs/tmpfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/tmpfs/tmpfs_vnops.c
diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.63 src/sys/fs/tmpfs/tmpfs_vnops.c:1.64
--- src/sys/fs/tmpfs/tmpfs_vnops.c:1.63	Tue Oct  6 00:17:24 2009
+++ src/sys/fs/tmpfs/tmpfs_vnops.c	Sat Oct 17 22:20:56 2009
@@ -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 @@
 	bool extended;
 	int error;
 	off_t oldsize;
+	struct proc *p = curproc;
 	struct tmpfs_node *node;
 	struct uvm_object *uobj;
 
@@ -612,6 +613,15 @@
 		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;
 

Reply via email to