home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / Emulatory / AROS / dos / addbuffers.c < prev    next >
Encoding:
C/C++ Source or Header  |  1978-03-06  |  2.6 KB  |  103 lines

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