Changeset c544c5d in mainline
- Timestamp:
- 2008-08-08T14:31:05Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 12fc042
- Parents:
- a61d1fc3
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libfs/libfs.c
ra61d1fc3 rc544c5d 37 37 #include "libfs.h" 38 38 #include "../../srv/vfs/vfs.h" 39 #include "../../srv/rd/rd.h" 39 40 #include <errno.h> 40 41 #include <async.h> … … 331 332 } 332 333 333 #define RD_BASE 1024 // FIXME334 #define RD_READ_BLOCK (RD_BASE + 1)335 336 334 /** Read data from a block device. 337 335 * -
uspace/srv/rd/rd.c
ra61d1fc3 rc544c5d 82 82 int retval; 83 83 void *fs_va = NULL; 84 ipcarg_t offset; 84 off_t offset; 85 size_t block_size; 86 size_t maxblock_size; 85 87 86 88 /* 87 * We allocate VA for communication per connection. 88 * This allows us to potentionally have more clients and work 89 * concurrently. 89 * Answer the first IPC_M_CONNECT_ME_TO call. 90 90 */ 91 fs_va = as_get_mappable_page(ALIGN_UP(BLOCK_SIZE, PAGE_SIZE)); 92 if (!fs_va) { 93 /* 94 * Hang up the phone if we cannot proceed any further. 95 * This is the answer to the call that opened the connection. 96 */ 97 ipc_answer_0(iid, EHANGUP); 98 return; 99 } else { 100 /* 101 * Answer the first IPC_M_CONNECT_ME_TO call. 102 * Return supported block size as ARG1. 103 */ 104 ipc_answer_1(iid, EOK, BLOCK_SIZE); 105 } 91 ipc_answer_0(iid, EOK); 106 92 107 93 /* 108 94 * Now we wait for the client to send us its communication as_area. 109 95 */ 110 size_t size;111 96 int flags; 112 if (ipc_share_out_receive(&callid, &size, &flags)) { 113 if (size >= BLOCK_SIZE) { 114 /* 115 * The client sends an as_area that can absorb the whole 116 * block. 117 */ 97 if (ipc_share_out_receive(&callid, &maxblock_size, &flags)) { 98 fs_va = as_get_mappable_page(maxblock_size); 99 if (fs_va) { 118 100 (void) ipc_share_out_finalize(callid, fs_va); 119 101 } else { 120 /*121 * The client offered as_area too small.122 * Close the connection.123 */124 102 ipc_answer_0(callid, EHANGUP); 125 103 return; … … 147 125 case RD_READ_BLOCK: 148 126 offset = IPC_GET_ARG1(call); 149 if (offset * BLOCK_SIZE > rd_size - BLOCK_SIZE) { 127 block_size = IPC_GET_ARG2(call); 128 if (block_size > maxblock_size) { 129 /* 130 * Maximum block size exceeded. 131 */ 132 retval = ELIMIT; 133 break; 134 } 135 if (offset * block_size > rd_size - block_size) { 150 136 /* 151 137 * Reading past the end of the device. … … 155 141 } 156 142 futex_down(&rd_futex); 157 memcpy(fs_va, rd_addr + offset * BLOCK_SIZE, BLOCK_SIZE);143 memcpy(fs_va, rd_addr + offset * block_size, block_size); 158 144 futex_up(&rd_futex); 159 145 retval = EOK; … … 161 147 case RD_WRITE_BLOCK: 162 148 offset = IPC_GET_ARG1(call); 163 if (offset * BLOCK_SIZE > rd_size - BLOCK_SIZE) { 149 block_size = IPC_GET_ARG2(call); 150 if (block_size > maxblock_size) { 151 /* 152 * Maximum block size exceeded. 153 */ 154 retval = ELIMIT; 155 break; 156 } 157 if (offset * block_size > rd_size - block_size) { 164 158 /* 165 159 * Writing past the end of the device. … … 169 163 } 170 164 futex_up(&rd_futex); 171 memcpy(rd_addr + offset * BLOCK_SIZE, fs_va, BLOCK_SIZE);165 memcpy(rd_addr + offset * block_size, fs_va, block_size); 172 166 futex_down(&rd_futex); 173 167 retval = EOK; -
uspace/srv/rd/rd.h
ra61d1fc3 rc544c5d 44 44 #define RD_RD_H_ 45 45 46 #define BLOCK_SIZE 1024 /**< Working block size */47 48 46 #define RD_BASE 1024 49 47 #define RD_READ_BLOCK (RD_BASE + 1) /**< Method for reading block. */
Note:
See TracChangeset
for help on using the changeset viewer.