Changeset d2c1fd5 in mainline
- Timestamp:
- 2008-08-07T19:01:24Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 61bc901
- Parents:
- 9f429c0
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libfs/libfs.c
r9f429c0 rd2c1fd5 331 331 } 332 332 333 #define RD_BASE 1024 // FIXME 334 #define RD_READ_BLOCK (RD_BASE + 1) 335 336 bool libfs_blockread(int phone, void *buffer, size_t *bufpos, size_t *buflen, 337 size_t *pos, void *dst, size_t size, size_t block_size) 338 { 339 size_t offset = 0; 340 size_t left = size; 341 342 while (left > 0) { 343 size_t rd; 344 345 if (*bufpos + left < *buflen) 346 rd = left; 347 else 348 rd = *buflen - *bufpos; 349 350 if (rd > 0) { 351 memcpy(dst + offset, buffer + *bufpos, rd); 352 offset += rd; 353 *bufpos += rd; 354 *pos += rd; 355 left -= rd; 356 } 357 358 if (*bufpos == *buflen) { 359 ipcarg_t retval; 360 int rc = async_req_2_1(phone, RD_READ_BLOCK, 361 *pos / block_size, block_size, &retval); 362 if ((rc != EOK) || (retval != EOK)) 363 return false; 364 365 *bufpos = 0; 366 *buflen = block_size; 367 } 368 } 369 370 return true; 371 } 372 333 373 /** @} 334 374 */ -
uspace/lib/libfs/libfs.h
r9f429c0 rd2c1fd5 70 70 extern void libfs_lookup(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *); 71 71 72 extern bool libfs_blockread(int, void *, size_t *, size_t *, size_t *, void *, 73 size_t, size_t); 74 72 75 #endif 73 76 -
uspace/srv/fs/tmpfs/tmpfs_dump.c
r9f429c0 rd2c1fd5 52 52 #include <byteorder.h> 53 53 54 #define BLOCK_SIZE 1024 // FIXME 55 #define RD_BASE 1024 // FIXME 56 #define RD_READ_BLOCK (RD_BASE + 1) 54 #define TMPFS_BLOCK_SIZE 1024 57 55 58 56 struct rdentry { … … 60 58 uint32_t len; 61 59 } __attribute__((packed)); 62 63 static bool64 tmpfs_blockread(int phone, void *buffer, size_t *bufpos, size_t *buflen,65 size_t *pos, void *dst, size_t size)66 {67 size_t offset = 0;68 size_t left = size;69 70 while (left > 0) {71 size_t rd;72 73 if (*bufpos + left < *buflen)74 rd = left;75 else76 rd = *buflen - *bufpos;77 78 if (rd > 0) {79 memcpy(dst + offset, buffer + *bufpos, rd);80 offset += rd;81 *bufpos += rd;82 *pos += rd;83 left -= rd;84 }85 86 if (*bufpos == *buflen) {87 ipcarg_t retval;88 int rc = async_req_2_1(phone, RD_READ_BLOCK,89 *pos / BLOCK_SIZE, BLOCK_SIZE, &retval);90 if ((rc != EOK) || (retval != EOK))91 return false;92 93 *bufpos = 0;94 *buflen = BLOCK_SIZE;95 }96 }97 98 return true;99 }100 60 101 61 static bool … … 111 71 uint32_t size; 112 72 113 if (! tmpfs_blockread(phone, block, bufpos, buflen, pos, &entry,114 sizeof(entry) ))73 if (!libfs_blockread(phone, block, bufpos, buflen, pos, &entry, 74 sizeof(entry), TMPFS_BLOCK_SIZE)) 115 75 return false; 116 76 … … 131 91 } 132 92 133 if (! tmpfs_blockread(phone, block, bufpos, buflen, pos,134 fname, entry.len )) {93 if (!libfs_blockread(phone, block, bufpos, buflen, pos, 94 fname, entry.len, TMPFS_BLOCK_SIZE)) { 135 95 ops->destroy((void *) node); 136 96 free(fname); … … 146 106 free(fname); 147 107 148 if (! tmpfs_blockread(phone, block, bufpos, buflen, pos,149 &size, sizeof(size) ))108 if (!libfs_blockread(phone, block, bufpos, buflen, pos, 109 &size, sizeof(size), TMPFS_BLOCK_SIZE)) 150 110 return false; 151 111 … … 157 117 158 118 node->size = size; 159 if (! tmpfs_blockread(phone, block, bufpos, buflen, pos,160 node->data, size ))119 if (!libfs_blockread(phone, block, bufpos, buflen, pos, 120 node->data, size, TMPFS_BLOCK_SIZE)) 161 121 return false; 162 122 … … 173 133 } 174 134 175 if (! tmpfs_blockread(phone, block, bufpos, buflen, pos,176 fname, entry.len )) {135 if (!libfs_blockread(phone, block, bufpos, buflen, pos, 136 fname, entry.len, TMPFS_BLOCK_SIZE)) { 177 137 ops->destroy((void *) node); 178 138 free(fname); … … 205 165 libfs_ops_t *ops = &tmpfs_libfs_ops; 206 166 207 void *block = mmap(NULL, BLOCK_SIZE,167 void *block = mmap(NULL, TMPFS_BLOCK_SIZE, 208 168 PROTO_READ | PROTO_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); 209 169 … … 215 175 216 176 if (phone < 0) { 217 munmap(block, BLOCK_SIZE);177 munmap(block, TMPFS_BLOCK_SIZE); 218 178 return false; 219 179 } … … 228 188 229 189 char tag[6]; 230 if (!tmpfs_blockread(phone, block, &bufpos, &buflen, &pos, tag, 5)) 190 if (!libfs_blockread(phone, block, &bufpos, &buflen, &pos, tag, 5, 191 TMPFS_BLOCK_SIZE)) 231 192 goto error; 232 193 … … 240 201 241 202 ipc_hangup(phone); 242 munmap(block, BLOCK_SIZE);203 munmap(block, TMPFS_BLOCK_SIZE); 243 204 return true; 244 205 245 206 error: 246 207 ipc_hangup(phone); 247 munmap(block, BLOCK_SIZE);208 munmap(block, TMPFS_BLOCK_SIZE); 248 209 return false; 249 210 }
Note:
See TracChangeset
for help on using the changeset viewer.