From: "E. Abbink" Subject: Fw: Re: Problem using mandatory locks (other apps can read/delete etc) Date: Wed, 17 Apr 2002 12:25:43 +0200 Sender: linux-fsdevel-owner@vger.kernel.org Message-ID: <200204171025.MAA28790@fikkie.vesc.nl> Reply-To: esger@bumblebeast.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Return-path: Received: from fikkie.vesc.nl (as03d033.dialin.vianetworks.nl [212.61.6.33]) by eowyn.vianetworks.nl (Postfix) with ESMTP id 91D652157A for ; Wed, 17 Apr 2002 11:49:30 +0200 (CEST) To: linux-fsdevel@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org forgot to cc this to the list, ahem.. ------------- Forwarded message follows ------------- > > >(maybe i could get along with just chmod-ing the file > >to deny everyone delete) > > But remember that nobody can delete a file anyway. The system deletes the > file of its own volition. All a user can do is remove a link to it from a > directory, and it's the permissions on the directory, not on the file, that > control your ability to modify the directory. If you're trying to preserve > the contents of the directory, either by locking or by permissions, you > have to look at the directory, not the file to which the directory refers. > what i am trying to do is prevent file corruption on files shared between several processes, not all of which care one bit about (advisory) locking. I cant change the other programs in all cases, so i need to really enforce it. > >if I read the lock using F_GETLK from another process I see the set > >write lock by the correct PID. This is identical in both (mand & > >non-mand) cases. > > > >but still, in both cases, i am able to read the file (more, display, cat > >etc). > > I'm not really clear on whether you tried to lock the file for read, as I > suggested. In the advisory lock case, you can obviously read the file in > spite of the write lock. But can you get a read lock in spite of the write > lock? I don't think any of the programs you mentioned attempt to lock the > file. > > I thought reading the lock would essentially do the same thing, confirm the lock was really set. (i already had that little program, call me lazy..) If i try to set a read lock after i set a write lock (for program see first post) i get EAGAIN. Which is the correct error afaik? -- NeoMail - Webmail that doesn't suck... as much. http://neomail.sourceforge.net -- NeoMail - Webmail that doesn't suck... as much. http://neomail.sourceforge.net