NetBSD Problem Report #48351

From www@NetBSD.org  Tue Oct 29 06:58:59 2013
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 1C8D2A5D79
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 29 Oct 2013 06:58:59 +0000 (UTC)
Message-Id: <20131029065857.9A7D8A5EBF@mollari.NetBSD.org>
Date: Tue, 29 Oct 2013 06:58:57 +0000 (UTC)
From: dennis.c.ferguson@gmail.com
Reply-To: dennis.c.ferguson@gmail.com
To: gnats-bugs@NetBSD.org
Subject: flock(1) -x, -s and -u options don't work
X-Send-Pr-Version: www-1.0

>Number:         48351
>Category:       bin
>Synopsis:       flock(1) -x, -s and -u options don't work
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 29 07:00:00 +0000 2013
>Closed-Date:    Fri Nov 07 08:25:57 +0000 2014
>Last-Modified:  Fri Nov 07 08:25:57 +0000 2014
>Originator:     Dennis Ferguson
>Release:        6.99.24
>Organization:
no organisation at all
>Environment:
NetBSD b1.to.mistimed.ca 6.99.24 NetBSD 6.99.24 (GENERIC) #3: Fri Oct 11 14:35:16 EDT 2013  dennis@b1.to.mistimed.ca:/build/amd64/obj/sys/arch/amd64/compile/GENERIC amd64

>Description:
flock(1) complains and quits if any of the -x, -s or -u options is specified
>How-To-Repeat:
$ flock -s 0
flock: -s can't be used with -x
Usage: flock [-dnosvx] [-w timeout] lockfile|lockdir [-c command]|command ...
        flock [-dnsuvx] [-w timeout] lockfd
$ flock -x 0 
flock: -x can't be used with -x
Usage: flock [-dnosvx] [-w timeout] lockfile|lockdir [-c command]|command ...
        flock [-dnsuvx] [-w timeout] lockfd
$ flock -u 0  
flock: -u can't be used with -x
Usage: flock [-dnosvx] [-w timeout] lockfile|lockdir [-c command]|command ...
        flock [-dnsuvx] [-w timeout] lockfd


>Fix:

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48351 CVS commit: src/usr.bin/flock
Date: Tue, 29 Oct 2013 12:02:15 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Tue Oct 29 16:02:15 UTC 2013

 Modified Files:
 	src/usr.bin/flock: flock.c

 Log Message:
 PR/48351: Dennis Ferguson: Fix incorrect parsing of flock flags.
 XXX: still flock -s 0 fails with EINVAL, why?


 To generate a diff of this commit:
 cvs rdiff -u -r1.7 -r1.8 src/usr.bin/flock/flock.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Dennis Ferguson <dennis.c.ferguson@gmail.com>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: PR/48351 CVS commit: src/usr.bin/flock
Date: Tue, 29 Oct 2013 12:46:51 -0400

 On 29 Oct, 2013, at 12:05 , Christos Zoulas <christos@netbsd.org> wrote:
 > XXX: still flock -s 0 fails with EINVAL, why?

 Does it stop if you do a flock -u 0 first?

 I see code in the kernel to handle upgrading a lock from shared
 to exclusive, but I don't see anything to deal with downgrading
 from exclusive to shared (though I may be missing something).

 Dennis Ferguson

From: Dennis Ferguson <dennis.c.ferguson@gmail.com>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: PR/48351 CVS commit: src/usr.bin/flock
Date: Tue, 29 Oct 2013 14:24:36 -0400

 On 29 Oct, 2013, at 12:05 , Christos Zoulas <christos@netbsd.org> wrote:
 > Subject: PR/48351 CVS commit: src/usr.bin/flock

 It might be good to edit the flock(1) man page as well.  It has an example
 that opens fd 100 with a

     ... 100> /path/to/lockfile

 but I've been unable to get that type of redirection to work with /bin/sh
 for anything other than single digit fd numbers.

 Dennis Ferguson

