Skip to contentSkip to conversation

0 byte writes should not seek even with O_APPEND

PATCH New Christopher Yeoh 1 participant 1 message Nov 20, 2000

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 0 byte writes should not seek even with O_APPEND

Hi Linus,

Currently when a zero byte write is done on a regular file opened with O_APPEND the file offset is set to the end of the file. For POSIX compliant behaviour this shouldn't happen.

The attached patch fixes this.

Chris.

filemap.c renamed from filemap.c.orig +8 -5
@@ -2458,12 +2458,15 @@
 		}
 	}
 
-	status  = 0;
-	if (count) {
-		remove_suid(inode);
-		inode->i_ctime = inode->i_mtime = CURRENT_TIME;
-		mark_inode_dirty(inode);
+	if (count == 0) {
+		err = 0;
+		goto out;
 	}
+
+	status  = 0;
+	remove_suid(inode);
+	inode->i_ctime = inode->i_mtime = CURRENT_TIME;
+	mark_inode_dirty(inode);
 
 	while (count) {
 		unsigned long bytes, index, offset;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/