home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / dos / addbuffers.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-27  |  2.7 KB  |  111 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: addbuffers.c,v 1.4 1997/01/27 00:36:13 ldp Exp $
  4.     $Log: addbuffers.c,v $
  5.     Revision 1.4  1997/01/27 00:36:13  ldp
  6.     Polish
  7.  
  8.     Revision 1.3  1996/12/09 13:53:20  aros
  9.     Added empty templates for all missing functions
  10.  
  11.     Moved #include's into first column
  12.  
  13.     Revision 1.2  1996/10/24 15:50:23  aros
  14.     Use the official AROS macros over the __AROS versions.
  15.  
  16.     Revision 1.1  1996/09/11 12:54:44  digulla
  17.     A couple of new DOS functions from M. Fleischer
  18.  
  19.     Desc:
  20.     Lang: english
  21. */
  22. #include <proto/exec.h>
  23. #include <dos/dosextens.h>
  24. #include <dos/filesystem.h>
  25. #include "dos_intern.h"
  26.  
  27. /*****************************************************************************
  28.  
  29.     NAME */
  30. #include <proto/dos.h>
  31.  
  32.     AROS_LH2(BOOL, AddBuffers,
  33.  
  34. /*  SYNOPSIS */
  35.     AROS_LHA(STRPTR, devicename, D1),
  36.     AROS_LHA(LONG,   numbuffers, D2),
  37.  
  38. /*  LOCATION */
  39.     struct DosLibrary *, DOSBase, 122, Dos)
  40.  
  41. /*  FUNCTION
  42.     Add or remove cache memory from a filesystem.
  43.  
  44.     INPUTS
  45.     devicename - NUL terminated dos device name.
  46.     numbuffers - Number of buffers to add. May be negative.
  47.  
  48.     RESULT
  49.     !=0 on success (IoErr() gives the actual number of buffers),
  50.     0 else (IoErr() gives the error code).
  51.  
  52.     NOTES
  53.  
  54.     EXAMPLE
  55.  
  56.     BUGS
  57.  
  58.     SEE ALSO
  59.  
  60.     INTERNALS
  61.  
  62.     HISTORY
  63.     29-10-95    digulla automatically created from
  64.                 dos_lib.fd and clib/dos_protos.h
  65.  
  66. *****************************************************************************/
  67. {
  68.     AROS_LIBFUNC_INIT
  69.     AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
  70.     
  71.     /* Get pointer to process structure */
  72.     struct Process *me=(struct Process *)FindTask(NULL);
  73.     struct DosList *dl;
  74.     BOOL success=0;
  75.  
  76.     dl=LockDosList(LDF_DEVICES|LDF_READ);
  77.     dl=FindDosEntry(dl,devicename,LDF_DEVICES);
  78.     if(dl!=NULL)
  79.     {
  80.  
  81.         /* Get pointer to I/O request. Use stackspace for now. */
  82.         struct IOFileSys io,*iofs=&io;
  83.  
  84.         /* Prepare I/O request. */
  85.         iofs->IOFS.io_Message.mn_Node.ln_Type=NT_REPLYMSG;
  86.         iofs->IOFS.io_Message.mn_ReplyPort   =&me->pr_MsgPort;
  87.         iofs->IOFS.io_Message.mn_Length      =sizeof(struct IOFileSys);
  88.         iofs->IOFS.io_Device =dl->dol_Device;
  89.         iofs->IOFS.io_Unit   =dl->dol_Unit;
  90.         iofs->IOFS.io_Command=FSA_MORE_CACHE;
  91.         iofs->IOFS.io_Flags  =0;
  92.         iofs->io_Args[0]=numbuffers;
  93.  
  94.         /* Send the request. */
  95.         DoIO(&iofs->IOFS);
  96.         
  97.         /* Set error code */
  98.         if(!iofs->io_DosError)
  99.         {
  100.             me->pr_Result2=iofs->io_Args[0];
  101.             success=1; 
  102.     }else
  103.         me->pr_Result2=iofs->io_DosError;
  104.     }else
  105.         me->pr_Result2=ERROR_DEVICE_NOT_MOUNTED;
  106.     /* All Done. */
  107.     UnLockDosList(LDF_DEVICES|LDF_READ);
  108.     return success;
  109.     AROS_LIBFUNC_EXIT
  110. } /* AddBuffers */
  111.