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

  1. #include <exec/memory.h>
  2. #include <clib/exec_protos.h>
  3. #include <dos/dosextens.h>
  4. #include <dos/filesystem.h>
  5. #include <clib/dos_protos.h>
  6. #include <utility/tagitem.h>
  7.  
  8. static LONG mount(struct IOFileSys *iofs, STRPTR filesys, STRPTR device)
  9. {
  10.     struct DosList *entry;
  11.     LONG error;
  12.     if(!OpenDevice(filesys,0,&iofs->IOFS,0))
  13.     {
  14.         entry=MakeDosEntry(device,DLT_DEVICE);
  15.         if(entry!=NULL)
  16.         {
  17.             if(AddDosEntry(entry))
  18.             {
  19.                 entry->dol_Unit  =iofs->IOFS.io_Unit;
  20.                 entry->dol_Device=iofs->IOFS.io_Device;
  21.                 /*
  22.                     Neither close the device nor free the DosEntry.
  23.                     Both will stay in the dos list as long as the
  24.                     device is mounted.
  25.                 */
  26.         return 0;
  27.         }else
  28.             error=IoErr();
  29.         FreeDosEntry(entry);
  30.     }else
  31.         error=ERROR_NO_FREE_STORE;
  32.     }else
  33.         error=ERROR_OBJECT_NOT_FOUND;
  34.     return error;
  35. }
  36.  
  37. int main (int argc, char ** argv)
  38. {
  39.     STRPTR args[2]={ NULL, NULL };
  40.     struct RDArgs *rda;
  41.     struct IOFileSys *iofs;
  42.     struct Process *me=(struct Process *)FindTask(NULL);
  43.     LONG error=0;
  44.  
  45.     rda=ReadArgs("FILESYS/A,DEVICE/A",(ULONG *)args,NULL);
  46.     if(rda!=NULL)
  47.     {
  48.     iofs=(struct IOFileSys *)CreateIORequest(&me->pr_MsgPort,sizeof(struct IOFileSys));
  49.     if(iofs!=NULL)
  50.     {
  51.             SetIoErr(mount(iofs,args[0],args[1]));
  52.             if(IoErr())
  53.             error = RETURN_FAIL;
  54.         DeleteIORequest(&iofs->IOFS);
  55.     }
  56.     FreeArgs(rda);
  57.     }else
  58.     error=RETURN_FAIL;
  59.     if(error)
  60.     PrintFault(IoErr(),"Mount");
  61.     return error;
  62. }
  63.