Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ucbvax!CORY.BERKELEY.EDU!dillon From: dillon@CORY.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.amiga.tech Subject: Re: Who's got the lock? Message-ID: <8805160340.AA23871@cory.Berkeley.EDU> Date: 16 May 88 03:40:36 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 40 :>If so, how far can I trust the definition of the lock in the AmigaDOS Technical :>Reference Manual? I know some of the other structures are off-base, but I have :>not been able to find struct Lock in an include file. : :The routines would work for the AmigaDOS FS handler. (I haven't looked at the :FileLock struct recently so the member names may be off). The problem is that :a "Lock" is an opaque structure that only the handler understands. These are Actually, Locks are quite rigid. The workbench guarantees that... that is, a bug in the workbench guarantees it. You see, the workbench does a very bad thing to locks ... it copies them manually. So the size of a lock MUST be EXACTLY sizeof(struct FileLock) or you will crash the workbench. The fields within a struct FileLock are: fl_Link Usually used to link locks together in a lock list (BPTR) fl_Key disk block # (read: unique key identifying an object in this device.. see below) fl_Access exclusive or shared access fl_Task pointer to the handler's message port fl_Volume BPTR to the Device or Volume node So you see, the only two fields that can possibly take on unspecified meanings are fl_Link and fl_Key... fl_Link would not be used by every day user programs, which leaves fl_Key. The device driver has this one remaining field to discern between objects within the device... Intuitively it will contain the 'same' value for duplicate locks on the same object. Realistically the easiest programming approach IS for it to contain the 'same' value, but of course the device driver writer can always make life harder for himself and not follow this reasoning. For the floppy drivers, disk block numbers are placed in fl_Key. For my RAM: disk sample device driver, I stick a pointer to my directory/ fileheader structure. I.E. you can't assume you know what the value in the fl_Key field means, but can probably assume its uniqueness. -Matt