linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <andrewm@uow.edu.au>
To: lkml <linux-kernel@vger.kernel.org>
Subject: [patch] s_maxbytes handling
Date: Tue, 22 May 2001 22:52:52 +1000	[thread overview]
Message-ID: <3B0A6124.E90717E7@uow.edu.au> (raw)

If ->f_pos is positioned exactly at sb->s_maxbytes, a non-zero-length
write to the file doesn't write anything, and write() returns zero.

Consequently applications which try to append to a file which
is s_maxbytes in length hang up, because write() just keeps
on returning zero.

We need to return -EFBIG if ->f_pos is at s_maxbytes and
the length is non-zero.

--- linux-2.4.5-pre4/mm/filemap.c	Mon May 21 20:03:03 2001
+++ linux-akpm/mm/filemap.c	Tue May 22 22:34:41 2001
@@ -2571,11 +2571,13 @@
 	 *	Linus frestrict idea will clean these up nicely..
 	 */
 	 
-	if (pos > inode->i_sb->s_maxbytes)
-	{
-		send_sig(SIGXFSZ, current, 0);
-		err = -EFBIG;
-		goto out;	
+	if (pos >= inode->i_sb->s_maxbytes) {
+		if (count || pos > inode->i_sb->s_maxbytes) {
+			send_sig(SIGXFSZ, current, 0);
+			err = -EFBIG;
+			goto out;
+		}
+		/* zero-length writes at ->s_maxbytes are OK */
 	}
 
 	if (pos + count > inode->i_sb->s_maxbytes)

             reply	other threads:[~2001-05-22 12:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-22 12:52 Andrew Morton [this message]
2001-05-22 13:27 ` [patch] s_maxbytes handling Alan Cox
2001-05-22 14:47   ` Andrew Morton
2001-05-22 15:05     ` Alan Cox
2001-05-22 17:49       ` Linus Torvalds
2001-05-22 18:24         ` David N. Lombard
2001-05-23 18:02       ` Stephen C. Tweedie
2001-05-22 19:33 Andries.Brouwer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3B0A6124.E90717E7@uow.edu.au \
    --to=andrewm@uow.edu.au \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).