From owner-freebsd-standards@FreeBSD.ORG Fri Apr 29 13:17:48 2011 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7B31C1065673 for ; Fri, 29 Apr 2011 13:17:48 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id 39A968FC15 for ; Fri, 29 Apr 2011 13:17:47 +0000 (UTC) Received: by qwc9 with SMTP id 9so2190579qwc.13 for ; Fri, 29 Apr 2011 06:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=JAnblh2ML4PM5qUQnRZwz6Ri19MbJxczU80N0a7UiJ0=; b=tTUMT8p5JmwI/K58XmgfArEPViGNPy0ZEnDGhIRzGDaM5TcqHWWmA9Ox8rTqGjBop+ oPEsfDiViQlcdGajEhDxa3Ol7wikC/fhSmgh+c0mTDEBevKw9R1+0l6sWJUwC8qGsdTF dhLRgsYAktbEbYyIJvebyhE3uv92f+okJpE5c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=wGDJ2uzqE9MvbK+P9aYj/nUP5ETZ1Qi2oLiHeTbp53KcsFM1RuIUvMM7g4ewS41G5Z mNcnwXgPSuzrErn0aao5L8ONs1xLK1utC37jeDfpvdb86ZA1ue4zTgadZxKFxtUz1/WF 1sJSCYiKwCU6PSybYa//fOR9Uo7rWhGuTFvEk= MIME-Version: 1.0 Received: by 10.229.62.198 with SMTP id y6mr3750034qch.290.1304081498451; Fri, 29 Apr 2011 05:51:38 -0700 (PDT) Received: by 10.229.97.146 with HTTP; Fri, 29 Apr 2011 05:51:38 -0700 (PDT) Date: Fri, 29 Apr 2011 16:51:38 +0400 Message-ID: From: Sergey Kandaurov To: freebsd-standards@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Subject: O_ACCMODE doesn't respect O_EXEC X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Apr 2011 13:17:48 -0000 Hi. As of now, O_ACCMODE is a conjunction of O_{RDONLY,WRONLY,RDWR} flags as it was from the beginning. Its definition hasn't changed with addition of O_EXEC. POSIX states: O_ACCMODE - Mask for file access modes. O_EXEC falls into this access modes category, so I think O_ACCMODE should include O_EXEC. This may require review of O_ACCMODE usage throughout the kernel, though.. This simple test demonstrates the problem: flags: 0x0 flags: 0x0 flags: 0x1 flags: 0x1 flags: 0x2 flags: 0x2 flags: 0x3ffff flags: 0x3 ^^ decremented due OFLAGS macro that also doesn't respect new access mode flag(s) ^^ correct version would show 0x40000 int main(void) { test_with(O_RDONLY); test_with(O_WRONLY); test_with(O_RDWR); test_with(O_EXEC); return (0); } static void test_with(int openflag) { int fd, flags; if ((fd = open("file", openflag)) < 0) err(1, "open"); if ((flags = fcntl(fd, F_GETFL)) < 0) err(1, "fcntl(fd, GETFL)"); printf("flags: 0x%x\n", flags); printf("flags: 0x%x\n", flags&O_ACCMODE); close(fd); } -- wbr, pluknet