Rev 2131 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2131 | Rev 2248 | ||
---|---|---|---|
Line 33... | Line 33... | ||
33 | /** |
33 | /** |
34 | * @file fs.c |
34 | * @file fs.c |
35 | * @brief File system driver for HelenOS. |
35 | * @brief File system driver for HelenOS. |
36 | */ |
36 | */ |
37 | 37 | ||
- | 38 | #include <ipc/ipc.h> |
|
- | 39 | #include <ipc/services.h> |
|
- | 40 | #include <ipc/ns.h> |
|
- | 41 | #include <sysinfo.h> |
|
- | 42 | #include <stdio.h> |
|
- | 43 | #include <stdlib.h> |
|
- | 44 | #include <as.h> |
|
- | 45 | #include <ddi.h> |
|
- | 46 | #include <align.h> |
|
- | 47 | #include <bool.h> |
|
- | 48 | #include <errno.h> |
|
- | 49 | #include <async.h> |
|
- | 50 | #include "fs.h" |
|
- | 51 | ||
- | 52 | ||
- | 53 | static void fs_connection(ipc_callid_t iid, ipc_call_t *icall) |
|
- | 54 | { |
|
- | 55 | ipc_callid_t callid; |
|
- | 56 | ipc_call_t call; |
|
- | 57 | int retval; |
|
- | 58 | ||
- | 59 | ipc_answer_fast(iid, 0, 0, 0); |
|
- | 60 | ||
- | 61 | while (1) { |
|
- | 62 | callid = async_get_call(&call); |
|
- | 63 | switch (IPC_GET_METHOD(call)) { |
|
- | 64 | case IPC_M_PHONE_HUNGUP: |
|
- | 65 | ipc_answer_fast(callid, 0,0,0); |
|
- | 66 | return; |
|
- | 67 | case FS_OPEN: |
|
- | 68 | //Why doesn't printf do anything in this task? |
|
- | 69 | printf("FS_OPEN called"); |
|
- | 70 | char * f_name = (char *) IPC_GET_ARG1(call); |
|
- | 71 | printf("I should open file: %s \n",f_name); |
|
- | 72 | retval = 73; |
|
- | 73 | break; |
|
- | 74 | case FS_READ: |
|
- | 75 | printf("FS_READ called"); |
|
- | 76 | unsigned int file_handle = IPC_GET_ARG1(call); |
|
- | 77 | void * buffer = (void *) IPC_GET_ARG2(call); |
|
- | 78 | unsigned int count = IPC_GET_ARG3(call); |
|
- | 79 | //I still don't know how to copy memory to another task :( |
|
- | 80 | //Or can i only map memory? |
|
- | 81 | retval = 0; |
|
- | 82 | break; |
|
- | 83 | default: |
|
- | 84 | retval = EINVAL; |
|
- | 85 | } |
|
- | 86 | ipc_answer_fast(callid, retval, 0, 0); |
|
- | 87 | } |
|
- | 88 | } |
|
- | 89 | ||
- | 90 | ||
- | 91 | static bool fs_init(void) |
|
- | 92 | { |
|
- | 93 | ||
- | 94 | return true; |
|
- | 95 | } |
|
38 | 96 | ||
39 | int main(int argc, char **argv) |
97 | int main(int argc, char **argv) |
40 | { |
98 | { |
- | 99 | if (fs_init()) { |
|
- | 100 | ipcarg_t phonead; |
|
- | 101 | ||
- | 102 | async_set_client_connection(fs_connection); |
|
- | 103 | ||
- | 104 | /* Register service at nameserver */ |
|
- | 105 | if (ipc_connect_to_me(PHONE_NS, SERVICE_FS, 0, &phonead) != 0) |
|
- | 106 | return -1; |
|
- | 107 | ||
- | 108 | async_manager(); |
|
- | 109 | ||
- | 110 | /* Never reached */ |
|
41 | return 0; |
111 | return 0; |
- | 112 | } |
|
- | 113 | ||
- | 114 | return -1; |
|
42 | } |
115 | } |
43 | 116 | ||
44 | /** |
117 | /** |
45 | * @} |
118 | * @} |
46 | */ |
119 | */ |