tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / rom / dos / namefromlock.c
blobe1a5014fb2ff53c5bf2d1aefcf2527ed31e03211
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Retrieve the full pathname from a lock.
6 Lang: english
7 */
8 #include <proto/exec.h>
9 #include "dos_intern.h"
11 #include <aros/debug.h>
13 /*****************************************************************************
15 NAME */
16 #include <proto/dos.h>
18 AROS_LH3(BOOL, NameFromLock,
20 /* SYNOPSIS */
21 AROS_LHA(BPTR, lock, D1),
22 AROS_LHA(STRPTR, buffer, D2),
23 AROS_LHA(LONG, length, D3),
25 /* LOCATION */
26 struct DosLibrary *, DOSBase, 67, Dos)
28 /* FUNCTION
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:".
33 INPUTS
34 lock - Lock to file or directory or 0.
35 buffer - Buffer to fill. Contains a NUL terminated string if
36 all went well.
37 length - Size of the buffer in bytes.
39 RESULT
40 !=0 if all went well, 0 in case of an error. IoErr() will
41 give additional information in that case.
43 *****************************************************************************/
46 AROS_LIBFUNC_INIT
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.
64 * Sonic
66 BOOL res;
67 BPTR lock2;
69 if (lock == BNULL) {
70 if (length > 5) {
71 CopyMem("SYS:", buffer, 5);
72 return DOSTRUE;
73 } else {
74 SetIoErr(ERROR_LINE_TOO_LONG);
75 return DOSFALSE;
80 lock2 = DupLock(lock);
81 res = namefrom_internal(DOSBase, lock2, buffer, length);
82 UnLock(lock2);
84 return res;
86 AROS_LIBFUNC_EXIT