r4722@vps: verhaegs | 2007-05-06 13:11:19 -0400
[cake.git] / rom / dos / samelock.c
blobda8486e31b6504903a119022743b34dbf9bfed5f
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
8 #include "dos_intern.h"
10 /*****************************************************************************
12 NAME */
13 #include <proto/dos.h>
15 AROS_LH2(LONG, SameLock,
17 /* SYNOPSIS */
18 AROS_LHA(BPTR, lock1, D1),
19 AROS_LHA(BPTR, lock2, D2),
21 /* LOCATION */
22 struct DosLibrary *, DOSBase, 70, Dos)
24 /* FUNCTION
26 INPUTS
28 RESULT
30 NOTES
32 EXAMPLE
34 BUGS
36 SEE ALSO
38 INTERNALS
40 *****************************************************************************/
42 AROS_LIBFUNC_INIT
44 struct IOFileSys iofs;
45 struct FileHandle *fh1;
46 struct FileHandle *fh2;
48 if(!SameDevice(lock1, lock2))
49 return LOCK_DIFFERENT;
51 fh1 = (struct FileHandle *)BADDR(lock1);
52 fh2 = (struct FileHandle *)BADDR(lock2);
54 /* Check if it is the same lock */
56 /* Prepare I/O request. */
57 InitIOFS(&iofs, FSA_SAME_LOCK, DOSBase);
59 iofs.IOFS.io_Device = fh1->fh_Device;
60 iofs.IOFS.io_Unit = fh1->fh_Unit;
61 iofs.io_Union.io_SAME_LOCK.io_Lock[0] = fh1->fh_Unit;
62 iofs.io_Union.io_SAME_LOCK.io_Lock[1] = fh2->fh_Unit;
63 iofs.io_Union.io_SAME_LOCK.io_Same = LOCK_DIFFERENT;
65 /* Send the request. */
66 DosDoIO(&iofs.IOFS);
68 /* Set error code and return */
69 SetIoErr(iofs.io_DosError);
71 if(iofs.io_DosError != 0)
72 return LOCK_DIFFERENT;
73 else
75 if(iofs.io_Union.io_SAME_LOCK.io_Same == LOCK_SAME)
76 return LOCK_SAME;
77 else
78 return LOCK_SAME_VOLUME;
81 return 0;
83 AROS_LIBFUNC_EXIT
84 } /* SameLock */