a1200   NEWS   APPS   DOCS   ABOUT
a1200
----
a1200
----
Autodocs
 Libraries:
 dos.library
  AbortPkt
  AddBuffers
  AddDosEntry
  AddPart
  AddSegment
  AllocDosObject
  AssignAdd
  AssignLate
  AssignLock
  AssignPath
  AttemptLockDosList
  ChangeMode
  CheckSignal
  Cli
  CliInitNewcli
  CliInitRun
  Close
  CompareDates
  CreateDir
  CreateNewProc
  CreateProc
  CurrentDir
  DateStamp
  DateToStr
  Delay
  DeleteFile
  DeleteVar
  DeviceProc
  DoPkt
  DupLock
  DupLockFromFH
  EndNotify
  ErrorReport
  ExAll
  ExAllEnd
  ExNext
  Examine
  ExamineFH
  Execute
  Exit
  FGetC
  FGets
  FPutC
  FPuts
  FRead
  FWrite
  Fault
  FilePart
  FindArg
  FindCliProc
  FindDosEntry
  FindSegment
  FindVar
  Flush
  Format
  FreeArgs
  FreeDeviceProc
  FreeDosEntry
  FreeDosObject
  GetArgStr
  GetConsoleTask
  GetCurrentDirName
  GetDeviceProc
  GetFileSysTask
  GetProgramDir
  GetProgramName
  GetPrompt
  GetVar
  Info
  Inhibit
  Input
  InternalLoadSeg
  InternalUnLoadSeg
  IoErr
  IsFileSystem
  IsInteractive
  LoadSeg
  Lock
  LockDosList
  LockRecord
  LockRecords
  MakeDosEntry
  MakeLink
  MatchEnd
  MatchFirst
  MatchNext
  MatchPattern
  MatchPatternNoCase
  MaxCli
  NameFromFH
  NameFromLock
  NewLoadSeg
  NextDosEntry
  Open
  OpenFromLock
  Output
  ParentDir
  ParentOfFH
  ParsePattern
  ParsePatternNoCase
  PathPart
  PrintFault
  PutStr
  Read
  ReadArgs
  ReadItem
  ReadLink
  Relabel
  RemAssignList
  RemDosEntry
  RemSegment
  Rename
  ReplyPkt
  RunCommand
  SameDevice
  SameLock
  Seek
  SelectInput
  SelectOutput
  SendPkt
  SetArgStr
  SetComment
  SetConsoleTask
  SetCurrentDirName
  SetFileDate
  SetFileSize
  SetFileSysTask
  SetIoErr
  SetMode
  SetOwner
  SetProgramDir
  SetProgramName
  SetPrompt
  SetProtection
  SetVBuf
  SetVar
  SplitName
  StartNotify
  StrToDate
  StrToLong
  SystemTagList
  UnGetC
  UnLoadSeg
  UnLock
  UnLockDosList
  UnLockRecord
  UnLockRecords
  VFPrintf
  VFWritef
  VPrintf
  WaitForChar
  WaitPkt
  Write
  WriteChars
Include
GuruMeditation
Docs » Autodocs » dos.library » LockDosList

NAME

	LockDosList -- Locks the specified Dos Lists for use (V36)

SYNOPSIS

	dlist = LockDosList(flags)
D0 D1
struct DosList *LockDosList(ULONG)

FUNCTION

	Locks the dos device list in preparation to walk the list.
If the list is 'busy' then this routine will not return until it is
available. This routine "nests": you can call it multiple times, and
then must unlock it the same number of times. The dlist
returned is NOT a valid entry: it is a special value. Note that
for 1.3 compatibility, it also does a Forbid() - this will probably
be removed at some future time. The 1.3 Forbid() locking of this
list had some race conditions. The pointer returned by this is NOT
an actual DosList pointer - you should use on of the other DosEntry
calls to get actual pointers to DosList structures (such as
NextDosEntry()), passing the value returned by LockDosList()
as the dlist value.
Note for handler writers: you should never call this function with
LDF_WRITE, since it can deadlock you (if someone has it read-locked
and they're trying to send you a packet). Use AttemptLockDosList()
instead, and effectively busy-wait with delays for the list to be
available. The other option is that you can spawn a process to
add the entry safely.
As an example, here's how you can search for all volumes of a specific
name and do something with them:
2.0 way:
dl = LockDosList(LDF_VOLUMES|LDF_READ);
while (dl = FindDosEntry(dl,name,LDF_VOLUMES))
{
Add to list of volumes to process or break out of
the while loop.
(You could try using it here, but I advise
against it for compatability reasons if you
are planning on continuing to examine the list.)
}
process list of volumes saved above, or current entry if
you're only interested in the first one of that name.
UnLockDosList(LDF_VOLUMES|LDF_READ);
\* must not use dl after this! *\
1.3/2.0 way:
if (version >= 36)
dl = LockDosList(LDF_VOLUMES|LDF_READ);
else {
Forbid();
/* tricky! note dol_Next is at offset 0! */
dl = &(...->di_DeviceList);
}
while (version >= 36 ?
dl = FindDosEntry(dl,name,LDF_VOLUMES) :
dl = yourfindentry(dl,name,DLT_VOLUME))
{
Add to list of volumes to process, or break out of
the while loop.
Do NOT lock foo1/foo2 here if you will continue
to examine the list - it breaks the forbid
and the list may change on you.
}
process list of volumes saved above, or current entry if
you're only interested in the first one of that name.
if (version >= 36)
UnLockDosList(LDF_VOLUMES|LDF_READ);
else
Permit();
\* must not use dl after this! *\
...
struct DosList *
yourfindentry (struct DosList *dl, STRPTRname, type)
{
\* tricky - depends on dol_Next being at offset 0,
and the initial ptr being a ptr to di_DeviceList! *\
while (dl = dl->dol_Next)
{
if (dl->dol_Type == type &&
stricmp(name,BADDR(dl->dol_Name)+1) == 0)
{
break;
}
}
return dl;
}

INPUTS

	flags - Flags stating which types of nodes you want to lock.

RESULT

	dlist - Pointer to the head of the list.  NOT a valid node!

SEE ALSO

AttemptLockDosList(), UnLockDosList(), exec.library/Forbid(), NextDosEntry()

Comments

Name:
E-mail: Use this if you want a message if you get a response, will not be shown.
Comment:
Select correct short for:

Kefrens

CSL
FLT
PDX
KEF

Comments:

$VER: d0.se 1.14 Copyright © 2011-2024 Tobias Geijersson support at d0 dot se