Rev 2394 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2394 | Rev 2435 | ||
---|---|---|---|
- | 1 | /* |
|
- | 2 | * Copyright (c) 2007 Konopa-Jelen-Majer |
|
- | 3 | * All rights reserved. |
|
- | 4 | * |
|
1 | /* Sending extended well formed messages to FS over |
5 | * Redistribution and use in source and binary forms, with or without |
- | 6 | * modification, are permitted provided that the following conditions |
|
- | 7 | * are met: |
|
- | 8 | * |
|
- | 9 | * - Redistributions of source code must retain the above copyright |
|
2 | * standard HelenOS message agrs and over shared buffer. |
10 | * notice, this list of conditions and the following disclaimer. |
- | 11 | * - Redistributions in binary form must reproduce the above copyright |
|
- | 12 | * notice, this list of conditions and the following disclaimer in the |
|
- | 13 | * documentation and/or other materials provided with the distribution. |
|
- | 14 | * - The name of the author may not be used to endorse or promote products |
|
- | 15 | * derived from this software without specific prior written permission. |
|
- | 16 | * |
|
- | 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
|
- | 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
|
- | 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
- | 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
- | 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
|
- | 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
- | 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
- | 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
- | 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
|
- | 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
3 | */ |
27 | */ |
4 | 28 | ||
- | 29 | /** @addtogroup FileSystemTask |
|
- | 30 | * @{ |
|
- | 31 | */ |
|
- | 32 | ||
- | 33 | /** |
|
5 | /* Methods: |
34 | * @file message.c |
6 | * send_request: forms and sends extended message to FS |
35 | * @brief Sending extended well formed messages to FS over |
7 | * unpack_message: unpacks message to given message_params_t* structure |
36 | * standard HelenOS message agrs and over shared buffer. |
8 | */ |
37 | */ |
9 | 38 | ||
10 | - | ||
11 | #include <async.h> |
39 | #include <async.h> |
12 | #include <task.h> |
40 | #include <task.h> |
13 | #include "../fs/fs.h" |
41 | #include "../fs/fs.h" |
14 | #include "message.h" |
42 | #include "message.h" |
15 | 43 | ||
16 | int send_request(int phoneid, ipcarg_t method, message_params_t *params, void *shared_buffer); |
44 | int send_request(int phoneid, ipcarg_t method, message_params_t *params, void *shared_buffer); |
17 | void unpack_message(message_params_t *message, ipc_call_t m_input, void *shared_buffer); |
45 | void unpack_message(message_params_t *message, ipc_call_t m_input, void *shared_buffer); |
18 | 46 | ||
- | 47 | /** |
|
- | 48 | * Forms and sends extended message to FS |
|
19 | /* This method should be used by all callers of FS. Candidate at library function. */ |
49 | * This method should be used by all callers of FS. Candidate at library function. |
- | 50 | */ |
|
20 | int send_request(int phoneid, ipcarg_t method, message_params_t *params, void *shared_buffer) |
51 | int send_request(int phoneid, ipcarg_t method, message_params_t *params, void *shared_buffer) |
21 | { |
52 | { |
22 | 53 | ||
23 | int retval, shift; |
54 | int retval, shift; |
24 | size_t size; |
55 | size_t size; |
25 | 56 | ||
26 | size = sizeof(message_params_t); |
57 | size = sizeof(message_params_t); |
27 | memset((void *)shared_buffer, 0, size); |
58 | memset((void *)shared_buffer, 0, size); |
28 | 59 | ||
29 | /* Setting 'buffered' parameters. */ |
60 | /* Setting 'buffered' parameters. */ |
30 | memcpy((void* )shared_buffer, (void *)(¶ms->nbytes), sizeof(unsigned int)); |
61 | memcpy((void* )shared_buffer, (void *)(¶ms->nbytes), sizeof(unsigned int)); |
31 | shift = sizeof(unsigned int); |
62 | shift = sizeof(unsigned int); |
32 | memcpy((void *)(shared_buffer + shift), (void *)(¶ms->offset), sizeof(offset_t)); |
63 | memcpy((void *)(shared_buffer + shift), (void *)(¶ms->offset), sizeof(offset_t)); |
33 | shift += sizeof(offset_t); |
64 | shift += sizeof(offset_t); |
34 | memcpy((void *)(shared_buffer + shift), (void *)(¶ms->fname), DIRSIZEX); |
65 | memcpy((void *)(shared_buffer + shift), (void *)(¶ms->fname), DIRSIZEX); |
35 | params->fname[DIRSIZEX-1] = '\0'; |
66 | params->fname[DIRSIZEX-1] = '\0'; |
36 | shift += DIRSIZEX * sizeof(char); |
67 | shift += DIRSIZEX * sizeof(char); |
37 | memcpy((void *)(shared_buffer + shift), (void *)(¶ms->entry_number), sizeof(int)); |
68 | memcpy((void *)(shared_buffer + shift), (void *)(¶ms->entry_number), sizeof(int)); |
38 | 69 | ||
39 | /* 'Most used' parameters will be pass in standart message parameters. */ |
70 | /* 'Most used' parameters will be pass in standart message parameters. */ |
40 | retval = async_req_3(phoneid, method, task_get_id(), params->fd, params->whence, NULL, NULL, NULL); |
71 | retval = async_req_3(phoneid, method, task_get_id(), params->fd, params->whence, NULL, NULL, NULL); |
41 | 72 | ||
42 | return retval; |
73 | return retval; |
43 | } |
74 | } |
44 | 75 | ||
- | 76 | /** |
|
- | 77 | * Unpacks message to given message_params_t* structure |
|
45 | /* Will be used by FS to unpacking incoming extended message. */ |
78 | * Will be used by FS to unpacking incoming extended message. |
- | 79 | */ |
|
46 | void unpack_message(message_params_t *message, ipc_call_t m_input, void *shared_buffer) |
80 | void unpack_message(message_params_t *message, ipc_call_t m_input, void *shared_buffer) |
47 | { |
81 | { |
48 | 82 | ||
49 | int shift; |
83 | int shift; |
50 | 84 | ||
51 | /* Core message parameters. */ |
85 | /* Core message parameters. */ |
52 | message->id_task = IPC_GET_ARG1(m_input); |
86 | message->id_task = IPC_GET_ARG1(m_input); |
53 | message->fd = IPC_GET_ARG2(m_input); |
87 | message->fd = IPC_GET_ARG2(m_input); |
54 | message->whence = IPC_GET_ARG3(m_input); |
88 | message->whence = IPC_GET_ARG3(m_input); |
55 | 89 | ||
56 | /* Buffered parameters - extended. */ |
90 | /* Buffered parameters - extended. */ |
57 | memcpy((void *)&message->nbytes, (void *)(shared_buffer), sizeof(unsigned int)); |
91 | memcpy((void *)&message->nbytes, (void *)(shared_buffer), sizeof(unsigned int)); |
58 | shift = sizeof(unsigned int); |
92 | shift = sizeof(unsigned int); |
59 | memcpy((void *)(&message->offset), (void *)(shared_buffer + shift), sizeof(offset_t)); |
93 | memcpy((void *)(&message->offset), (void *)(shared_buffer + shift), sizeof(offset_t)); |
60 | shift += sizeof(offset_t); |
94 | shift += sizeof(offset_t); |
61 | memcpy((void *)(&message->fname), (void *)(shared_buffer + shift), DIRSIZEX); |
95 | memcpy((void *)(&message->fname), (void *)(shared_buffer + shift), DIRSIZEX); |
62 | shift += DIRSIZEX * sizeof(char); |
96 | shift += DIRSIZEX * sizeof(char); |
63 | memcpy((void *)(&message->entry_number), (void *)(shared_buffer + shift), sizeof(int)); |
97 | memcpy((void *)(&message->entry_number), (void *)(shared_buffer + shift), sizeof(int)); |
64 | 98 | ||
65 | } |
99 | } |
- | 100 | ||
- | 101 | /** |
|
- | 102 | *} |
|
- | 103 | */ |
|
- | 104 | ||
66 | 105 |