Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3251 → Rev 3252

/trunk/uspace/lib/libfs/libfs.c
333,10 → 333,25
#define RD_BASE 1024 // FIXME
#define RD_READ_BLOCK (RD_BASE + 1)
 
bool libfs_blockread(int phone, void *buffer, size_t *bufpos, size_t *buflen,
size_t *pos, void *dst, size_t size, size_t block_size)
/** Read data from a block device.
*
* @param phone Phone to be used to communicate with the device.
* @param buffer Communication buffer shared with the device.
* @param bufpos Pointer to the first unread valid offset within the
* communication buffer.
* @param buflen Pointer to the number of unread bytes that are ready in
* the communication buffer.
* @param pos Device position to be read.
* @param dst Destination buffer.
* @param size Size of the destination buffer.
* @param block_size Block size to be used for the transfer.
*
* @return True on success, false on failure.
*/
bool libfs_blockread(int phone, void *buffer, off_t *bufpos, size_t *buflen,
off_t *pos, void *dst, size_t size, size_t block_size)
{
size_t offset = 0;
off_t offset = 0;
size_t left = size;
while (left > 0) {
348,6 → 363,10
rd = *buflen - *bufpos;
if (rd > 0) {
/*
* Copy the contents of the communication buffer to the
* destination buffer.
*/
memcpy(dst + offset, buffer + *bufpos, rd);
offset += rd;
*bufpos += rd;
356,6 → 375,7
}
if (*bufpos == *buflen) {
/* Refill the communication buffer with a new block. */
ipcarg_t retval;
int rc = async_req_2_1(phone, RD_READ_BLOCK,
*pos / block_size, block_size, &retval);
/trunk/uspace/lib/libfs/libfs.h
69,7 → 69,7
 
extern void libfs_lookup(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);
 
extern bool libfs_blockread(int, void *, size_t *, size_t *, size_t *, void *,
extern bool libfs_blockread(int, void *, off_t *, size_t *, off_t *, void *,
size_t, size_t);
 
#endif