patch-2.1.79 linux/fs/ext2/inode.c

Next file: linux/fs/fat/Makefile
Previous file: linux/fs/dquot.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.78/linux/fs/ext2/inode.c linux/fs/ext2/inode.c
@@ -209,18 +209,30 @@
 repeat:
 	tmp = *p;
 	if (tmp) {
-		result = getblk (inode->i_dev, tmp, inode->i_sb->s_blocksize);
+		struct buffer_head * result = getblk (inode->i_dev, tmp, inode->i_sb->s_blocksize);
 		if (tmp == *p)
 			return result;
 		brelse (result);
 		goto repeat;
 	}
-	if (!create || new_block >= 
-	    (current->rlim[RLIMIT_FSIZE].rlim_cur >>
-	     EXT2_BLOCK_SIZE_BITS(inode->i_sb))) {
-		*err = -EFBIG;
-		return NULL;
+	*err = -EFBIG;
+	if (!create)
+		goto dont_create;
+
+	/* Check file limits.. */
+	{
+		unsigned long limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
+		if (limit < RLIM_INFINITY) {
+			limit >>= EXT2_BLOCK_SIZE_BITS(inode->i_sb);
+			if (new_block >= limit) {
+				send_sig(SIGXFSZ, current, 0);
+dont_create:
+				*err = -EFBIG;
+				return NULL;
+			}
+		}
 	}
+
 	if (inode->u.ext2_i.i_next_alloc_block == new_block)
 		goal = inode->u.ext2_i.i_next_alloc_goal;
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov