From owner-freebsd-bugs@FreeBSD.ORG Thu Apr 30 11:25:54 2015 Return-Path: Delivered-To: freebsd-bugs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 026719C7 for ; Thu, 30 Apr 2015 11:25:54 +0000 (UTC) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C69DA16E1 for ; Thu, 30 Apr 2015 11:25:53 +0000 (UTC) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.14.9/8.14.9) with ESMTP id t3UBPrvu073274 for ; Thu, 30 Apr 2015 11:25:53 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 199806] Add a new option letter "l" to make fopen() use O_SHLOCK or O_EXLOCK when calling open() Date: Thu, 30 Apr 2015 11:25:53 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 11.0-CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: jau@iki.fi X-Bugzilla-Status: New X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Apr 2015 11:25:54 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=199806 Bug ID: 199806 Summary: Add a new option letter "l" to make fopen() use O_SHLOCK or O_EXLOCK when calling open() Product: Base System Version: 11.0-CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: freebsd-bugs@FreeBSD.org Reporter: jau@iki.fi Created attachment 156144 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=156144&action=edit A patch to add the proposed new option letter to fopen() This is a change proposal. Since FreeBSD already has the open() flags O_SHLOCK and O_EXLOCK it would make sense for the same feature to be also available when calling fopen(). So, I propose adding a new option letter "l" to force fopen() to add the suitable one of these locking flags when calling open(), O_SHLOCK for "r" and O_EXLOCK for "w", "r+", etc. Such an extension is of course non-standard, but when code portability is not a big issue such an extension would make FreeBSD specific code easier to read and write, and maybe also a bit more robust while avoiding the need to go the extra mille passum to call fileno() and flock() later. >From my point of view writing something like... fp = fopen("whateverfile", "wb+lex"); ... is a pretty neat idea. Either I get a handle to a completely new file with the exclusive lock applied, and it will not be left open after an exec*() call, or I get a NULL. Obviously the same change applies to 10.1 as well, if the merits of this idea are accepted. -- You are receiving this mail because: You are the assignee for the bug.