Question about file locking

Rechenberg, Andy ARechenberg at Hasbro.com
Mon Jul 24 18:08:07 GMT 2000


Basically I'm opening a file with an application (e.g. Windows Notepad) and
no lock is being placed on the file at all.  Another user can open the file
in question and write to it while I have the file open.  

Here's what I get from a "smbstatus" when I have the file "test.txt" open
with notepad:

**************************************************************
[root at vfr ~]# smbstatus

Samba version 2.0.6
Service      uid      gid      pid     machine
----------------------------------------------
_projects    engaxr0  projects  7124   chris    (136.113.12.149) Mon Jul
24 13:55:06 2000

No locked files

Share mode memory usage (bytes):
   1048464(99%) free + 56(0%) used + 56(0%) overhead = 1048576(100%) total
**************************************************************

It shows "No locked files."  If I open the same file with MS Word 97
"smbstatus" outputs the following:


**************************************************************
[root at vfr ~]# smbstatus

Samba version 2.0.6
Service      uid      gid      pid     machine
----------------------------------------------
_projects    engaxr0  projects  7124   chris    (136.113.12.149) Mon Jul
24 13:55:06 2000

Locked files:
Pid    DenyMode   R/W        Oplock           Name
--------------------------------------------------
7124   DENY_WRITE RDWR       NONE             /home/_projects/test.txt
Mon Jul 24 13:56:46 2000

Share mode memory usage (bytes):
   1048360(99%) free + 144(0%) used + 72(0%) overhead =
1048576(100%) total
**************************************************************


Notepad seems to obey that lock because I cannot write to test.txt once Word
has the file open, but it never creates a lock when opening the file.  I
want to be able to lock the file so that it is DENY_WRITE so that others can
view the file but not be able to write changes to it.  

Is it the responsibility of the application to request the lock?  Because
Notepad (and a couple of other applications I'm using) does not seem to lock
the file at all.  Very frustrating :)

Thanks for the help.

Regards,
Andy.



-----Original Message-----
From: Jeremy Allison [mailto:jeremy at valinux.com]
Sent: Monday, July 24, 2000 1:26 PM
To: Rechenberg, Andy
Cc: 'samba-technical at samba.org'
Subject: Re: Question about file locking


"Rechenberg, Andy" wrote:

> Does an application have to request a lock before Samba will impose one?
> The reason I ask is because I'm trying to setup a box to serve files for a
> mostly Windows NT-based network (NT4SP5, and some Win95SR2 boxes) with
Samba
> and everything is working fine (shows up in Net Hood, can browse fine,
home
> directories show up) EXCEPT file locking.
> 
> Only some applications actually lock a file that is accessed (Word, Excel,
> AutoCAD, etc.).  If I use Notepad, Wordpad, or some other applications, no
> file lock is put in place.  I have file locking, and strict locking both
set
> to "yes."

With strict locking Samba will place an fcntl lock over
a the region to be read/written just before doing so and
will unlock afterwards.

Remember that oplocks will skew the fcntl locks seen on
the UNIX box as if a client has oplocked a file it has
no need to send locking requests to the server.

Can you be more specific about any problems you are
seeing ?

Regards,

	Jeremy Allison,
	Samba Team.

-- 
--------------------------------------------------------
Buying an operating system without source is like buying
a self-assembly Space Shuttle with no instructions.
--------------------------------------------------------




More information about the samba-technical mailing list