[patch] s_maxbytes handling

Andrew Morton (andrewm@uow.edu.au)
Tue, 22 May 2001 22:52:52 +1000


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)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/