public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] s_maxbytes handling
@ 2001-05-22 12:52 Andrew Morton
  2001-05-22 13:27 ` Alan Cox
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Morton @ 2001-05-22 12:52 UTC (permalink / raw)
  To: lkml

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)

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: [patch] s_maxbytes handling
@ 2001-05-22 19:33 Andries.Brouwer
  0 siblings, 0 replies; 8+ messages in thread
From: Andries.Brouwer @ 2001-05-22 19:33 UTC (permalink / raw)
  To: linux-kernel, torvalds

Linus writes:

	0 is EOF _for_reads_. For writes it is not very well defined

Hmm.

	So -EFBIG is certainly the preferable return value,

Yes. The Austin 6th draft writes

EFBIG:
An attempt was made to write a file that exceeds the implementation-defined
maximum file size  or the process' file size limit, and there was no room for 
any bytes to be written.

Andries

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-05-23 18:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-05-22 12:52 [patch] s_maxbytes handling Andrew Morton
2001-05-22 13:27 ` 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
  -- strict thread matches above, loose matches on Subject: below --
2001-05-22 19:33 Andries.Brouwer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox