dos.library: Fix C:AddDataTypes on OS 3.9
[AROS.git] / rom / dos / addbuffers.c
blob44e6b38cf61df1d7489012511fddfba308c43e0e
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Add or remove cache memory from a filesystem.
6 Lang: English
7 */
8 #include <proto/exec.h>
9 #include <dos/dosextens.h>
10 #include "dos_intern.h"
12 /*****************************************************************************
14 NAME */
15 #include <proto/dos.h>
17 AROS_LH2(LONG, AddBuffers,
19 /* SYNOPSIS */
20 AROS_LHA(CONST_STRPTR, devicename, D1),
21 AROS_LHA(LONG, numbuffers, D2),
23 /* LOCATION */
24 struct DosLibrary *, DOSBase, 122, Dos)
26 /* FUNCTION
27 Add or remove cache memory to/from a filesystem. The amount of memory
28 per cache buffer and the limit depends on the filesystem.
30 INPUTS
31 devicename - DOS device name (with trailing ':' and NUL terminated).
32 numbuffers - Number of buffers to add. May be negative for decreasing.
34 RESULT
35 DOSTRUE on success (IoErr() gives the actual number of buffers).
36 DOSFALSE on error (IoErr() gives the error code).
37 Some old filesystems return the actual buffer size. See the example
38 for a workaround for that case.
40 NOTES
42 EXAMPLE
43 LONG res1, res2;
44 res1 = AddBuffers("df0:", 10);
45 res2 = IoErr();
46 if (res1 != DOSFALSE && res1 != DOSTRUE)
48 res2 = res1;
49 res1 = DOSTRUE;
52 BUGS
54 SEE ALSO
55 IoErr()
57 INTERNALS
59 The error value in case of a filesystem error will be reported in
60 the io_MORE_CACHE.io_NumBuffers field.
62 *****************************************************************************/
65 AROS_LIBFUNC_INIT
67 struct DevProc *dvp;
68 LONG ret;
70 /* get the device */
71 if ((dvp = GetDeviceProc(devicename, NULL)) == NULL)
72 return DOSFALSE;
74 /* we're only interested in real devices */
75 if (dvp->dvp_DevNode == NULL ||
76 dvp->dvp_DevNode->dol_Type != DLT_DEVICE) {
77 FreeDeviceProc(dvp);
78 SetIoErr(ERROR_DEVICE_NOT_MOUNTED);
79 return DOSFALSE;
82 ret = dopacket1(DOSBase, NULL, dvp->dvp_Port, ACTION_MORE_CACHE, numbuffers);
84 FreeDeviceProc(dvp);
86 return ret;
88 AROS_LIBFUNC_EXIT
89 } /* AddBuffers */