linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Fiedler Roman <Roman.Fiedler@ait.ac.at>
Cc: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Subject: Re: O_CREAT|O_DIRECTORY on nonexisting file with ext4 not posix-compliant
Date: Tue, 16 Dec 2014 13:49:26 +1100	[thread overview]
Message-ID: <20141216134926.70253edb@notabene.brown> (raw)
In-Reply-To: <2ECE9D9EEF1F524185270138AE23265947D57FA7@S0MSMAIL112.arc.local>

[-- Attachment #1: Type: text/plain, Size: 1681 bytes --]

On Mon, 15 Dec 2014 17:39:09 +0000 Fiedler Roman <Roman.Fiedler@ait.ac.at>
wrote:

> Hi,
> 
> 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 POSIX
> 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


> 
> A simple test program is:
> 
> #include <fcntl.h>
> #include <stdio.h>
> #include <sys/stat.h>
> 
> int main(int argc, char **argv) {
>   int fd;
>   struct stat statBuf;
>   int result;
> 
>   fd=open("xxx", O_RDWR|O_CREAT|O_DIRECTORY, 0600);
>   result=fstat(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);
> }
> 
> 
> Kind Regards,
> Roman
> 
> [1] http://www.openwall.com/lists/oss-security/2014/11/26/10
> 
> 
> DI Roman Fiedler
> Scientist
> Digital Safety & Security Department
> Assistive Healthcare Information Technology
> 
> AIT Austrian Institute of Technology GmbH
> Reininghausstraße 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/
> 
> FN: 115980 i HG Wien  |  UID: ATU14703506
> http://www.ait.ac.at/Email-Disclaimer
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

  reply	other threads:[~2014-12-16  2:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-15 17:39 O_CREAT|O_DIRECTORY on nonexisting file with ext4 not posix-compliant Fiedler Roman
2014-12-16  2:49 ` NeilBrown [this message]
2014-12-16 10:42   ` AW: " Fiedler Roman
2014-12-16 21:43     ` NeilBrown
2014-12-16 16:36   ` Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141216134926.70253edb@notabene.brown \
    --to=neilb@suse.de \
    --cc=Roman.Fiedler@ait.ac.at \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).