Subversion Repositories HelenOS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Cat
  3.  */
  4.  
  5. #include <err.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <unistd.h>
  10. #include <async.h>
  11. #include <ipc/services.h>
  12. #include "../fs/fs.h"
  13.  
  14.  
  15. int main(int argc, char *argv[])
  16. {
  17.     //Why does my console have no number?  
  18.     printf("This is your cat! \n");
  19.  
  20.     char * fname = "version";
  21.     char * buff = "012345678901234567890123456789012";
  22.     unsigned int file_handle;
  23.  
  24.     int fs_phone;  
  25.  
  26.     fs_phone = ipc_connect_me_to(PHONE_NS, SERVICE_FS, 0);
  27.     while (fs_phone < 0) {
  28.         usleep(10000);
  29.         fs_phone = ipc_connect_me_to(PHONE_NS, SERVICE_FS, 0);
  30.     }
  31.  
  32.     file_handle = async_req_2(fs_phone, FS_OPEN, (unsigned int) fname, 0, NULL, NULL);
  33.  
  34.     printf("I got file handle %d \n",file_handle);
  35.  
  36.     char * retval = (char * ) async_req_3(fs_phone, FS_READ, file_handle, (unsigned int) buff, 32, NULL, NULL, NULL);
  37.  
  38.     printf("Data read: %d\n", retval);
  39.  
  40.     return 0;
  41. }
  42.  
  43.