From: Stefan Behrens Subject: Not POSIX conform: open(..., O_CREAT | O_RDWR, ...) returns -1 although a file was created Date: Fri, 29 Jul 2011 15:47:44 +0200 Message-ID: <4E32BA00.3060402@giantdisaster.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit To: linux-fsdevel@vger.kernel.org Return-path: Received: from mo-p00-ob.rzone.de ([81.169.146.162]:57328 "EHLO mo-p00-ob.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754349Ab1G2NsH (ORCPT ); Fri, 29 Jul 2011 09:48:07 -0400 Received: from [IPv6:2a01:238:e100:320:fd3b:e161:dd0f:8d66] ([2a01:238:e100:320:fd3b:e161:dd0f:8d66]) by smtp.strato.de (klopstock mo36) (RZmta 26.2) with ESMTPA id x00d31n6TCLmHE for ; Fri, 29 Jul 2011 15:47:40 +0200 (MEST) Sender: linux-fsdevel-owner@vger.kernel.org List-ID: IEEE 1003.1-2004 says that open() must not have created or modified a file if -1 is returned. But this happens with the released Linux kernel 3.0.0, x86_64. This issue happens when you run test 079 from xfstests on an ext2, ext3, ext4 or btrfs filesystem. This test 079 makes use of the append-only flag. It is set on the directory and inherited to the created file. The test 079 creates the situation that during a call to open(..., O_CREAT | O_RDWR, ...) the creation of the file is allowed but the opening for writing is not allowed. The expected behaviour would be that open() returns -1 and that the file _is_ _not_ created. The recognized behaviour is that -1 is returned but the file _is_ created. mkdir("/mnt3/foo/append-only.d", 0777) = 0 open("/mnt3/foo/append-only.d", O_RDONLY) = 3 ioctl(3, FS_IOC32_SETFLAGS or FS_IOC_SETFLAGS, 0x7fffaf60b07c) = 0 (this ioctl enables FS_APPEND_FL for the directory) close(3) open("/mnt3/foo/append-only.d/newfile-0", O_RDWR|O_CREAT, 0666) = -1 EPERM (Operation not permitted) But you can see that an empty file was created although -1 was returned.