-
Notifications
You must be signed in to change notification settings - Fork 110
/
p_read.c
41 lines (36 loc) · 1.01 KB
/
p_read.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <pal.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include "pal_base.h"
#include "pal_base_private.h"
/**
*
* Copies the content of 'mem' into the area pointed to by the 'dst' pointer.
*
*
* @param mem Pointer to a memory object created with p_malloc();
*
* @param dst Address to copy the memory block to
*
* @param offset Offset (in bytes) relative to start of buffer.
*
* @param nb Number of bytes to copy
*
* @param flags Bitmask field indicating runtime options
* ASYNC: Specifies asynchronous (non-blocking) operation.
* The default is blocking.
*
*
* @return Returns number of bytes read. Negative value indicates error.
*
*/
ssize_t p_read(p_mem_t *mem, void *dst, off_t offset, size_t nb, int flags)
{
struct mem_ops *mem_ops = mem->ops;
if (p_mem_error(mem))
return p_mem_error(mem);
if (!mem_ops || !mem_ops->read)
return -ENOSYS;
return mem_ops->read(mem, dst, offset, nb, flags);
}