From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752644AbcDZRzn (ORCPT ); Tue, 26 Apr 2016 13:55:43 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:60375 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752436AbcDZRzl (ORCPT ); Tue, 26 Apr 2016 13:55:41 -0400 Date: Tue, 26 Apr 2016 18:55:38 +0100 From: Al Viro To: Linus Torvalds Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC] a corner case of open(2) Message-ID: <20160426175538.GO25498@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org According to POSIX (and behaviour on other Unices) the following should succeed: open("/tmp", O_CREAT, 0) does not have O_EXCL and the pathname does refer to existing object, so O_CREAT is ignored and the call is equivalent to open("/tmp", 0), which succeeds. We have it rejected with EISDIR. The thing is, the standard behaviour is actually less messy wrt code, and do_last()/lookup_open()/atomic_open() badly needs untangling. Another place where we produce a bogus EISDIR is O_CREAT|O_EXCL on an existing directory. POSIX (and other Unices) have EEXIST there. In some cases we produce EEXIST, in some - EISDIR. Uniform EEXIST is actually easier. It is a change of user-visible behaviour, but I would be very surprised if anything broke from that change. And it would help to simplify the awful mess we have in there. Comments?