2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Retrieve the full pathname from a lock.
8 #include <proto/exec.h>
9 #include "dos_intern.h"
11 #include <aros/debug.h>
13 /*****************************************************************************
16 #include <proto/dos.h>
18 AROS_LH3(BOOL
, NameFromLock
,
21 AROS_LHA(BPTR
, lock
, D1
),
22 AROS_LHA(STRPTR
, buffer
, D2
),
23 AROS_LHA(LONG
, length
, D3
),
26 struct DosLibrary
*, DOSBase
, 67, Dos
)
29 Get the full path name associated with a lock to a file or
30 directory into a user supplied buffer.
31 If the lock is zero the buffer will be filled with "SYS:".
34 lock - Lock to file or directory or 0.
35 buffer - Buffer to fill. Contains a NUL terminated string if
37 length - Size of the buffer in bytes.
40 !=0 if all went well, 0 in case of an error. IoErr() will
41 give additional information in that case.
43 *****************************************************************************/
49 * We could simply call namefrom_internal() with our lock. However this
50 * causes prolems with Mount on SFS. Mount with a pattern (e. g. Mount DEVS:DOSDrivers/#?)
51 * enters endless loop examining the same first file all times.
52 * The problem occurs because Mount calls NameFromLock() on AnchorPath's ap_Current->an_Lock().
53 * This results in calling Examine() on this lock.
54 * SFS, in its turn, uses own extended form of a lock, and stores some information about current
55 * search position in it. Calling Examine() on this lock, even with another FIB, causes search
56 * position to be reset to the beginning of the directory.
57 * This is unlikely a bug in Mount, because this code perfectly works on MorphOS without any
58 * modifications. This is either:
59 * a) A bug in SFS itself (unlikely, should have been noticed and fixed)
60 * b) Wrong implementation of our NameFromLock().
62 * Duplicating a lock here is a brute-force workaround for this problem. When i have more time, i'll
63 * pick up my old archive with MorphOS dos.library code, and check theirs implementation.
71 CopyMem("SYS:", buffer
, 5);
74 SetIoErr(ERROR_LINE_TOO_LONG
);
80 lock2
= DupLock(lock
);
81 res
= namefrom_internal(DOSBase
, lock2
, buffer
, length
);