From mboxrd@z Thu Jan 1 00:00:00 1970 From: NeilBrown Subject: Re: O_CREAT|O_DIRECTORY on nonexisting file with ext4 not posix-compliant Date: Tue, 16 Dec 2014 13:49:26 +1100 Message-ID: <20141216134926.70253edb@notabene.brown> References: <2ECE9D9EEF1F524185270138AE23265947D57FA7@S0MSMAIL112.arc.local> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/X8wW8WzhkJOWmeK9gC74092"; protocol="application/pgp-signature" Cc: "linux-fsdevel@vger.kernel.org" , "Michael Kerrisk (man-pages)" To: Fiedler Roman Return-path: Received: from cantor2.suse.de ([195.135.220.15]:42250 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752518AbaLPCtf (ORCPT ); Mon, 15 Dec 2014 21:49:35 -0500 In-Reply-To: <2ECE9D9EEF1F524185270138AE23265947D57FA7@S0MSMAIL112.arc.local> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: --Sig_/X8wW8WzhkJOWmeK9gC74092 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, 15 Dec 2014 17:39:09 +0000 Fiedler Roman wrote: > Hi, >=20 > It seems that the open syscall is not POSIX-compliant when using both > O_CREAT|O_DIRECTORY. This was discussed in [1] with a reference to the PO= SIX > documentation. Given that O_DIRECTORY is not part of POSIX, I don't think that POSIX-compliance is an issue here. However the implementation does seem to differ from the Linux documentation. I suggest you submit a patch to the manpages project to change If pathname is not a directory to If pathname exists and is not a directory That should fix the problem. NeilBrown >=20 > A simple test program is: >=20 > #include > #include > #include >=20 > int main(int argc, char **argv) { > int fd; > struct stat statBuf; > int result; >=20 > fd=3Dopen("xxx", O_RDWR|O_CREAT|O_DIRECTORY, 0600); > result=3Dfstat(fd, &statBuf); > if(result) { > fprintf(stderr, "Stat failed\n"); > return(1); > } > fprintf(stderr, "New element type is %d\n", S_ISDIR(statBuf.st_mode)); > return(0); > } >=20 >=20 > Kind Regards, > Roman >=20 > [1] http://www.openwall.com/lists/oss-security/2014/11/26/10 >=20 >=20 > DI Roman Fiedler > Scientist > Digital Safety & Security Department > Assistive Healthcare Information Technology >=20 > AIT Austrian Institute of Technology GmbH > Reininghausstra=C3=9Fe 13/1 | 8020 Graz | Austria > T +43(0) 50550 2957 | M +43(0) 664 8561599 | F +43(0) 50550 2950 > roman.fiedler@ait.ac.at | http://www.ait.ac.at/ >=20 > FN: 115980 i HG Wien=C2=A0 |=C2=A0 UID: ATU14703506 > http://www.ait.ac.at/Email-Disclaimer >=20 --Sig_/X8wW8WzhkJOWmeK9gC74092 Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIVAwUBVI+dtjnsnt1WYoG5AQJwvRAAhvf3emlHHWxbDEMYd5AMeyaIbXQTL/jh 2bJKD3vvCUw1GkChOb28fC1PdLg9asJjk34rplrp06ycVXS7/7zrwkZh+MCChU6V Wn98GWJwzkpNJD+K6vQw9k6kByjSPTM3hIvVAFjtO4bWaxEol0x14mdrS4h0Lysb t+KrWlB2kE/wEqvUJ5ivdGGQhvLmsFQaJNqIgpuQ7TvUBFJI5nv22kA+WtOnKbUR V2l0UHJTXq1RTg/7gHpqaeGF8z/nRynGKcA5+dNrkvhj241jQVdq9QwRcKeCfMtR JMktfSlBBaoZ+1cLz87mcEcz8Q7vWtIVuT4CyJw8bYKTmkVTxO8VtFcMDRagM4hX tmQAS4yFBTW7/8RMsvFrOyEAsZWn4o2aAFgSKDNgWV5hIGlEazDTB8vE39ktzxEg BNK96QBsQ65c2AEyRB0sl03uxugOe+1kWL4+/LIr6MyW175UFEQPy76KGsRX1lAI QhYnszdd9h0gLEUi22m70g5LrPZsIEMR3CeWrH97w1fLbr5b7R9sSd8X894ZD+BV 8ZOH/g2GT9u+m2Velsp5JIYBh+8k7Q6DO4gpVERGgepdZkIoLHEjL8JixDR74ro+ iXA5afi8AIOXJJ+E2Rb40R3EjkV0ENuWORwbGkkQgSDjNDAk+J4HhvyANciK7ULV iRLQMQBitYE= =Zr5+ -----END PGP SIGNATURE----- --Sig_/X8wW8WzhkJOWmeK9gC74092--