From: christos@zoulas.com (Christos Zoulas)
To: Dennis Ferguson <dennis.c.ferguson@gmail.com>, gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: PR/48351 CVS commit: src/usr.bin/flock
Date: Tue, 29 Oct 2013 14:25:13 -0400

 On Oct 29, 12:46pm, dennis.c.ferguson@gmail.com (Dennis Ferguson) wrote:
 -- Subject: Re: PR/48351 CVS commit: src/usr.bin/flock

 | 
 | On 29 Oct, 2013, at 12:05 , Christos Zoulas <christos@netbsd.org> wrote:
 | > XXX: still flock -s 0 fails with EINVAL, why?
 | 
 | Does it stop if you do a flock -u 0 first?
 | 
 | I see code in the kernel to handle upgrading a lock from shared
 | to exclusive, but I don't see anything to deal with downgrading
 | from exclusive to shared (though I may be missing something).

 Nope, we need some kernel work I guess:

 [2:24pm] 2544>flock -u 0
 Exit 1
 [2:24pm] 2545>flock -s 0
 Exit 1

 christos

From: Dennis Ferguson <dennis.c.ferguson@gmail.com>
To: Christos Zoulas <christos@zoulas.com>
Cc: gnats-bugs@NetBSD.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: PR/48351 CVS commit: src/usr.bin/flock
Date: Tue, 29 Oct 2013 15:32:32 -0400

 On 29 Oct, 2013, at 14:25 , Christos Zoulas <christos@zoulas.com> wrote:
 > Nope, we need some kernel work I guess:
 > 
 > [2:24pm] 2544>flock -u 0
 > Exit 1
 > [2:24pm] 2545>flock -s 0
 > Exit 1

 Ah, maybe it's my fault for not providing a better example.  This
 seems to work:

 $ (                                                                          
 > ./flock -s 0; echo $?
 > ./flock -x 0; echo $?
 > ./flock -s 0; echo $?
 > ./flock -u 0; echo $?
 > ) < /tmp/a_file
 0
 0
 0
 0

 I think the thing being locked might need to be a regular file.

 Dennis Ferguson

From: christos@zoulas.com (Christos Zoulas)
To: Dennis Ferguson <dennis.c.ferguson@gmail.com>
Cc: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: PR/48351 CVS commit: src/usr.bin/flock
Date: Tue, 29 Oct 2013 17:19:46 -0400

 On Oct 29,  3:32pm, dennis.c.ferguson@gmail.com (Dennis Ferguson) wrote:
 -- Subject: Re: PR/48351 CVS commit: src/usr.bin/flock

 | Ah, maybe it's my fault for not providing a better example.  This
 | seems to work:
 | 
 | $ (                                                                          
 | > ./flock -s 0; echo $?
 | > ./flock -x 0; echo $?
 | > ./flock -s 0; echo $?
 | > ./flock -u 0; echo $?
 | > ) < /tmp/a_file
 | 0
 | 0
 | 0
 | 0
 | 
 | I think the thing being locked might need to be a regular file.

 On linux locking 0 on the shell works...

 christos

From: "SAITOH Masanobu" <msaitoh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48351 CVS commit: [netbsd-6] src/usr.bin/flock
Date: Mon, 3 Nov 2014 19:26:02 +0000

 Module Name:	src
 Committed By:	msaitoh
 Date:		Mon Nov  3 19:26:02 UTC 2014

 Modified Files:
 	src/usr.bin/flock [netbsd-6]: flock.1 flock.c

 Log Message:
 Pull up following revision(s) (requested by manu in ticket #1143):
 	usr.bin/flock/flock.c: revision 1.10
 	usr.bin/flock/flock.c: revision 1.11
 	usr.bin/flock/flock.1: revision 1.10
 	usr.bin/flock/flock.c: revision 1.8
 PR/48351: Dennis Ferguson: Fix incorrect parsing of flock flags.
 XXX: still flock -s 0 fails with EINVAL, why?
 make this behave like linux.
 remove XXX, fix error message
 mention that -x is the default.


 To generate a diff of this commit:
 cvs rdiff -u -r1.8.4.3 -r1.8.4.4 src/usr.bin/flock/flock.1
 cvs rdiff -u -r1.6.4.3 -r1.6.4.4 src/usr.bin/flock/flock.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: msaitoh@NetBSD.org
State-Changed-When: Fri, 07 Nov 2014 08:25:57 +0000
State-Changed-Why:
Fixed and pulled up.
Thanks.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.