• Miklos Szeredi's avatar
    vfs: don't set FILE_CREATED before calling ->atomic_open() · 116cc022
    Miklos Szeredi authored
    If O_CREAT|O_EXCL are passed to open, then we know that either
    
     - the file is successfully created, or
     - the operation fails in some way.
    
    So previously we set FILE_CREATED before calling ->atomic_open() so the
    filesystem doesn't have to.  This, however, led to bugs in the
    implementation that went unnoticed when the filesystem didn't check for
    existence, yet returned success.  To prevent this kind of bug, require
    filesystems to always explicitly set FILE_CREATED on O_CREAT|O_EXCL and
    verify this in the VFS.
    
    Also added a couple more verifications for the result of atomic_open():
    
     - Warn if filesystem set FILE_CREATED despite the lack of O_CREAT.
     - Warn if filesystem set FILE_CREATED but gave a negative dentry.
    Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
    Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
    116cc022
namei.c 107 KB