Changeset fc840d9 in mainline
- Timestamp:
- 2008-10-27T16:53:38Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7a5cdded
- Parents:
- 04619ba
- Location:
- uspace
- Files:
-
- 3 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/Makefile
r04619ba rfc840d9 35 35 lib/libc \ 36 36 lib/libfs \ 37 lib/libblock \ 37 38 lib/softint \ 38 39 lib/softfloat \ -
uspace/lib/libfs/libfs.c
r04619ba rfc840d9 37 37 #include "libfs.h" 38 38 #include "../../srv/vfs/vfs.h" 39 #include "../../srv/rd/rd.h"40 39 #include <errno.h> 41 40 #include <async.h> … … 332 331 } 333 332 334 /** Read data from a block device.335 *336 * @param phone Phone to be used to communicate with the device.337 * @param buffer Communication buffer shared with the device.338 * @param bufpos Pointer to the first unread valid offset within the339 * communication buffer.340 * @param buflen Pointer to the number of unread bytes that are ready in341 * the communication buffer.342 * @param pos Device position to be read.343 * @param dst Destination buffer.344 * @param size Size of the destination buffer.345 * @param block_size Block size to be used for the transfer.346 *347 * @return True on success, false on failure.348 */349 bool libfs_blockread(int phone, void *buffer, off_t *bufpos, size_t *buflen,350 off_t *pos, void *dst, size_t size, size_t block_size)351 {352 off_t offset = 0;353 size_t left = size;354 355 while (left > 0) {356 size_t rd;357 358 if (*bufpos + left < *buflen)359 rd = left;360 else361 rd = *buflen - *bufpos;362 363 if (rd > 0) {364 /*365 * Copy the contents of the communication buffer to the366 * destination buffer.367 */368 memcpy(dst + offset, buffer + *bufpos, rd);369 offset += rd;370 *bufpos += rd;371 *pos += rd;372 left -= rd;373 }374 375 if (*bufpos == *buflen) {376 /* Refill the communication buffer with a new block. */377 ipcarg_t retval;378 int rc = async_req_2_1(phone, RD_READ_BLOCK,379 *pos / block_size, block_size, &retval);380 if ((rc != EOK) || (retval != EOK))381 return false;382 383 *bufpos = 0;384 *buflen = block_size;385 }386 }387 388 return true;389 }390 391 333 /** @} 392 334 */ -
uspace/lib/libfs/libfs.h
r04619ba rfc840d9 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 *, off_t *, size_t *, off_t *, void *,73 size_t, size_t);74 75 72 #endif 76 73 -
uspace/srv/fs/fat/Makefile
r04619ba rfc840d9 32 32 LIBC_PREFIX = ../../../lib/libc 33 33 LIBFS_PREFIX = ../../../lib/libfs 34 LIBBLOCK_PREFIX = ../../../lib/libblock 34 35 SOFTINT_PREFIX = ../../../lib/softint 35 36 include $(LIBC_PREFIX)/Makefile.toolchain 36 37 37 CFLAGS += -I $(LIBFS_PREFIX) 38 CFLAGS += -I $(LIBFS_PREFIX) -I $(LIBBLOCK_PREFIX) 38 39 39 LIBS = $(LIBC_PREFIX)/libc.a $(LIBFS_PREFIX)/libfs.a 40 LIBS = \ 41 $(LIBC_PREFIX)/libc.a \ 42 $(LIBFS_PREFIX)/libfs.a \ 43 $(LIBBLOCK_PREFIX)/libblock.a 40 44 41 45 ## Sources -
uspace/srv/fs/fat/fat.h
r04619ba rfc840d9 198 198 } fat_node_t; 199 199 200 /* TODO move somewhere else */201 typedef struct block {202 void *data;203 size_t size;204 bool dirty;205 } block_t;206 207 extern block_t *block_get(dev_handle_t, off_t, size_t);208 extern void block_put(block_t *);209 210 200 extern fs_reg_t fat_reg; 211 201 -
uspace/srv/fs/fat/fat_fat.c
r04619ba rfc840d9 41 41 #include "../../vfs/vfs.h" 42 42 #include <libfs.h> 43 #include <libblock.h> 43 44 #include <errno.h> 44 45 #include <byteorder.h> -
uspace/srv/fs/fat/fat_ops.c
r04619ba rfc840d9 41 41 #include "../../vfs/vfs.h" 42 42 #include <libfs.h> 43 #include <libblock.h> 43 44 #include <ipc/ipc.h> 44 45 #include <ipc/services.h> … … 60 61 /** List of cached free FAT nodes. */ 61 62 static LIST_INITIALIZE(ffn_head); 62 63 static int dev_phone = -1; /* FIXME */64 static void *dev_buffer = NULL; /* FIXME */65 66 block_t *block_get(dev_handle_t dev_handle, off_t offset, size_t bs)67 {68 /* FIXME */69 block_t *b;70 off_t bufpos = 0;71 size_t buflen = 0;72 off_t pos = offset * bs;73 74 assert(dev_phone != -1);75 assert(dev_buffer);76 77 b = malloc(sizeof(block_t));78 if (!b)79 return NULL;80 81 b->data = malloc(bs);82 if (!b->data) {83 free(b);84 return NULL;85 }86 b->size = bs;87 88 if (!libfs_blockread(dev_phone, dev_buffer, &bufpos, &buflen, &pos,89 b->data, bs, bs)) {90 free(b->data);91 free(b);92 return NULL;93 }94 95 return b;96 }97 98 void block_put(block_t *block)99 {100 /* FIXME */101 free(block->data);102 free(block);103 }104 63 105 64 static void fat_node_initialize(fat_node_t *node) -
uspace/srv/fs/tmpfs/Makefile
r04619ba rfc840d9 32 32 LIBC_PREFIX = ../../../lib/libc 33 33 LIBFS_PREFIX = ../../../lib/libfs 34 LIBBLOCK_PREFIX = ../../../lib/libblock 34 35 SOFTINT_PREFIX = ../../../lib/softint 35 36 include $(LIBC_PREFIX)/Makefile.toolchain 36 37 37 CFLAGS += -I $(LIBFS_PREFIX) 38 CFLAGS += -I $(LIBFS_PREFIX) -I $(LIBBLOCK_PREFIX) 38 39 39 LIBS = $(LIBC_PREFIX)/libc.a $(LIBFS_PREFIX)/libfs.a 40 LIBS = \ 41 $(LIBC_PREFIX)/libc.a \ 42 $(LIBFS_PREFIX)/libfs.a \ 43 $(LIBBLOCK_PREFIX)/libblock.a 40 44 41 45 ## Sources -
uspace/srv/fs/tmpfs/tmpfs_dump.c
r04619ba rfc840d9 46 46 #include <sys/types.h> 47 47 #include <as.h> 48 #include <lib fs.h>48 #include <libblock.h> 49 49 #include <ipc/services.h> 50 50 #include <ipc/devmap.h> … … 71 71 uint32_t size; 72 72 73 if (! libfs_blockread(phone, block, bufpos, buflen, pos, &entry,73 if (!blockread(phone, block, bufpos, buflen, pos, &entry, 74 74 sizeof(entry), TMPFS_BLOCK_SIZE)) 75 75 return false; … … 91 91 } 92 92 93 if (! libfs_blockread(phone, block, bufpos, buflen, pos,94 fname,entry.len, TMPFS_BLOCK_SIZE)) {93 if (!blockread(phone, block, bufpos, buflen, pos, fname, 94 entry.len, TMPFS_BLOCK_SIZE)) { 95 95 ops->destroy((void *) node); 96 96 free(fname); … … 106 106 free(fname); 107 107 108 if (! libfs_blockread(phone, block, bufpos, buflen, pos,109 &size,sizeof(size), TMPFS_BLOCK_SIZE))108 if (!blockread(phone, block, bufpos, buflen, pos, &size, 109 sizeof(size), TMPFS_BLOCK_SIZE)) 110 110 return false; 111 111 … … 117 117 118 118 node->size = size; 119 if (! libfs_blockread(phone, block, bufpos, buflen, pos,119 if (!blockread(phone, block, bufpos, buflen, pos, 120 120 node->data, size, TMPFS_BLOCK_SIZE)) 121 121 return false; … … 133 133 } 134 134 135 if (! libfs_blockread(phone, block, bufpos, buflen, pos,136 fname,entry.len, TMPFS_BLOCK_SIZE)) {135 if (!blockread(phone, block, bufpos, buflen, pos, fname, 136 entry.len, TMPFS_BLOCK_SIZE)) { 137 137 ops->destroy((void *) node); 138 138 free(fname); … … 188 188 189 189 char tag[6]; 190 if (! libfs_blockread(phone, block, &bufpos, &buflen, &pos, tag, 5,190 if (!blockread(phone, block, &bufpos, &buflen, &pos, tag, 5, 191 191 TMPFS_BLOCK_SIZE)) 192 192 goto error;
Note:
See TracChangeset
for help on using the changeset viewer.