Rev 2658 | Rev 2664 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2658 | Rev 2663 | ||
---|---|---|---|
Line 280... | Line 280... | ||
280 | void tmpfs_read(ipc_callid_t rid, ipc_call_t *request) |
280 | void tmpfs_read(ipc_callid_t rid, ipc_call_t *request) |
281 | { |
281 | { |
282 | int dev_handle = IPC_GET_ARG1(*request); |
282 | int dev_handle = IPC_GET_ARG1(*request); |
283 | unsigned long index = IPC_GET_ARG2(*request); |
283 | unsigned long index = IPC_GET_ARG2(*request); |
284 | off_t pos = IPC_GET_ARG3(*request); |
284 | off_t pos = IPC_GET_ARG3(*request); |
285 | size_t size = IPC_GET_ARG4(*request); |
- | |
286 | 285 | ||
287 | /* |
286 | /* |
288 | * Lookup the respective dentry. |
287 | * Lookup the respective dentry. |
289 | */ |
288 | */ |
290 | link_t *hlp; |
289 | link_t *hlp; |
Line 295... | Line 294... | ||
295 | } |
294 | } |
296 | tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t, |
295 | tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t, |
297 | dh_link); |
296 | dh_link); |
298 | 297 | ||
299 | /* |
298 | /* |
300 | * Receive the communication area. |
299 | * Receive the read request. |
301 | */ |
300 | */ |
302 | ipc_callid_t callid; |
301 | ipc_callid_t callid; |
303 | ipc_call_t call; |
302 | size_t size; |
304 | callid = async_get_call(&call); |
- | |
305 | if (IPC_GET_METHOD(call) != IPC_M_AS_AREA_SEND) { |
303 | if (!ipc_data_read_receive(&callid, size)) { |
306 | ipc_answer_0(callid, EINVAL); |
304 | ipc_answer_0(callid, EINVAL); |
307 | ipc_answer_0(rid, EINVAL); |
305 | ipc_answer_0(rid, EINVAL); |
308 | return; |
306 | return; |
309 | } |
307 | } |
310 | 308 | ||
311 | int flags = IPC_GET_ARG3(call); |
- | |
312 | if (!(flags & AS_AREA_WRITE)) { |
- | |
313 | ipc_answer_0(callid, EINVAL); |
- | |
314 | ipc_answer_0(rid, EINVAL); |
- | |
315 | return; |
- | |
316 | } |
- | |
317 | size_t sz = IPC_GET_ARG2(call); |
- | |
318 | uint8_t *buf = as_get_mappable_page(sz); |
- | |
319 | if (!buf) { |
- | |
320 | ipc_answer_0(callid, ENOMEM); |
- | |
321 | ipc_answer_0(rid, ENOMEM); |
- | |
322 | return; |
- | |
323 | } |
- | |
324 | ipc_answer_1(callid, EOK, buf); /* commit to share the area */ |
- | |
325 | - | ||
326 | size_t bytes = max(0, min(dentry->size - pos, size)); |
309 | size_t bytes = max(0, min(dentry->size - pos, size)); |
327 | memcpy(buf, dentry->data + pos, bytes); |
310 | (void) ipc_data_read_deliver(callid, dentry->data + pos, bytes); |
328 | - | ||
329 | (void) as_area_destroy(buf); |
- | |
330 | - | ||
331 | ipc_answer_1(rid, EOK, bytes); |
- | |
332 | } |
311 | } |
333 | 312 | ||
334 | /** |
313 | /** |
335 | * @} |
314 | * @} |
336 | */ |
315 | */ |