NetBSD Problem Report #30303
From khym@azeotrope.org Sun May 22 07:39:14 2005
Return-Path: <khym@azeotrope.org>
Received: from yerfable.azeotrope.org (cdm-208-180-124-100.gtwn.cox-internet.com [208.180.124.100])
by narn.netbsd.org (Postfix) with ESMTP id 9F95163B104
for <gnats-bugs@gnats.NetBSD.org>; Sun, 22 May 2005 07:39:14 +0000 (UTC)
Message-Id: <20050522073902.41D3B4C890@yerfable.azeotrope.org>
Date: Sun, 22 May 2005 02:39:02 -0500 (CDT)
From: khym@azeotrope.org
Reply-To: khym@azeotrope.org
To: gnats-bugs@netbsd.org
Subject: Unlocking already-unlocked file on smbfs returns EBUSY
X-Send-Pr-Version: 3.95
>Number: 30303
>Category: kern
>Synopsis: Unlocking already-unlocked file on smbfs returns EBUSY
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: jdolecek
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun May 22 07:40:00 +0000 2005
>Closed-Date: Fri Jun 17 17:19:58 +0000 2005
>Last-Modified: Tue Jun 28 03:25:00 +0000 2005
>Originator: Dave Huang
>Release: NetBSD 2.0
>Organization:
Name: Dave Huang | Mammal, mammal / their names are called /
INet: khym@azeotrope.org | they raise a paw / the bat, the cat /
FurryMUCK: Dahan | dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 29 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++
>Environment:
System: NetBSD yerfable.azeotrope.org 2.0 NetBSD 2.0 (YERFABLE) #214: Sun Dec 12 07:15:04 CST 2004 khym@yerfable.azeotrope.org:/usr2/obj.alpha/sys/arch/alpha/compile/YERFABLE alpha
Architecture: alpha
Machine: alpha
>Description:
Calling flock(2) to unlock a file that's not locked succeeds
the file is on a FFS filesystem. However, if the file is on SMBFS, the
flock() call returns an error and sets errno to EBUSY. According to
the manpage, EBUSY is not an error flock() should return, and it seems
to me that it shouldn't return any error in this case.
This is apparently due to smb_maperror() in
sys/netsmb/smb_subr.c mapping the ERRnotlocked returned by the SMB
server to EBUSY, then that getting passed back up to flock()'s caller.
>How-To-Repeat:
#include <fcntl.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
int f;
if (argc < 2) {
fprintf(stderr, "Usage: %s filename\n", argv[0]);
return 1;
}
if ((f = open(argv[1], O_RDWR | O_CREAT, 0666)) == -1) {
perror("open");
return 1;
}
if (flock(f, LOCK_UN) == -1) {
perror("flock");
return -1;
}
printf("No error\n");
return 0;
}
% ./locktest /usr/tmp/abc
No error
% ./locktest /c/abc
flock: Device busy
(Where /usr/tmp is ffs, and /c is smbfs)
>Fix:
I don't know... perhaps smb_advlock() should see if it gets
EBUSY when unlocking, and return success in that case?
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: kern-bug-people->jdolecek
Responsible-Changed-By: jdolecek@netbsd.org
Responsible-Changed-When: Sun, 12 Jun 2005 15:26:16 +0000
Responsible-Changed-Why:
Mine :)
State-Changed-From-To: open->feedback
State-Changed-By: jdolecek@netbsd.org
State-Changed-When: Sun, 12 Jun 2005 15:26:16 +0000
State-Changed-Why:
Patch provided, please test.
From: Jaromir Dolecek <jdolecek@NetBSD.org>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org,
netbsd-bugs@NetBSD.org
Subject: Re: kern/30303: Unlocking already-unlocked file on smbfs returns EBUSY
Date: Sun, 12 Jun 2005 17:25:27 +0200
> This is apparently due to smb_maperror() in
> sys/netsmb/smb_subr.c mapping the ERRnotlocked returned by the SMB
> server to EBUSY, then that getting passed back up to flock()'s caller.
This is right :)
Can you try this patch?
Index: smb_subr.c
===================================================================
RCS file: /cvsroot/src/sys/netsmb/smb_subr.c,v
retrieving revision 1.21
diff -u -p -r1.21 smb_subr.c
--- smb_subr.c 26 Feb 2005 22:39:50 -0000 1.21
+++ smb_subr.c 12 Jun 2005 15:24:26 -0000
@@ -241,7 +241,8 @@ smb_maperror(int eclass, int eno)
case ERRquota:
return EDQUOT;
case ERRnotlocked:
- return EBUSY;
+ /* it's okay to try to unlock already unlocked file */
+ return 0;
case NT_STATUS_NOTIFY_ENUM_DIR:
return EMSGSIZE;
}
Jaromir
--
Jaromir Dolecek <jdolecek@NetBSD.org> http://www.NetBSD.cz/
-=- We can walk our road together if our goals are all the same; -=-
-=- We can run alone and free if we pursue a different aim. -=-
From: Dave Huang <khym@azeotrope.org>
To: Jaromir Dolecek <jdolecek@NetBSD.org>
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/30303: Unlocking already-unlocked file on smbfs returns EBUSY
Date: Tue, 14 Jun 2005 03:15:47 -0500
On Sun, Jun 12, 2005 at 05:25:27PM +0200, Jaromir Dolecek wrote:
> > This is apparently due to smb_maperror() in
> > sys/netsmb/smb_subr.c mapping the ERRnotlocked returned by the SMB
> > server to EBUSY, then that getting passed back up to flock()'s caller.
>
> This is right :)
>
> Can you try this patch?
That fixes it; thanks!
State-Changed-From-To: feedback->closed
State-Changed-By: jdolecek@netbsd.org
State-Changed-When: Fri, 17 Jun 2005 17:19:58 +0000
State-Changed-Why:
Confirmed fixed. Thanks.
From: Dave Huang <khym@azeotrope.org>
To: Jaromir Dolecek <jdolecek@NetBSD.org>
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/30303
Date: Sat, 18 Jun 2005 05:30:29 -0500
> Synopsis: Unlocking already-unlocked file on smbfs returns EBUSY
>
> State-Changed-From-To: feedback->closed
> State-Changed-By: jdolecek@netbsd.org
> State-Changed-When: Fri, 17 Jun 2005 17:19:58 +0000
> State-Changed-Why:
> Confirmed fixed. Thanks.
Yes, the patch fixed it, but... I don't think you actually commited
the patch :)
From: Dave Huang <khym@azeotrope.org>
To: current-users@netbsd.org
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/30303: Unlocking already-unlocked file on smbfs returns EBUSY
Date: Mon, 27 Jun 2005 21:53:35 -0500
Hi, could someone either commit the patch in PR kern/30303 or re-open
the PR so it doesn't get forgotten? The PR was closed without the
patch having actually been comitted.
From: Christos Zoulas <christos@netbsd.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: PR/30303 CVS commit: src/sys/netsmb
Date: Tue, 28 Jun 2005 03:24:32 +0000 (UTC)
Module Name: src
Committed By: christos
Date: Tue Jun 28 03:24:32 UTC 2005
Modified Files:
src/sys/netsmb: smb_subr.c
Log Message:
PR/30303: Dave Huang: It is ok to unlock an unlocked file.
To generate a diff of this commit:
cvs rdiff -r1.22 -r1.23 src/sys/netsmb/smb_subr.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.