Build fix.
[AROS.git] / rom / dos / changemode.c
blob982d14c5cbd136b8b708094af86db0bfbd16b7f1
1 /*
2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Change the mode of a filehandle or lock.
6 Lang: English
7 */
8 #include <proto/exec.h>
9 #include <dos/dosextens.h>
10 #include <dos/filesystem.h>
11 #include "dos_intern.h"
13 /*****************************************************************************
15 NAME */
16 #include <proto/dos.h>
18 AROS_LH3(BOOL, ChangeMode,
20 /* SYNOPSIS */
21 AROS_LHA(ULONG, type, D1),
22 AROS_LHA(BPTR, object, D2),
23 AROS_LHA(ULONG, newmode, D3),
25 /* LOCATION */
26 struct DosLibrary *, DOSBase, 75, Dos)
28 /* FUNCTION
29 Try to change the access mode of a lock or filehandle.
31 INPUTS
32 type - CHANGE_FH or CHANGE_LOCK.
33 object - Filehandle or lock.
34 newmode - New mode, either SHARED_LOCK or EXCLUSIVE_LOCK.
36 RESULT
37 != 0 if all went well, otherwise 0. IoErr() gives additional
38 information in the latter case.
40 NOTES
42 EXAMPLE
44 BUGS
46 SEE ALSO
48 INTERNALS
49 Since filehandles and locks are identical under AROS the type
50 argument is ignored.
52 *****************************************************************************/
54 AROS_LIBFUNC_INIT
56 /* Get pointer to filehandle */
57 struct FileHandle *fh = (struct FileHandle *)BADDR(object);
59 /* Get pointer to I/O request. Use stackspace for now. */
60 struct IOFileSys iofs;
62 /* Prepare I/O request. */
63 InitIOFS(&iofs, FSA_FILE_MODE, DOSBase);
65 iofs.IOFS.io_Device = fh->fh_Device;
66 iofs.IOFS.io_Unit = fh->fh_Unit;
68 iofs.io_Union.io_FILE_MODE.io_FileMode =
69 (newmode == EXCLUSIVE_LOCK) ? FMF_LOCK : 0;
70 iofs.io_Union.io_FILE_MODE.io_Mask = FMF_LOCK;
72 /* Send the request. */
73 DosDoIO(&iofs.IOFS);
75 /* Set error code and return */
76 if (iofs.io_DosError != 0)
78 SetIoErr(iofs.io_DosError);
79 return DOSFALSE;
82 return DOSTRUE;
84 AROS_LIBFUNC_EXIT
85 } /* ChangeMode */